module.h
来自「linux 内核源代码」· C头文件 代码 · 共 632 行 · 第 1/2 页
H
632 行
#ifdef CONFIG_GENERIC_BUG /* Support for BUG */ struct list_head bug_list; struct bug_entry *bug_table; unsigned num_bugs;#endif#ifdef CONFIG_MODULE_UNLOAD /* Reference counts */ struct module_ref ref[NR_CPUS]; /* What modules depend on me? */ struct list_head modules_which_use_me; /* Who is waiting for us to be unloaded */ struct task_struct *waiter; /* Destruction function. */ void (*exit)(void);#endif#ifdef CONFIG_KALLSYMS /* We keep the symbol and string tables for kallsyms. */ Elf_Sym *symtab; unsigned long num_symtab; char *strtab; /* Section attributes */ struct module_sect_attrs *sect_attrs; /* Notes attributes */ struct module_notes_attrs *notes_attrs;#endif /* Per-cpu data. */ void *percpu; /* The command line arguments (may be mangled). People like keeping pointers to this stuff */ char *args;#ifdef CONFIG_MARKERS struct marker *markers; unsigned int num_markers;#endif};#ifndef MODULE_ARCH_INIT#define MODULE_ARCH_INIT {}#endif/* FIXME: It'd be nice to isolate modules during init, too, so they aren't used before they (may) fail. But presently too much code (IDE & SCSI) require entry into the module during init.*/static inline int module_is_live(struct module *mod){ return mod->state != MODULE_STATE_GOING;}/* 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 0 and fills in value, defined and namebuf, or -ERANGE if symnum out of range. */int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported);/* Look for this name: can be of form module:name. */unsigned long module_kallsyms_lookup_name(const char *name);extern void __module_put_and_exit(struct module *mod, long code) __attribute__((noreturn));#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);#ifdef CONFIG_MODULE_UNLOADunsigned int module_refcount(struct module *mod);void __symbol_put(const char *symbol);#define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)void symbol_put_addr(void *addr);/* Sometimes we know we already have a refcount, and it's easier not to handle the error case (which only happens with rmmod --wait). */static inline void __module_get(struct module *module){ if (module) { BUG_ON(module_refcount(module) == 0); local_inc(&module->ref[get_cpu()].count); put_cpu(); }}static inline int try_module_get(struct module *module){ int ret = 1; if (module) { unsigned int cpu = get_cpu(); if (likely(module_is_live(module))) local_inc(&module->ref[cpu].count); else ret = 0; put_cpu(); } return ret;}extern void module_put(struct module *module);#else /*!CONFIG_MODULE_UNLOAD*/static inline int try_module_get(struct module *module){ return !module || module_is_live(module);}static inline void module_put(struct module *module){}static inline void __module_get(struct module *module){}#define symbol_put(x) do { } while(0)#define symbol_put_addr(p) do { } while(0)#endif /* CONFIG_MODULE_UNLOAD *//* This is a #define so the string doesn't get put in every .o file */#define module_name(mod) \({ \ struct module *__mod = (mod); \ __mod ? __mod->name : "kernel"; \})/* For kallsyms to ask for address resolution. NULL means not found. */const char *module_address_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname);int lookup_module_symbol_name(unsigned long addr, char *symname);int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);/* For extable.c to search modules' exception tables. */const struct exception_table_entry *search_module_extables(unsigned long addr);int register_module_notifier(struct notifier_block * nb);int unregister_module_notifier(struct notifier_block * nb);extern void print_modules(void);extern void module_update_markers(struct module *probe_module, int *refcount);#else /* !CONFIG_MODULES... */#define EXPORT_SYMBOL(sym)#define EXPORT_SYMBOL_GPL(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 *search_module_extables(unsigned long addr){ return NULL;}/* Is this address in a module? */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)#define symbol_put_addr(x) do { } while(0)static inline void __module_get(struct module *module){}static inline int try_module_get(struct module *module){ return 1;}static inline void module_put(struct module *module){}#define module_name(mod) "kernel"/* For kallsyms to ask for address resolution. NULL means not found. */static inline const char *module_address_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname){ return NULL;}static inline int lookup_module_symbol_name(unsigned long addr, char *symname){ return -ERANGE;}static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name){ return -ERANGE;}static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported){ return -ERANGE;}static inline unsigned long module_kallsyms_lookup_name(const char *name){ return 0;}static inline int register_module_notifier(struct notifier_block * nb){ /* no events will happen anyway, so this can always succeed */ return 0;}static inline int unregister_module_notifier(struct notifier_block * nb){ return 0;}#define module_put_and_exit(code) do_exit(code)static inline void print_modules(void){}static inline void module_update_markers(struct module *probe_module, int *refcount){}#endif /* CONFIG_MODULES */struct device_driver;#ifdef CONFIG_SYSFSstruct module;extern struct kset module_subsys;int mod_sysfs_init(struct module *mod);int mod_sysfs_setup(struct module *mod, struct kernel_param *kparam, unsigned int num_params);int module_add_modinfo_attrs(struct module *mod);void module_remove_modinfo_attrs(struct module *mod);#else /* !CONFIG_SYSFS */static inline int mod_sysfs_init(struct module *mod){ return 0;}static inline int mod_sysfs_setup(struct module *mod, struct kernel_param *kparam, unsigned int num_params){ return 0;}static inline int module_add_modinfo_attrs(struct module *mod){ return 0;}static inline void module_remove_modinfo_attrs(struct module *mod){ }#endif /* CONFIG_SYSFS */#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)void module_add_driver(struct module *mod, struct device_driver *drv);void module_remove_driver(struct device_driver *drv);#else /* not both CONFIG_SYSFS && CONFIG_MODULES */static inline void module_add_driver(struct module *mod, struct device_driver *drv){ }static inline void module_remove_driver(struct device_driver *drv){ }#endif#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */#define __MODULE_STRING(x) __stringify(x)#endif /* _LINUX_MODULE_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?