Reorganised the modules directory, started serious work on GUI support
[tpg/acess2.git] / Kernel / include / modules.h
1 /*
2  * AcessOS 2
3  * - Module Loader
4  */
5 #ifndef _MODULE_H
6 #define _MODULE_H
7
8 #define MODULE_MAGIC    ('A'|('M'<<8)|('D'<<16)|('\2'<<24))
9
10 // IA32 - Architecture 1
11 #if ARCHDIR == x86
12 # define MODULE_ARCH_ID 1
13 // IA64 - Architecture 2
14 #elif ARCHDIR == x64
15 # define MODULE_ARCH_ID 2
16 #else
17 # error "Unknown architecture when determining MODULE_ARCH_ID ('" #ARCHDIR "')"
18 #endif
19
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)}
26
27 typedef struct sModule {
28         Uint32  Magic;
29         Uint8   Arch;
30         Uint8   Flags;
31         Uint16  Version;
32         struct sModule  *Next;
33         char    *Name;
34          int    (*Init)(char **Arguments);
35         void    (*Deinit)();
36         char    **Dependencies; // NULL Terminated List
37 } __attribute__((packed)) tModule;
38
39 #define MODULE_INIT_SUCCESS     1
40 #define MODULE_INIT_FAILURE     0
41
42 /**
43  * \brief Module Loader definition
44  * 
45  * Allows a module to extend the loader to recognise other module types
46  * E.g. EDI, UDI, Windows, Linux, ...
47  */
48 typedef struct sModuleLoader {
49         struct sModuleLoader    *Next;  //!< Kernel Only - Next loader in list
50         char    *Name;  //!< Friendly name for the loader
51          int    (*Detector)(void *Base);        //!< Simple detector function
52          int    (*Loader)(void *Base);  //!< Initialises the module
53          int    (*Unloader)(void *Base);        //!< Calls module's cleanup
54 } PACKED tModuleLoader;
55
56 /**
57  * \brief Registers a tModuleLoader with the kernel
58  * \param Loader        Pointer to loader structure (must be persistent)
59  */
60 extern int      Module_RegisterLoader(tModuleLoader *Loader);
61
62 #endif

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