X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fmodules.c;h=58521baacafa28ae1791badb4012b5ac9de8ce3b;hb=270e5fe88b0666021a7a6393334db7feeb8245f8;hp=92dd8d31317aea188370963440d7777c411c6b1b;hpb=263987655706186a27d4c158ea30a00924f47f7d;p=tpg%2Facess2.git diff --git a/Kernel/modules.c b/Kernel/modules.c index 92dd8d31..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; @@ -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,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 */ @@ -382,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;