8 #define MODULE_MAGIC ('A'|('M'<<8)|('D'<<16)|('\2'<<24))
10 // IA32 - Architecture 1
12 # define MODULE_ARCH_ID 1
13 // IA64 - Architecture 2
15 # define MODULE_ARCH_ID 2
17 # error "Unknown architecture when determining MODULE_ARCH_ID ('" #ARCHDIR "')"
20 #define MODULE_DEFINE(_flags,_ver,_ident,_entry,_deinit,_deps...) \
21 char *EXPAND_CONCAT(_DriverDeps_,_ident)[]={_deps};\
22 tModule __attribute__ ((section ("KMODULES"),unused))\
23 EXPAND_CONCAT(_DriverInfo_,_ident)=\
24 {MODULE_MAGIC,MODULE_ARCH_ID,_flags,_ver,NULL,EXPAND_STR(_ident),\
25 _entry,_deinit,EXPAND_CONCAT(_DriverDeps_,_ident)}
27 typedef struct sModule {
34 int (*Init)(char **Arguments);
36 char **Dependencies; // NULL Terminated List
37 } __attribute__((packed)) tModule;
41 MODULE_ERR_OK, //!< No Error
42 MODULE_ERR_MISC, //!< Misc Error
43 MODULE_ERR_NOTNEEDED, //!< Module not needed
44 MODULE_ERR_MALLOC, //!< Error with malloc/realloc/calloc
50 * \brief Module Loader definition
52 * Allows a module to extend the loader to recognise other module types
53 * E.g. EDI, UDI, Windows, Linux, ...
55 typedef struct sModuleLoader {
56 struct sModuleLoader *Next; //!< Kernel Only - Next loader in list
57 char *Name; //!< Friendly name for the loader
58 int (*Detector)(void *Base); //!< Simple detector function
59 int (*Loader)(void *Base); //!< Initialises the module
60 int (*Unloader)(void *Base); //!< Calls module's cleanup
61 } PACKED tModuleLoader;
64 * \brief Registers a tModuleLoader with the kernel
65 * \param Loader Pointer to loader structure (must be persistent)
67 extern int Module_RegisterLoader(tModuleLoader *Loader);