X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Fmodule.h;h=159560d5acb3d00071125e8d105a1e868a463222;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=2709330e8684ce6ee1a65e158dd66b40caab5085;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/include/linux/module.h b/include/linux/module.h index 2709330e8..159560d5a 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -6,8 +6,6 @@ * Rewritten by Richard Henderson Dec 1996 * Rewritten again by Rusty Russell, 2002 */ -#include -#include #include #include #include @@ -44,6 +42,24 @@ struct modversion_info char name[MODULE_NAME_LEN]; }; +struct module; + +struct module_attribute { + struct attribute attr; + ssize_t (*show)(struct module_attribute *, struct module *, char *); + ssize_t (*store)(struct module_attribute *, struct module *, + const char *, size_t count); + void (*setup)(struct module *, const char *); + int (*test)(struct module *); + void (*free)(struct module *); +}; + +struct module_kobject +{ + struct kobject kobj; + struct module *mod; +}; + /* These are either module local, or the kernel's dummy ones. */ extern int init_module(void); extern void cleanup_module(void); @@ -59,25 +75,17 @@ void sort_extable(struct exception_table_entry *start, struct exception_table_entry *finish); void sort_main_extable(void); -#ifdef MODULE -#define ___module_cat(a,b) __mod_ ## a ## b -#define __module_cat(a,b) ___module_cat(a,b) -#define __MODULE_INFO(tag, name, info) \ -static const char __module_cat(name,__LINE__)[] \ - __attribute_used__ \ - __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info +extern struct subsystem module_subsys; +#ifdef MODULE #define MODULE_GENERIC_TABLE(gtype,name) \ extern const struct gtype##_id __mod_##gtype##_table \ __attribute__ ((unused, alias(__stringify(name)))) extern struct module __this_module; #define THIS_MODULE (&__this_module) - #else /* !MODULE */ - #define MODULE_GENERIC_TABLE(gtype,name) -#define __MODULE_INFO(tag, name, info) #define THIS_MODULE ((struct module *)0) #endif @@ -96,6 +104,8 @@ extern struct module __this_module; * "GPL and additional rights" [GNU Public License v2 rights and more] * "Dual BSD/GPL" [GNU Public License v2 * or BSD license choice] + * "Dual MIT/GPL" [GNU Public License v2 + * or MIT license choice] * "Dual MPL/GPL" [GNU Public License v2 * or Mozilla license choice] * @@ -141,11 +151,14 @@ extern struct module __this_module; customizations, eg "rh3" or "rusty1". Using this automatically adds a checksum of the .c files and the - local headers to the end. Use MODULE_VERSION("") if you want just - this. Macro includes room for this. + local headers in "srcversion". */ -#define MODULE_VERSION(_version) \ - MODULE_INFO(version, _version "\0xxxxxxxxxxxxxxxxxxxxxxxx") +#define MODULE_VERSION(_version) MODULE_INFO(version, _version) + +/* Optional firmware file (or files) needed by the module + * format is simply firmware file name. Multiple firmware + * files require multiple MODULE_FIRMWARE() specifiers */ +#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware) /* Given an address, look for it in the exception tables */ const struct exception_table_entry *search_exception_tables(unsigned long add); @@ -175,6 +188,7 @@ void *__symbol_get_gpl(const char *symbol); /* For every exported symbol, place a struct in the __ksymtab section */ #define __EXPORT_SYMBOL(sym, sec) \ + extern typeof(sym) sym; \ __CRC_SYMBOL(sym, sec) \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"))) \ @@ -190,11 +204,19 @@ void *__symbol_get_gpl(const char *symbol); #define EXPORT_SYMBOL_GPL(sym) \ __EXPORT_SYMBOL(sym, "_gpl") +#define EXPORT_SYMBOL_GPL_FUTURE(sym) \ + __EXPORT_SYMBOL(sym, "_gpl_future") + + +#ifdef CONFIG_UNUSED_SYMBOLS +#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") +#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") +#else +#define EXPORT_UNUSED_SYMBOL(sym) +#define EXPORT_UNUSED_SYMBOL_GPL(sym) #endif -/* We don't mangle the actual symbol anymore, so no need for - * special casing EXPORT_SYMBOL_NOVERS. FIXME: Deprecated */ -#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym) +#endif struct module_ref { @@ -208,23 +230,23 @@ enum module_state MODULE_STATE_GOING, }; -/* sysfs stuff */ -struct module_attribute +/* Similar stuff for section attributes. */ +struct module_sect_attr { - struct attribute attr; - struct kernel_param *param; + struct module_attribute mattr; + char *name; + unsigned long address; }; -struct module_kobject +struct module_sect_attrs { - /* Everyone should have one of these. */ - struct kobject kobj; - - /* We always have refcnt, we may have others from module_param(). */ - unsigned int num_attributes; - struct module_attribute attr[0]; + struct attribute_group grp; + int nsections; + struct module_sect_attr attrs[0]; }; +struct module_param_attrs; + struct module { enum module_state state; @@ -236,7 +258,12 @@ struct module char name[MODULE_NAME_LEN]; /* Sysfs stuff. */ - struct module_kobject *mkobj; + struct module_kobject mkobj; + struct module_param_attrs *param_attrs; + struct module_attribute *modinfo_attrs; + const char *version; + const char *srcversion; + struct kobject *drivers_dir; /* Exported symbols */ const struct kernel_symbol *syms; @@ -248,6 +275,20 @@ struct module unsigned int num_gpl_syms; const unsigned long *gpl_crcs; + /* unused exported symbols. */ + const struct kernel_symbol *unused_syms; + unsigned int num_unused_syms; + const unsigned long *unused_crcs; + /* GPL-only, unused exported symbols. */ + const struct kernel_symbol *unused_gpl_syms; + unsigned int num_unused_gpl_syms; + const unsigned long *unused_gpl_crcs; + + /* symbols that will be GPL-only in the near future. */ + const struct kernel_symbol *gpl_future_syms; + unsigned int num_gpl_future_syms; + const unsigned long *gpl_future_crcs; + /* Exception table */ unsigned int num_exentries; const struct exception_table_entry *extable; @@ -267,14 +308,26 @@ struct module /* The size of the executable code in each section. */ unsigned long init_text_size, core_text_size; + /* The handle returned from unwind_add_table. */ + void *unwind_info; + /* Arch-specific module values */ struct mod_arch_specific arch; /* Am I unsafe to unload? */ int unsafe; - /* Am I GPL-compatible */ - int license_gplok; + unsigned int taints; /* same bits as kernel:tainted */ + +#ifdef CONFIG_GENERIC_BUG + /* Support for BUG */ + struct list_head bug_list; + struct bug_entry *bug_table; + unsigned num_bugs; +#endif + + /* Is this module GPG signed */ + int gpgsig_ok; #ifdef CONFIG_MODULE_UNLOAD /* Reference counts */ @@ -288,9 +341,6 @@ struct module /* Destruction function. */ void (*exit)(void); - - /* Fake kernel param for refcnt. */ - struct kernel_param refcnt_param; #endif #ifdef CONFIG_KALLSYMS @@ -298,6 +348,9 @@ struct module Elf_Sym *symtab; unsigned long num_symtab; char *strtab; + + /* Section attributes */ + struct module_sect_attrs *sect_attrs; #endif /* Per-cpu data. */ @@ -316,15 +369,15 @@ static inline int module_is_live(struct module *mod) return mod->state != MODULE_STATE_GOING; } -/* Is this address in a module? */ +/* Is this address in a module? (second is with no locks, for oops) */ struct module *module_text_address(unsigned long addr); +struct module *__module_text_address(unsigned long addr); +int is_module_address(unsigned long addr); /* Returns module and fills in value, defined and namebuf, or NULL if symnum out of range. */ -struct module *module_get_kallsym(unsigned int symnum, - unsigned long *value, - char *type, - char namebuf[128]); +struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, + char *type, char *name, size_t namelen); /* Look for this name: can be of form module:name. */ unsigned long module_kallsyms_lookup_name(const char *name); @@ -367,17 +420,7 @@ static inline int try_module_get(struct module *module) return ret; } -static inline void module_put(struct module *module) -{ - if (module) { - unsigned int cpu = get_cpu(); - local_dec(&module->ref[cpu].count); - /* Maybe they're waiting for us to drop reference? */ - if (unlikely(!module_is_live(module))) - wake_up_process(module->waiter); - put_cpu(); - } -} +extern void module_put(struct module *module); #else /*!CONFIG_MODULE_UNLOAD*/ static inline int try_module_get(struct module *module) @@ -425,10 +468,17 @@ int register_module_notifier(struct notifier_block * nb); int unregister_module_notifier(struct notifier_block * nb); extern void print_modules(void); + +struct device_driver; +void module_add_driver(struct module *, struct device_driver *); +void module_remove_driver(struct device_driver *); + #else /* !CONFIG_MODULES... */ #define EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_GPL(sym) -#define EXPORT_SYMBOL_NOVERS(sym) +#define EXPORT_SYMBOL_GPL_FUTURE(sym) +#define EXPORT_UNUSED_SYMBOL(sym) +#define EXPORT_UNUSED_SYMBOL_GPL(sym) /* Given an address, look for it in the exception tables. */ static inline const struct exception_table_entry * @@ -443,6 +493,17 @@ static inline struct module *module_text_address(unsigned long addr) return NULL; } +/* Is this address in a module? (don't take a lock, we're oopsing) */ +static inline struct module *__module_text_address(unsigned long addr) +{ + return NULL; +} + +static inline int is_module_address(unsigned long addr) +{ + return 0; +} + /* Get/put a kernel symbol (calls should be symmetric) */ #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) #define symbol_put(x) do { } while(0) @@ -476,8 +537,8 @@ static inline const char *module_address_lookup(unsigned long addr, static inline struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, - char *type, - char namebuf[128]) + char *type, char *name, + size_t namelen) { return NULL; } @@ -508,56 +569,24 @@ static inline int unregister_module_notifier(struct notifier_block * nb) static inline void print_modules(void) { } -#endif /* CONFIG_MODULES */ - -#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) - -/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ -struct obsolete_modparm { - char name[64]; - char type[64-sizeof(void *)]; - void *addr; -}; -#ifdef MODULE -/* DEPRECATED: Do not use. */ -#define MODULE_PARM(var,type) \ -struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \ -{ __stringify(var), type }; +struct device_driver; +struct module; -static inline void __deprecated MOD_INC_USE_COUNT(struct module *module) +static inline void module_add_driver(struct module *module, struct device_driver *driver) { - __unsafe(module); - -#if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE) - local_inc(&module->ref[get_cpu()].count); - put_cpu(); -#else - (void)try_module_get(module); -#endif } -static inline void __deprecated MOD_DEC_USE_COUNT(struct module *module) +static inline void module_remove_driver(struct device_driver *driver) { - module_put(module); } -#define MOD_INC_USE_COUNT MOD_INC_USE_COUNT(THIS_MODULE) -#define MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT(THIS_MODULE) -#else -#define MODULE_PARM(var,type) -#define MOD_INC_USE_COUNT do { } while (0) -#define MOD_DEC_USE_COUNT do { } while (0) -#endif +#endif /* CONFIG_MODULES */ -#define __MODULE_STRING(x) __stringify(x) +#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) + +/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ -/* Use symbol_get and symbol_put instead. You'll thank me. */ -#define HAVE_INTER_MODULE -extern void inter_module_register(const char *, struct module *, const void *); -extern void inter_module_unregister(const char *); -extern const void *inter_module_get(const char *); -extern const void *inter_module_get_request(const char *, const char *); -extern void inter_module_put(const char *); +#define __MODULE_STRING(x) __stringify(x) #endif /* _LINUX_MODULE_H */