Misc Changes, Added Logging Subsystem, Fixes to InitRD, Working on RTL8139 driver
[tpg/acess2.git] / Kernel / modules.c
index 5b5a906..37f5418 100644 (file)
@@ -7,15 +7,19 @@
 #include <modules.h>
 
 #define        USE_EDI 0
-#define        USE_UDI 1
+#define        USE_UDI 0
 
 // === PROTOTYPES ===
- int   Modules_LoadBuiltins();
+ int   Modules_LoadBuiltins(void);
+ int   Module_RegisterLoader(tModuleLoader *Loader);
  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);
 
+// === EXPORTS ===
+EXPORT(Module_RegisterLoader);
+
 // === IMPORTS ===
 #if USE_UDI
 extern int     UDI_LoadDriver(void *Base);
@@ -26,7 +30,7 @@ extern void   gKernelModulesEnd;
 
 // === GLOBALS ===
  int   giNumBuiltinModules = 0;
- int   giModuleSpinlock = 0;
+tSpinlock      glModuleSpinlock;
 tModule        *gLoadedModules = NULL;
 tModuleLoader  *gModule_Loaders = NULL;
 tModule        *gLoadingModules = NULL;
@@ -114,31 +118,33 @@ int Module_int_Initialise(tModule *Module)
        
        ret = Module->Init(NULL);
        if( ret != MODULE_ERR_OK ) {
-               Log("[MOD  ] Loading Failed, all modules that depend on this will also fail");
                switch(ret)
                {
                case MODULE_ERR_MISC:
-                       Log("[MOD  ] Reason: Miscelanious");
+                       Warning("[MOD  ] Unable to load, reason: Miscelanious");
                        break;
                case MODULE_ERR_NOTNEEDED:
-                       Log("[MOD  ] Reason: Module not needed (probably hardware not found)");
+                       Warning("[MOD  ] Unable to load, reason: Module not needed (probably hardware not found)");
                        break;
                case MODULE_ERR_MALLOC:
-                       Log("[MOD  ] Reason: Error in malloc/realloc/calloc, probably not good");
+                       Warning("[MOD  ] Unable to load, reason: Error in malloc/realloc/calloc, probably not good");
                        break;
                default:
-                       Log("[MOD  ] Reason - Unknown code %i", ret);
+                       Warning("[MOD  ] Unable to load reason - Unknown code %i", ret);
                        break;
                }
                LEAVE_RET('i', ret);
+               return ret;
        }
        
        // Remove from loading list
        gLoadingModules = gLoadingModules->Next;
        
        // Add to loaded list
+       LOCK( &glModuleSpinlock );
        Module->Next = gLoadedModules;
        gLoadedModules = Module;
+       RELEASE( &glModuleSpinlock );
        
        LEAVE_RET('i', 0);
 }
@@ -250,6 +256,13 @@ int Module_LoadFile(char *Path, char *ArgString)
                return 0;
        }
        
+       #if 1
+       if( Module_int_Initialise( info ) )
+       {
+               Binary_Unload(base);
+               return 0;
+       }
+       #else
        // Resolve Dependencies
        if( !Module_int_ResolveDeps(info) ) {
                Binary_Unload(base);
@@ -271,10 +284,11 @@ int Module_LoadFile(char *Path, char *ArgString)
        }
        
        // Add to list
-       LOCK( &giModuleSpinlock );
+       LOCK( &glModuleSpinlock );
        info->Next = gLoadedModules;
        gLoadedModules = info;
-       RELEASE( &giModuleSpinlock );
+       RELEASE( &glModuleSpinlock );
+       #endif
        
        return 1;
 }

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