#define USE_EDI 0
#define USE_UDI 0
+#define MODULE_FLAG_LOADERROR 0x1
// === PROTOTYPES ===
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;
Log_Warning("Module", "Unable to load reason - Unknown code %i", ret);
break;
}
+ Module->Flags |= MODULE_FLAG_LOADERROR;
LEAVE_RET('i', ret);
return ret;
}
VFS_GetMemPath(path, Buffer, Length);
- return Module_LoadFile( path, ArgString );
+ return Module_LoadFile( path, ArgString ) == EOK;
}
/**
// Error check
if(base == NULL) {
Log_Warning("Module", "Module_LoadFile - Unable to load '%s'", Path);
- return 0;
+ return ENOENT;
}
// 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);
+ Log_Warning("Module", "Relocation of module %s failed", Path);
Binary_Unload(base);
- return 0;
+ return EINVAL;
}
// Check for Acess Driver
if( !loader ) {
Binary_Unload(base);
Log_Warning("Module", "Module '%s' does not have a Module Info struct", Path);
- return 0;
+ return EINVAL;
}
}
- if( !Module_int_ResolveDeps(info) ) {
- Log_Warning("Dependencies not met for '%s'", Path);
- Binary_Unload(base);
- return 0;
+ if( loader )
+ {
+ if( loader->Loader(base) )
+ {
+ Binary_Unload(base);
+ return EINVAL;
+ }
}
-
- // Initialise (and register)
- if( loader ? loader->Loader(base) : Module_int_Initialise( info, ArgString ) )
+ else
{
- Binary_Unload(base);
- return 0;
+ if( !Module_int_ResolveDeps(info) ) {
+ Log_Warning("Module", "Dependencies not met for '%s'", Path);
+ Binary_Unload(base);
+ return EINVAL;
+ }
+
+ if( Module_int_Initialise(info, ArgString) )
+ {
+ Binary_Unload(base);
+ return EINVAL;
+ }
}
- return 1;
+ return 0;
}
/**