2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Nonvolatile disk based storage library initialization code.
12 #include "nvdisk_intern.h"
14 #include <aros/debug.h>
16 #include <exec/types.h>
17 #include <exec/resident.h>
18 #include <proto/exec.h>
19 #include <proto/dos.h>
20 #include <devices/timer.h>
21 #include <aros/symbolsets.h>
23 #include <exec/libraries.h>
24 #include <exec/memory.h>
25 #include <exec/alerts.h>
26 #include LC_LIBDEFS_FILE
29 static int Init(LIBBASETYPEPTR LIBBASE
)
32 This function is single-threaded by exec by calling Forbid.
33 If you break the Forbid() another task may enter this function
34 at the same time. Take care.
37 BOOL error
= TRUE
; // Notice the initialization to 'TRUE' here.
41 LIBBASE
->nvd_DOSBase
= OpenLibrary("dos.library",0);
42 if (LIBBASE
->nvd_DOSBase
== NULL
)
45 D(bug("Init nvdisk.library\n"));
47 locFile
= Open("SYS:prefs/env-archive/sys/nv_location", MODE_OLDFILE
);
49 D(bug("Getting location\n"));
53 D(bug("Location file exists!\n"));
55 temp
= AllocVec(512, MEMF_CLEAR
);
59 int i
= 0; // Loop variable
61 Read(locFile
, temp
, 512);
63 // End string if a carriage return is encountered
75 nvdBase
->nvd_location
= Lock(temp
, SHARED_LOCK
);
77 D(bug("NV location = %s\n", temp
));
83 /* Volatile mode, if we have no nv_location file */
84 UnLock(CreateDir("RAM:NVRAM"));
85 nvdBase
->nvd_location
= Lock("RAM:NVRAM", SHARED_LOCK
);
88 D(bug("Got lock = %p\n", nvdBase
->nvd_location
));
90 if(nvdBase
->nvd_location
!= BNULL
)
98 static int Expunge(LIBBASETYPEPTR LIBBASE
)
101 This function is single-threaded by exec by calling Forbid.
102 Never break the Forbid() or strange things might happen.
105 UnLock(nvdBase
->nvd_location
);
107 CloseLibrary(nvdBase
->nvd_DOSBase
);
112 ADD2INITLIB(Init
, 0);
113 ADD2EXPUNGELIB(Expunge
, 0);