From 685491a25f8289aaa57ac85f0e7293a1f360ab05 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Sun, 3 Feb 2013 03:47:26 +0000 Subject: [PATCH] nvdisk.library: Make ROMable for m68k For now, it will place "nonvolatile"s in RAM:NVRAM/ if there is no ENV-ARCHIVE:SYS/nv_location preference. In the future, we should use the CD32's NVRAM on m68k to back nonvolatile.library Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@46475 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/libs/nonvolatile/nvdisk/nvdisk.conf | 2 + workbench/libs/nonvolatile/nvdisk/nvdisk_init.c | 87 +++++++++++++---------- workbench/libs/nonvolatile/nvdisk/nvdisk_intern.h | 4 ++ 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/workbench/libs/nonvolatile/nvdisk/nvdisk.conf b/workbench/libs/nonvolatile/nvdisk/nvdisk.conf index ce72fb2f3f..6e008f9e1c 100644 --- a/workbench/libs/nonvolatile/nvdisk/nvdisk.conf +++ b/workbench/libs/nonvolatile/nvdisk/nvdisk.conf @@ -2,6 +2,8 @@ basename NVDisk libbase nvdBase libbasetype struct NVDBase +seglist_field nvd_SegList +residentpri -126 version 42.0 ##end config diff --git a/workbench/libs/nonvolatile/nvdisk/nvdisk_init.c b/workbench/libs/nonvolatile/nvdisk/nvdisk_init.c index 9c3546619f..d3cbc5c57e 100644 --- a/workbench/libs/nonvolatile/nvdisk/nvdisk_init.c +++ b/workbench/libs/nonvolatile/nvdisk/nvdisk_init.c @@ -37,6 +37,10 @@ static int Init(LIBBASETYPEPTR LIBBASE) BOOL error = TRUE; // Notice the initialization to 'TRUE' here. char *temp = NULL; BPTR locFile; + + LIBBASE->nvd_DOSBase = OpenLibrary("dos.library",0); + if (LIBBASE->nvd_DOSBase == NULL) + return 0; D(bug("Init nvdisk.library\n")); @@ -46,43 +50,46 @@ static int Init(LIBBASETYPEPTR LIBBASE) if(locFile != BNULL) { - D(bug("Location file exists!\n")); - - temp = AllocVec(512, MEMF_CLEAR); - - if(temp != NULL) - { - int i = 0; // Loop variable - - Read(locFile, temp, 512); - - // End string if a carriage return is encountered - while(temp[i] != 0) - { - if(temp[i] == '\n') - { - temp[i] = 0; - break; - } - - i++; - } - - nvdBase->nvd_location = Lock(temp, SHARED_LOCK); - - D(bug("NV location = %s\n", temp)); - - FreeVec(temp); - - D(bug("Got lock = %p\n", nvdBase->nvd_location)); - - if(nvdBase->nvd_location != BNULL) - { - error = FALSE; - } - } - - Close(locFile); + D(bug("Location file exists!\n")); + + temp = AllocVec(512, MEMF_CLEAR); + + if(temp != NULL) + { + int i = 0; // Loop variable + + Read(locFile, temp, 512); + + // End string if a carriage return is encountered + while(temp[i] != 0) + { + if(temp[i] == '\n') + { + temp[i] = 0; + break; + } + + i++; + } + + nvdBase->nvd_location = Lock(temp, SHARED_LOCK); + + D(bug("NV location = %s\n", temp)); + + FreeVec(temp); + } + Close(locFile); + } else { + /* Volatile mode, if we have no nv_location file */ + UnLock(CreateDir("RAM:NVRAM")); + nvdBase->nvd_location = Lock("RAM:NVRAM", SHARED_LOCK); + } + + D(bug("Got lock = %p\n", nvdBase->nvd_location)); + + if(nvdBase->nvd_location != BNULL) + { + error = FALSE; } return !error; @@ -91,11 +98,13 @@ static int Init(LIBBASETYPEPTR LIBBASE) static int Expunge(LIBBASETYPEPTR LIBBASE) { /* - This function is single-threaded by exec by calling Forbid. - Never break the Forbid() or strange things might happen. + This function is single-threaded by exec by calling Forbid. + Never break the Forbid() or strange things might happen. */ UnLock(nvdBase->nvd_location); + + CloseLibrary(nvdBase->nvd_DOSBase); return TRUE; } diff --git a/workbench/libs/nonvolatile/nvdisk/nvdisk_intern.h b/workbench/libs/nonvolatile/nvdisk/nvdisk_intern.h index d51a2fee1f..6692c56671 100644 --- a/workbench/libs/nonvolatile/nvdisk/nvdisk_intern.h +++ b/workbench/libs/nonvolatile/nvdisk/nvdisk_intern.h @@ -20,11 +20,15 @@ struct NVDBase struct Library nvd_Lib; BPTR nvd_location; + BPTR nvd_SegList; + struct Library *nvd_DOSBase; }; /* Locate library bases */ #define GPB(x) ((struct NVDBase *)x) +#define DOSBase (((struct NVDBase *)nvdBase)->nvd_DOSBase) + #endif /* NVDISK_INTERN_H */ -- 2.11.4.GIT