diff options
author | Stefan Bucur <stefanb@zytor.com> | 2008-06-09 17:55:57 +0300 |
---|---|---|
committer | Stefan Bucur <stefanb@zytor.com> | 2008-06-09 17:55:57 +0300 |
commit | e4642a4d0fac67f22e2e63cbcaea915c507e241e (patch) | |
tree | 7457b6fd2d29401b73d4780497fb0a45a5ac3954 /elf/elf_module.h | |
parent | 80a1747d4b8c5149af0c6101fa5110dcda85d2fe (diff) | |
download | syslinux-elf-e4642a4d0fac67f22e2e63cbcaea915c507e241e.tar.gz syslinux-elf-e4642a4d0fac67f22e2e63cbcaea915c507e241e.tar.xz syslinux-elf-e4642a4d0fac67f22e2e63cbcaea915c507e241e.zip |
Created the basic module infrastructure.
Diffstat (limited to 'elf/elf_module.h')
-rw-r--r-- | elf/elf_module.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/elf/elf_module.h b/elf/elf_module.h new file mode 100644 index 00000000..fd0e15c5 --- /dev/null +++ b/elf/elf_module.h @@ -0,0 +1,58 @@ +#ifndef ELF_MODULE_H_ +#define ELF_MODULE_H_ + +#include <elf.h> +#include <stdint.h> +#include "linux_list.h" + +#define MODULE_NAME_SIZE 64 + +#define MODULE_ELF_CLASS ELFCLASS32 +#define MODULE_ELF_DATA ELFDATA2LSB +#define MODULE_ELF_VERSION EV_CURRENT + + +typedef int (*module_init_func)(); +typedef void (*module_exit_func)(); + +// Structure encapsulating a module loaded in memory +struct elf_module { + char name[MODULE_NAME_SIZE]; // The module name + + struct list_head deps; // Head of module dependency list + struct list_head list; // The list entry in the module list + + module_init_func init_func; // The initialization entry point + module_exit_func exit_func; // The module finalization code + + void *file_image; // The image of the module file in memory + uint32_t file_size; // The size of the module file + + // Information for modules loaded in user space +#ifdef ELF_USERSPACE_TEST + int file_fd; // The file descriptor of the open file +#endif +}; + +// Structure encapsulating a module dependency need +struct module_dep { + struct list_head list; // The list entry in the dependency list + + char name[MODULE_NAME_SIZE]; // The name of the module +}; + +// Initialization of the module subsystem +extern int modules_init(); +// Termination of the module subsystem +extern void modules_term(); + +// Allocates the structure for a new module +extern struct elf_module *module_alloc(const char *name); + +// Loads the module into the system +extern int module_load(struct elf_module *module); + +// Unloads the module from the system and releases all the associated memory +extern int module_unload(struct elf_module *module); + +#endif /*ELF_MODULE_H_*/ |