X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fmodules.c;h=58521baacafa28ae1791badb4012b5ac9de8ce3b;hb=3e11c7767641614fbb3fad38fffefa0da9e66919;hp=009ade37c14205ce39f4a1299294572817a8ecc5;hpb=7a0937309ce3538a05c140022b39ceb0d7d7264a;p=tpg%2Facess2.git diff --git a/Kernel/modules.c b/Kernel/modules.c index 009ade37..58521baa 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; @@ -180,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); } @@ -252,6 +252,33 @@ void Modules_LoadBuiltins() free(gasBuiltinModuleArgs); } +/** + * \brief Initialise a builtin module given it's name + * + * E.g. 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 */ @@ -383,11 +410,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;