*.d
*.ao
*.ao.*
+*.so
+*.bin.*
+*.dsm.*
+*.dsm
+*.dmp
+Map.txt
+map.txt
MAKEDEP = $(CC) -M
CPPFLAGS += -I./include -I./arch/$(ARCHDIR)/include
-CPPFLAGS += -DARCH=$(ARCH) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
+CPPFLAGS += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
CFLAGS += -Wall -Werror -O3 -fno-stack-protector -fno-builtin
-ASFLAGS += -D ARCH=\"$(ARCH)\"
+ASFLAGS += -D ARCH=\"$(ARCH)\" -D ARCHDIR=\"$(ARCHDIR)\"
LDFLAGS += -T arch/$(ARCHDIR)/link.ld
ifeq ($(DEBUG_BUILD),yes)
-BUILD_NUM = 1353
+BUILD_NUM = 1359
#define MODULE_MAGIC ('A'|('M'<<8)|('D'<<16)|('\2'<<24))
// IA32 - Architecture 1
-#if ARCH == i386 || ARCH == i586
+#if ARCHDIR == x86
# define MODULE_ARCH_ID 1
// IA64 - Architecture 2
-#elif ARCH == x64 || ARCH == x86_64
+#elif ARCHDIR == x64
# define MODULE_ARCH_ID 2
#else
-# error "Unknown architecture when determining MODULE_ARCH_ID ('" #ARCH "')"
+# error "Unknown architecture when determining MODULE_ARCH_ID ('" #ARCHDIR "')"
#endif
#define MODULE_DEFINE(_flags,_ver,_ident,_entry,_deinit,_deps...) char *_DriverDeps_##_ident[]={_deps};\
#define MODULE_INIT_SUCCESS 1
#define MODULE_INIT_FAILURE 0
+/**
+ * \brief Module Loader definition
+ *
+ * Allows a module to extend the loader to recognise other module types
+ * E.g. EDI, UDI, Windows, Linux, ...
+ */
+typedef struct sModuleLoader {
+ struct sModuleLoader *Next; //!< Kernel Only - Next loader in list
+ char *Name; //!< Friendly name for the loader
+ int (*Detector)(void *Base); //!< Simple detector function
+ int (*Loader)(void *Base); //!< Initialises the module
+ int (*Unloader)(void *Base); //!< Calls module's cleanup
+} PACKED tModuleLoader;
+
+/**
+ * \brief Registers a tModuleLoader with the kernel
+ * \param Loader Pointer to loader structure (must be persistent)
+ */
+extern int Module_RegisterLoader(tModuleLoader *Loader);
+
#endif
int giNumBuiltinModules = 0;
int giModuleSpinlock = 0;
tModule *gLoadedModules = NULL;
+tModuleLoader *gModule_Loaders = NULL;
// === CODE ===
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
// 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 )
}
#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
FILESYSTEMS = fat
DRIVERS = ata_x86
-MODULES = FS_Ext2 FDD NE2000 BochsGA IPStack UDI
-DYNMODS = USB
-# UDI
+MODULES = FS_Ext2 FDD NE2000 BochsGA IPStack
+DYNMODS = USB UDI
#DISTROOT = /mnt/AcessHDD/Acess2
#DISTROOT = ~/Projects/Acess2/Filesystem
// === PROTOTYPES ===
int UDI_Install(char **Arguments);
+ int UDI_DetectDriver(void *Base);
int UDI_LoadDriver(void *Base);
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, UDI, UDI_Install, NULL, NULL);
+tModuleLoader gUDI_Loader = {
+ NULL, "UDI", UDI_DetectDriver, UDI_LoadDriver, NULL
+};
// === CODE ===
/**
*/
int UDI_Install(char **Arguments)
{
+ Module_RegisterLoader( &gUDI_Loader );
+ return 1;
+}
+
+/**
+ * \brief Detects if a driver should be loaded by the UDI subsystem
+ */
+int UDI_DetectDriver(void *Base)
+{
+ if( Binary_FindSymbol(Base, "udi_init_info", NULL) == 0) {
+ return 0;
+ }
+
return 1;
}
{
udi_init_t *info;
char *udiprops = NULL;
- int udiprops_size;
+ int udiprops_size = 0;
int i;
// int j;
}
else {
Binary_FindSymbol(Base, "_udiprops_size", (Uint*)&udiprops_size);
+ Log("udiprops = %p, udiprops_size = 0x%x", udiprops, udiprops_size);
}
+
Log("primary_init_info = %p = {", info->primary_init_info);
{
Log(" .mgmt_ops = %p = {", info->primary_init_info->mgmt_ops);