Working on GUI, side changes to the message passing
[tpg/acess2.git] / Kernel / modules.c
index a206cf9..e4f49b2 100644 (file)
@@ -27,6 +27,7 @@ extern void   gKernelModulesEnd;
  int   giNumBuiltinModules = 0;
  int   giModuleSpinlock = 0;
 tModule        *gLoadedModules = NULL;
+tModuleLoader  *gModule_Loaders = NULL;
 
 // === CODE ===
 int Modules_LoadBuiltins()
@@ -118,6 +119,20 @@ int Modules_LoadBuiltins()
        return 0;
 }
 
+/**
+ * \brief Registers a tModuleLoader with the kernel
+ * \param Loader       Pointer to loader structure (must be persistent)
+ */
+int Module_RegisterLoader(tModuleLoader *Loader)
+{
+       if(!Loader)     return 1;
+       
+       Loader->Next = gModule_Loaders;
+       gModule_Loaders = Loader;
+       
+       return 0;
+}
+
 /**
  * \fn int Module_LoadMem(void *Buffer, Uint Length, char *ArgString)
  * \brief Load a module from a memory location
@@ -152,6 +167,14 @@ int Module_LoadFile(char *Path, char *ArgString)
        // Check for Acess Driver
        if( Binary_FindSymbol(base, "DriverInfo", (Uint*)&info ) == 0 )
        {
+               tModuleLoader   *tmp;
+               for( tmp = gModule_Loaders; tmp; tmp = tmp->Next)
+               {
+                       if( tmp->Detector(base) == 0 )  continue;
+                       
+                       return tmp->Loader(base);
+               }
+               
                #if USE_EDI
                // Check for EDI Driver
                if( Binary_FindSymbol(base, "driver_init", NULL ) != 0 )
@@ -160,13 +183,6 @@ int Module_LoadFile(char *Path, char *ArgString)
                }
                #endif
                
-               #if USE_UDI
-               if( Binary_FindSymbol(base, "udi_init_info", NULL ) != 0 )
-               {
-                       return UDI_LoadDriver( base );  // And intialise
-               }
-               #endif
-               
                // Unknown module type?, return error
                Binary_Unload(base);
                #if USE_EDI

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