00001
00002
00003
00004
00023 #ifndef _MODULE_H
00024 #define _MODULE_H
00025
00029 #define MODULE_MAGIC ('A'|('M'<<8)|('D'<<16)|('\2'<<24))
00030
00035
00036 #if ARCHDIR == x86
00037 # define MODULE_ARCH_ID 1
00038
00039 #elif ARCHDIR == x86_64
00040 # define MODULE_ARCH_ID 2
00041 #else
00042 # error "Unknown architecture when determining MODULE_ARCH_ID ('" #ARCHDIR "')"
00043 #endif
00044
00055 #define MODULE_DEFINE(_flags,_ver,_ident,_entry,_deinit,_deps...) \
00056 char *EXPAND_CONCAT(_DriverDeps_,_ident)[]={_deps};\
00057 tModule __attribute__ ((section ("KMODULES"),unused))\
00058 EXPAND_CONCAT(_DriverInfo_,_ident)=\
00059 {MODULE_MAGIC,MODULE_ARCH_ID,_flags,_ver,NULL,EXPAND_STR(_ident),\
00060 _entry,_deinit,EXPAND_CONCAT(_DriverDeps_,_ident)}
00061
00067 typedef struct sModule
00068 {
00069 Uint32 Magic;
00070 Uint8 Arch;
00071 Uint8 Flags;
00072 Uint16 Version;
00073 struct sModule *Next;
00074 char *Name;
00075 int (*Init)(char **Arguments);
00076 void (*Deinit)(void);
00077 char **Dependencies;
00078 } PACKED tModule;
00079
00083 enum eModuleErrors
00084 {
00085 MODULE_ERR_OK,
00086 MODULE_ERR_MISC,
00087 MODULE_ERR_NOTNEEDED,
00088 MODULE_ERR_MALLOC,
00089
00090 MODULE_ERR_BADMODULE,
00091 MODULE_ERR_MAX
00092 };
00093
00100 typedef struct sModuleLoader
00101 {
00102 struct sModuleLoader *Next;
00103 char *Name;
00104 int (*Detector)(void *Base);
00105 int (*Loader)(void *Base);
00106 int (*Unloader)(void *Base);
00107 } PACKED tModuleLoader;
00108
00114 extern int Module_RegisterLoader(tModuleLoader *Loader);
00115
00121 extern int Modules_InitialiseBuiltin(const char *Name);
00122
00123 #endif