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);
// === GLOBALS ===
int giNumBuiltinModules = 0;
-tSpinlock glModuleSpinlock;
+tShortSpinlock glModuleSpinlock;
tModule *gLoadedModules = NULL;
tModuleLoader *gModule_Loaders = NULL;
tModule *gLoadingModules = NULL;
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);
}
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
*/
}
/**
- * \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;