X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fmodules.c;h=87511aa656c4dfa91c4e2d6654476b9d3e47151a;hb=7d881c2e5fef91a6570e46ef69a5d4a5cf0e8b4d;hp=9f6d3c548932b427f98289b95877a9a590ff2663;hpb=b9615a08ff1f70d112b480673ebd5079468658a4;p=tpg%2Facess2.git diff --git a/Kernel/modules.c b/Kernel/modules.c index 9f6d3c54..87511aa6 100644 --- a/Kernel/modules.c +++ b/Kernel/modules.c @@ -17,7 +17,7 @@ void Modules_SetBuiltinParams(char *Name, char *ArgString); int Module_LoadMem(void *Buffer, Uint Length, char *ArgString); int Module_LoadFile(char *Path, char *ArgString); int Module_int_ResolveDeps(tModule *Info); - int Module_IsLoaded(char *Name); + int Module_IsLoaded(const char *Name); // === EXPORTS === EXPORT(Module_RegisterLoader); @@ -32,7 +32,7 @@ extern void gKernelModulesEnd; // === GLOBALS === int giNumBuiltinModules = 0; -tSpinlock glModuleSpinlock; +tShortSpinlock glModuleSpinlock; tModule *gLoadedModules = NULL; tModuleLoader *gModule_Loaders = NULL; tModule *gLoadingModules = NULL; @@ -43,6 +43,7 @@ char **gasBuiltinModuleArgs; /** * \brief Initialises a module * \param Module Pointer to the module header + * \param ArgString Comma separated list of module arguments * \return Zero on success, eModuleErrors or -1 on error * \retval -1 Returned if a dependency fails, or a circular dependency * exists. @@ -179,10 +180,10 @@ int Module_int_Initialise(tModule *Module, char *ArgString) LOG("ret = %i", ret); // Add to loaded list - LOCK( &glModuleSpinlock ); + SHORTLOCK( &glModuleSpinlock ); Module->Next = gLoadedModules; gLoadedModules = Module; - RELEASE( &glModuleSpinlock ); + SHORTREL( &glModuleSpinlock ); LEAVE_RET('i', 0); } @@ -251,6 +252,32 @@ void Modules_LoadBuiltins() free(gasBuiltinModuleArgs); } +/** + * \brief Initialise a builtin module given it's name + * \example Used by VTerm to load an alternate video driver at runtime + */ +int Modules_InitialiseBuiltin(const char *Name) +{ + int i; + + // Check if it's loaded + if( Module_IsLoaded(Name) ) + return 0; + + if( !gapBuiltinModules ) + Modules_int_GetBuiltinArray(); + + for( i = 0; i < giNumBuiltinModules; i++ ) + { + if( strcmp(gapBuiltinModules[i]->Name, Name) == 0 ) { + return Module_int_Initialise(gapBuiltinModules[i], + (gasBuiltinModuleArgs ? gasBuiltinModuleArgs[i] : NULL) + ); + } + } + return -1; +} + /** * \brief Sets the parameters for a builtin module */ @@ -349,39 +376,12 @@ int Module_LoadFile(char *Path, char *ArgString) return 0; } - #if 1 + // Initialise (and register) if( Module_int_Initialise( info, ArgString ) ) { Binary_Unload(base); return 0; } - #else - // Resolve Dependencies - if( !Module_int_ResolveDeps(info) ) { - Binary_Unload(base); - return 0; - } - - Log_Log("Module", "Initialising %p '%s' v%i.%i...", - info, - info->Name, - info->Version>>8, info->Version & 0xFF - ); - - // Call Initialiser - //if( info->Init( ArgString ) != 0 ) - if( info->Init( NULL ) == 0 ) - { - Binary_Unload(base); - return 0; - } - - // Add to list - LOCK( &glModuleSpinlock ); - info->Next = gLoadedModules; - gLoadedModules = info; - RELEASE( &glModuleSpinlock ); - #endif return 1; } @@ -409,11 +409,11 @@ int Module_int_ResolveDeps(tModule *Info) } /** - * \fn int Module_IsLoaded(char *Name) + * \fn int Module_IsLoaded(const char *Name) * \brief Checks if a module is loaded * \param Name Name of module to find */ -int Module_IsLoaded(char *Name) +int Module_IsLoaded(const char *Name) { tModule *mod = gLoadedModules;