void Arch_LoadBootModules(void)
{
- int i, j, numPages;
- for( i = 0; i < giArch_NumBootModules; i ++ )
+ for( int i = 0; i < giArch_NumBootModules; i ++ )
{
- Log_Log("Arch", "Loading '%s'", gaArch_BootModules[i].ArgString);
+ const tBootModule *mod = &gaArch_BootModules[i];
+ Log_Log("Arch", "Loading (%p[%P]+%x) '%s'",
+ mod->Base, mod->PBase, mod->Size,
+ mod->ArgString);
- if( !Module_LoadMem( gaArch_BootModules[i].Base,
- gaArch_BootModules[i].Size, gaArch_BootModules[i].ArgString
- ) )
- {
+ if( !Module_LoadMem( mod->Base, mod->Size, mod->ArgString) ) {
Log_Warning("Arch", "Unable to load module");
+ continue ;
}
+ #if 0
// Unmap and free
- numPages = (gaArch_BootModules[i].Size + ((Uint)gaArch_BootModules[i].Base&0xFFF) + 0xFFF) >> 12;
+ int numPages = (mod->Size + ((tVAddr)mod->Base&0xFFF) + 0xFFF) >> 12;
MM_UnmapHWPages( (tVAddr)gaArch_BootModules[i].Base, numPages );
- for( j = 0; j < numPages; j++ )
- MM_DerefPhys( gaArch_BootModules[i].PBase + (j << 12) );
+ //for( int j = 0; j < numPages; j++ )
+ // MM_DerefPhys( mod->PBase + (j << 12) );
- if( (tVAddr) gaArch_BootModules[i].ArgString > MAX_ARGSTR_POS )
- MM_UnmapHWPages( (tVAddr)gaArch_BootModules[i].ArgString, 2 );
+ if( (tVAddr) mod->ArgString > MAX_ARGSTR_POS )
+ MM_UnmapHWPages( (tVAddr)mod->ArgString, 2 );
+ #endif
}
Log_Log("Arch", "Boot modules loaded");
if( gaArch_BootModules )
*/
Uint Binary_GetSymbolEx(const char *Name, Uint *Value)
{
- int i;
tKernelBin *pKBin;
int numKSyms = ((Uint)&gKernelSymbolsEnd-(Uint)&gKernelSymbols)/sizeof(tKernelSymbol);
- LOG("numKSyms = %i", numKSyms);
-
// Scan Kernel
- for( i = 0; i < numKSyms; i++ )
+ for( int i = 0; i < numKSyms; i++ )
{
- LOG("KSym %s = %p", gKernelSymbols[i].Name, gKernelSymbols[i].Value);
if(strcmp(Name, gKernelSymbols[i].Name) == 0) {
+ LOG("KSym %s = %p", gKernelSymbols[i].Name, gKernelSymbols[i].Value);
*Value = gKernelSymbols[i].Value;
return 1;
}
}
+
// Scan Loaded Libraries
for(pKBin = glLoadedKernelLibs;
pKBin;
// === PROTOTYPES ===
int Module_int_Initialise(tModule *Module, const char *ArgString);
+size_t Modules_int_PopulateBuiltins(tModule **Array);
void Modules_int_GetBuiltinArray(void);
void Modules_LoadBuiltins(void);
void Modules_SetBuiltinParams(const char *Name, char *ArgString);
LEAVE_RET('i', 0);
}
-/**
- * \brief Scans the builtin modules and creates an array of them
- */
-void Modules_int_GetBuiltinArray(void)
+size_t Modules_int_PopulateBuiltins(tModule **Array)
{
- int i;
- tModule *module;
-
- // Count
- module = &gKernelModules;
- i = 0;
- while( (tVAddr)module < (tVAddr)&gKernelModulesEnd )
+ size_t count = 0;
+ for( tModule *module = &gKernelModules; module < (tModule*)&gKernelModulesEnd; )
{
if(module->Magic == MODULE_MAGIC) {
- i ++;
+ if( Array ) {
+ Array[count] = module;
+ }
+ count ++;
module ++;
}
- else
+ else {
module = (void*)( (tVAddr)module + 4 );
+ }
}
-
- // Create
- giNumBuiltinModules = i;
- gasBuiltinModuleArgs = calloc( giNumBuiltinModules, sizeof(char*) );
- gapBuiltinModules = malloc( giNumBuiltinModules * sizeof(tModule*) );
-
-
- // Fill
- module = &gKernelModules;
- i = 0;
- while( (tVAddr)module < (tVAddr)&gKernelModulesEnd )
+ return count;
+}
+
+/**
+ * \brief Scans the builtin modules and creates an array of them
+ */
+void Modules_int_GetBuiltinArray(void)
+{
+ if( !gapBuiltinModules )
{
- if(module->Magic == MODULE_MAGIC) {
- gapBuiltinModules[i] = module;
- i ++;
- module ++;
- }
- else
- module = (void*)( (tVAddr)module + 4 );
+ // Count
+ giNumBuiltinModules = Modules_int_PopulateBuiltins(NULL);
+
+ // Create
+ gasBuiltinModuleArgs = calloc( giNumBuiltinModules, sizeof(char*) );
+ gapBuiltinModules = malloc( giNumBuiltinModules * sizeof(tModule*) );
+
+ // Fill
+ Modules_int_PopulateBuiltins(gapBuiltinModules);
}
}
/**
* \brief Initialises builtin modules
*/
-void Modules_LoadBuiltins()
+void Modules_LoadBuiltins(void)
{
- int i;
-
- if( !gapBuiltinModules )
- Modules_int_GetBuiltinArray();
-
- for( i = 0; i < giNumBuiltinModules; i++ )
+ Modules_int_GetBuiltinArray();
+ for( int i = 0; i < giNumBuiltinModules; i++ )
{
Module_int_Initialise(
gapBuiltinModules[i],
memset(ret, 0, sizeof(tVFS_Node));
// State
+ ret->Inode = base;
ret->ImplPtr = (void*)base;
ret->Size = size;