remove typedef cmd_tbl_t and replace it with struct command
[barebox-mini2440.git] / include / module.h
blob9d0e803344ebde5331356f579e32e90953435dca
1 #ifndef __MODULE_H
2 #define __MODULE_H
4 #include <elf.h>
5 #include <linux/compiler.h>
6 #include <linux/list.h>
8 #ifndef MODULE_SYMBOL_PREFIX
9 #define MODULE_SYMBOL_PREFIX
10 #endif
12 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
14 #ifdef CONFIG_MODULES
15 #include <asm/module.h>
17 struct kernel_symbol
19 unsigned long value;
20 const char *name;
23 struct module * load_module(void *mod_image, unsigned long len);
25 /* For every exported symbol, place a struct in the __ksymtab section */
26 #define __EXPORT_SYMBOL(sym, sec) \
27 extern typeof(sym) sym; \
28 static const char __ustrtab_##sym[] \
29 __attribute__((section("__usymtab_strings"))) \
30 = MODULE_SYMBOL_PREFIX #sym; \
31 static const struct kernel_symbol __usymtab_##sym \
32 __used \
33 __attribute__((section("__usymtab" sec), unused)) \
34 = { (unsigned long)&sym, __ustrtab_##sym }
36 #define EXPORT_SYMBOL(sym) \
37 __EXPORT_SYMBOL(sym, "")
39 struct module {
40 /* Unique handle for this module */
41 char name[MODULE_NAME_LEN];
43 /* Startup function. */
44 int (*init)(void);
46 /* Here is the actual code + data, free'd on unload. */
47 void *module_core;
49 /* Arch-specific module values */
50 struct mod_arch_specific arch;
52 unsigned long core_size;
54 struct list_head list;
57 /* Apply the given relocation to the (simplified) ELF. Return -error
58 or 0. */
59 int apply_relocate(Elf_Shdr *sechdrs,
60 const char *strtab,
61 unsigned int symindex,
62 unsigned int relsec,
63 struct module *mod);
65 /* Apply the given add relocation to the (simplified) ELF. Return
66 -error or 0 */
67 int apply_relocate_add(Elf_Shdr *sechdrs,
68 const char *strtab,
69 unsigned int symindex,
70 unsigned int relsec,
71 struct module *mod);
72 #else
73 #define EXPORT_SYMBOL(sym)
74 #endif /* CONFIG_MODULES */
76 extern struct list_head module_list;
78 #define for_each_module(m) \
79 list_for_each_entry(m, &module_list, list)
81 #endif /* __MODULE_H */