Fixing up doxygen comments
[tpg/acess2.git] / Kernel / modules.c
index 9f6d3c5..58521ba 100644 (file)
@@ -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
  */
@@ -349,39 +377,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 +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;
        

UCC git Repository :: git.ucc.asn.au