X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fmodules.c;h=dd8a3ae1f0ab6a1926694d64f1fefc847773539b;hb=d8b31df1121ff75fe218f83574eb600c47f8d2d5;hp=e3e0ebeba68cb5ca753bca981a828b38222ff1bb;hpb=67c9c489ba80c23739854905cf6d2f378193c9a8;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/modules.c b/KernelLand/Kernel/modules.c index e3e0ebeb..dd8a3ae1 100644 --- a/KernelLand/Kernel/modules.c +++ b/KernelLand/Kernel/modules.c @@ -8,6 +8,7 @@ #define USE_EDI 0 #define USE_UDI 0 +#define MODULE_FLAG_LOADERROR 0x1 // === PROTOTYPES === int Module_int_Initialise(tModule *Module, const char *ArgString); @@ -80,6 +81,15 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) "Module %p (%s) is for another architecture (%i)", Module, Module->Name, Module->Arch ); + LEAVE('i', MODULE_ERR_BADMODULE); + return MODULE_ERR_BADMODULE; + } + + LOG("Module->Flags = %x", Module->Flags); + if(Module->Flags & MODULE_FLAG_LOADERROR ) { + Log_Warning("Module", "%s has already attempted to load and encountered errors", Module->Name); + LEAVE('i', MODULE_ERR_MISC); + return MODULE_ERR_MISC; } deps = Module->Dependencies; @@ -168,7 +178,7 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) Log_Warning("Module", "Unable to load, reason: Miscelanious"); break; case MODULE_ERR_NOTNEEDED: -// Log_Debug("Module", "Unable to load, reason: Module not needed"); + Log_Debug("Module", "Unable to load, reason: Module not needed"); break; case MODULE_ERR_MALLOC: Log_Warning("Module", "Unable to load, reason: Error in malloc/realloc/calloc, probably not good"); @@ -177,6 +187,7 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) Log_Warning("Module", "Unable to load reason - Unknown code %i", ret); break; } + Module->Flags |= MODULE_FLAG_LOADERROR; LEAVE_RET('i', ret); return ret; } @@ -351,9 +362,17 @@ int Module_LoadFile(const char *Path, const char *ArgString) Log_Warning("Module", "Module_LoadFile - Unable to load '%s'", Path); return 0; } + + // TODO: I need a way of relocating the dependencies before everything else, so + // they can be resolved before any other link errors + if( !Binary_Relocate(base) ) { + Log_Warning("Relocation of module %s failed", Path); + Binary_Unload(base); + return 0; + } // Check for Acess Driver - if( Binary_FindSymbol(base, "DriverInfo", (Uint*)&info ) ) + if( Binary_FindSymbol(base, "DriverInfo", (Uint*)&info ) == 0 ) { for( loader = gModule_Loaders; loader; loader = loader->Next) { @@ -375,12 +394,6 @@ int Module_LoadFile(const char *Path, const char *ArgString) return 0; } - if( !Binary_Relocate(base) ) { - Log_Warning("Relocation of module %s failed", Path); - Binary_Unload(base); - return 0; - } - // Initialise (and register) if( loader ? loader->Loader(base) : Module_int_Initialise( info, ArgString ) ) {