toaruos/base/usr/include/kernel/module.h

43 lines
1014 B
C
Raw Normal View History

2018-03-16 15:56:19 +03:00
#pragma once
2018-03-19 05:38:11 +03:00
#include <kernel/types.h>
#include <toaru/hashmap.h>
2018-03-16 15:56:19 +03:00
typedef struct {
char * name;
int (* initialize)(void);
int (* finalize)(void);
} module_defs;
typedef struct {
module_defs * mod_info;
void * bin_data;
hashmap_t * symbols;
uintptr_t end;
size_t deps_length;
char * deps;
} module_data_t;
void (* symbol_find(const char * name))(void);
extern int module_quickcheck(void * blob);
extern void * module_load_direct(void * blob, size_t size);
extern void * module_load(char * filename);
extern void module_unload(char * name);
extern void modules_install(void);
#define MODULE_DEF(n,init,fini) \
module_defs module_info_ ## n = { \
.name = #n, \
.initialize = &init, \
.finalize = &fini \
}
extern hashmap_t * modules_get_list(void);
extern hashmap_t * modules_get_symbols(void);
#define MODULE_DEPENDS(n) \
static char _mod_dependency_ ## n [] __attribute__((section("moddeps"), used)) = #n