Blame view
include/linux/module.h
22.1 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 |
#ifndef _LINUX_MODULE_H #define _LINUX_MODULE_H /* * Dynamic loading of modules into the kernel. * * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 * Rewritten again by Rusty Russell, 2002 */ |
1da177e4c Linux-2.6.12-rc2 |
9 10 11 12 13 |
#include <linux/list.h> #include <linux/stat.h> #include <linux/compiler.h> #include <linux/cache.h> #include <linux/kmod.h> |
0fd972a7d module: relocate ... |
14 |
#include <linux/init.h> |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 18 |
#include <linux/elf.h> #include <linux/stringify.h> #include <linux/kobject.h> #include <linux/moduleparam.h> |
b2e285fcb tracing/module: R... |
19 |
#include <linux/jump_label.h> |
f50169324 module.h: split o... |
20 |
#include <linux/export.h> |
93c2e105f module: Optimize ... |
21 |
#include <linux/rbtree_latch.h> |
1da177e4c Linux-2.6.12-rc2 |
22 |
|
e1783a240 module: Use this_... |
23 |
#include <linux/percpu.h> |
1da177e4c Linux-2.6.12-rc2 |
24 |
#include <asm/module.h> |
106a4ee25 module: signature... |
25 26 27 |
/* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */ #define MODULE_SIG_STRING "~Module signature appended~ " |
1da177e4c Linux-2.6.12-rc2 |
28 29 |
/* Not Yet Implemented */ #define MODULE_SUPPORTED_DEVICE(name) |
730b69d22 module: check ker... |
30 |
#define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN |
1da177e4c Linux-2.6.12-rc2 |
31 |
|
e865d06b1 module: fix codin... |
32 |
struct modversion_info { |
1da177e4c Linux-2.6.12-rc2 |
33 34 35 36 37 |
unsigned long crc; char name[MODULE_NAME_LEN]; }; struct module; |
0ef765379 exceptions: fork ... |
38 |
struct exception_table_entry; |
1da177e4c Linux-2.6.12-rc2 |
39 |
|
4befb026c module: change at... |
40 41 42 43 44 |
struct module_kobject { struct kobject kobj; struct module *mod; struct kobject *drivers_dir; struct module_param_attrs *mp; |
942e44312 module: Fix mod->... |
45 |
struct completion *kobj_completion; |
3859a271a randstruct: Mark ... |
46 |
} __randomize_layout; |
4befb026c module: change at... |
47 |
|
1da177e4c Linux-2.6.12-rc2 |
48 |
struct module_attribute { |
4befb026c module: change at... |
49 50 51 52 |
struct attribute attr; ssize_t (*show)(struct module_attribute *, struct module_kobject *, char *); ssize_t (*store)(struct module_attribute *, struct module_kobject *, |
1da177e4c Linux-2.6.12-rc2 |
53 |
const char *, size_t count); |
c988d2b28 [PATCH] modules: ... |
54 55 56 |
void (*setup)(struct module *, const char *); int (*test)(struct module *); void (*free)(struct module *); |
1da177e4c Linux-2.6.12-rc2 |
57 |
}; |
e94965ed5 module: show vers... |
58 59 60 61 |
struct module_version_attribute { struct module_attribute mattr; const char *module_name; const char *version; |
98562ad8c module: explicitl... |
62 |
} __attribute__ ((__aligned__(sizeof(void *)))); |
e94965ed5 module: show vers... |
63 |
|
9b73a5840 module: do not hi... |
64 |
extern ssize_t __modver_version_show(struct module_attribute *, |
4befb026c module: change at... |
65 |
struct module_kobject *, char *); |
9b73a5840 module: do not hi... |
66 |
|
88bfa3247 module: add /sys/... |
67 |
extern struct module_attribute module_uevent; |
1da177e4c Linux-2.6.12-rc2 |
68 69 70 71 |
/* These are either module local, or the kernel's dummy ones. */ extern int init_module(void); extern void cleanup_module(void); |
0fd972a7d module: relocate ... |
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
#ifndef MODULE /** * module_init() - driver initialization entry point * @x: function to be run at kernel boot time or module insertion * * module_init() will either be called during do_initcalls() (if * builtin) or at module insertion time (if a module). There can only * be one per module. */ #define module_init(x) __initcall(x); /** * module_exit() - driver exit entry point * @x: function to be run when driver is removed * * module_exit() will wrap the driver clean-up code * with cleanup_module() when used with rmmod when * the driver is a module. If the driver is statically * compiled into the kernel, module_exit() has no effect. * There can only be one per module. */ #define module_exit(x) __exitcall(x); #else /* MODULE */ /* * In most cases loadable modules do not need custom * initcall levels. There are still some valid cases where * a driver may be needed early if built in, and does not * matter when built as a loadable module. Like bus * snooping debug drivers. */ #define early_initcall(fn) module_init(fn) #define core_initcall(fn) module_init(fn) #define core_initcall_sync(fn) module_init(fn) #define postcore_initcall(fn) module_init(fn) #define postcore_initcall_sync(fn) module_init(fn) #define arch_initcall(fn) module_init(fn) #define subsys_initcall(fn) module_init(fn) #define subsys_initcall_sync(fn) module_init(fn) #define fs_initcall(fn) module_init(fn) #define fs_initcall_sync(fn) module_init(fn) #define rootfs_initcall(fn) module_init(fn) #define device_initcall(fn) module_init(fn) #define device_initcall_sync(fn) module_init(fn) #define late_initcall(fn) module_init(fn) #define late_initcall_sync(fn) module_init(fn) #define console_initcall(fn) module_init(fn) #define security_initcall(fn) module_init(fn) /* Each module must use one module_init(). */ #define module_init(initfn) \ |
1f318a8ba modules: mark __i... |
125 |
static inline initcall_t __maybe_unused __inittest(void) \ |
0fd972a7d module: relocate ... |
126 127 128 129 130 |
{ return initfn; } \ int init_module(void) __attribute__((alias(#initfn))); /* This is only required if you want to be unloadable. */ #define module_exit(exitfn) \ |
1f318a8ba modules: mark __i... |
131 |
static inline exitcall_t __maybe_unused __exittest(void) \ |
0fd972a7d module: relocate ... |
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
{ return exitfn; } \ void cleanup_module(void) __attribute__((alias(#exitfn))); #endif /* This means "can be init if no module support, otherwise module load may call it." */ #ifdef CONFIG_MODULES #define __init_or_module #define __initdata_or_module #define __initconst_or_module #define __INIT_OR_MODULE .text #define __INITDATA_OR_MODULE .data #define __INITRODATA_OR_MODULE .section ".rodata","a",%progbits #else #define __init_or_module __init #define __initdata_or_module __initdata #define __initconst_or_module __initconst #define __INIT_OR_MODULE __INIT #define __INITDATA_OR_MODULE __INITDATA #define __INITRODATA_OR_MODULE __INITRODATA #endif /*CONFIG_MODULES*/ |
1da177e4c Linux-2.6.12-rc2 |
154 155 156 157 158 |
/* Generic info of form tag = "info" */ #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) /* For userspace: you can also call me... */ #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) |
7cb14ba75 modules: add supp... |
159 160 161 162 |
/* Soft module dependencies. See man modprobe.d for details. * Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz") */ #define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep) |
1da177e4c Linux-2.6.12-rc2 |
163 164 165 166 167 168 169 170 171 |
/* * The following license idents are currently accepted as indicating free * software modules * * "GPL" [GNU Public License v2 or later] * "GPL v2" [GNU Public License v2] * "GPL and additional rights" [GNU Public License v2 rights and more] * "Dual BSD/GPL" [GNU Public License v2 * or BSD license choice] |
8d27e9084 [PATCH] module.h:... |
172 173 |
* "Dual MIT/GPL" [GNU Public License v2 * or MIT license choice] |
1da177e4c Linux-2.6.12-rc2 |
174 175 176 177 178 179 180 181 182 183 184 185 |
* "Dual MPL/GPL" [GNU Public License v2 * or Mozilla license choice] * * The following other idents are available * * "Proprietary" [Non free products] * * There are dual licensed components, but when running with Linux it is the * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL * is a GPL combined work. * * This exists for several reasons |
e865d06b1 module: fix codin... |
186 |
* 1. So modinfo can show license info for users wanting to vet their setup |
1da177e4c Linux-2.6.12-rc2 |
187 188 189 190 191 |
* is free * 2. So the community can ignore bug reports including proprietary modules * 3. So vendors can do likewise based on their own policies */ #define MODULE_LICENSE(_license) MODULE_INFO(license, _license) |
1d7015caa module: preferred... |
192 193 194 195 |
/* * Author(s), use "Name <email>" or just "Name", for multiple * authors use multiple MODULE_AUTHOR() statements/lines. */ |
1da177e4c Linux-2.6.12-rc2 |
196 |
#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) |
e865d06b1 module: fix codin... |
197 |
|
1da177e4c Linux-2.6.12-rc2 |
198 199 |
/* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) |
cff26a51d module: remove MO... |
200 201 202 |
#ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ |
0bf8bf50e module: Remove co... |
203 |
extern typeof(name) __mod_##type##__##name##_device_table \ |
cff26a51d module: remove MO... |
204 205 206 207 |
__attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) #endif |
1da177e4c Linux-2.6.12-rc2 |
208 209 |
/* Version of form [<epoch>:]<version>[-<extra-version>]. |
e865d06b1 module: fix codin... |
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
* Or for CVS/RCS ID version, everything but the number is stripped. * <epoch>: A (small) unsigned integer which allows you to start versions * anew. If not mentioned, it's zero. eg. "2:1.0" is after * "1:2.0". * <version>: The <version> may contain only alphanumerics and the * character `.'. Ordered by numeric sort for numeric parts, * ascii sort for ascii parts (as per RPM or DEB algorithm). * <extraversion>: Like <version>, but inserted for local * customizations, eg "rh3" or "rusty1". * Using this automatically adds a checksum of the .c files and the * local headers in "srcversion". */ |
e94965ed5 module: show vers... |
225 |
|
3b90a5b29 module: fix linke... |
226 |
#if defined(MODULE) || !defined(CONFIG_SYSFS) |
1da177e4c Linux-2.6.12-rc2 |
227 |
#define MODULE_VERSION(_version) MODULE_INFO(version, _version) |
e94965ed5 module: show vers... |
228 229 |
#else #define MODULE_VERSION(_version) \ |
b4bc84280 module: deal with... |
230 |
static struct module_version_attribute ___modver_attr = { \ |
e94965ed5 module: show vers... |
231 232 233 234 235 236 237 238 239 |
.mattr = { \ .attr = { \ .name = "version", \ .mode = S_IRUGO, \ }, \ .show = __modver_version_show, \ }, \ .module_name = KBUILD_MODNAME, \ .version = _version, \ |
b4bc84280 module: deal with... |
240 241 242 243 |
}; \ static const struct module_version_attribute \ __used __attribute__ ((__section__ ("__modver"))) \ * __moduleparam_const __modver_attr = &___modver_attr |
e94965ed5 module: show vers... |
244 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
245 |
|
187afbed1 [SCSI] MODULE_FIR... |
246 247 248 249 |
/* 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) |
1da177e4c Linux-2.6.12-rc2 |
250 251 252 |
struct notifier_block; #ifdef CONFIG_MODULES |
5ed109103 sysctl extern cle... |
253 |
extern int modules_disabled; /* for sysctl */ |
1da177e4c Linux-2.6.12-rc2 |
254 255 256 |
/* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get(const char *symbol); void *__symbol_get_gpl(const char *symbol); |
b92021b09 CONFIG_SYMBOL_PRE... |
257 |
#define symbol_get(x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x)))) |
1da177e4c Linux-2.6.12-rc2 |
258 |
|
c8e21ced0 module: fix kdb's... |
259 260 261 262 263 264 |
/* modules using other modules: kdb wants to see this. */ struct module_use { struct list_head source_list; struct list_head target_list; struct module *source, *target; }; |
0d21b0e34 module: add new s... |
265 266 267 268 269 |
enum module_state { MODULE_STATE_LIVE, /* Normal state. */ MODULE_STATE_COMING, /* Full formed, running module_init. */ MODULE_STATE_GOING, /* Going away. */ MODULE_STATE_UNFORMED, /* Still setting it up. */ |
1da177e4c Linux-2.6.12-rc2 |
270 |
}; |
93c2e105f module: Optimize ... |
271 272 273 274 |
struct mod_tree_node { struct module *mod; struct latch_tree_node node; }; |
7523e4dc5 module: use a str... |
275 276 277 278 279 280 281 282 283 |
struct module_layout { /* The actual code + data. */ void *base; /* Total size. */ unsigned int size; /* The size of the executable code. */ unsigned int text_size; /* Size of RO section of the module (text+rodata) */ unsigned int ro_size; |
444d13ff1 modules: add ro_a... |
284 285 |
/* Size of RO after init section */ unsigned int ro_after_init_size; |
7523e4dc5 module: use a str... |
286 287 288 289 290 291 292 293 294 295 296 297 |
#ifdef CONFIG_MODULES_TREE_LOOKUP struct mod_tree_node mtn; #endif }; #ifdef CONFIG_MODULES_TREE_LOOKUP /* Only touch one cacheline for common rbtree-for-core-layout case. */ #define __module_layout_align ____cacheline_aligned #else #define __module_layout_align #endif |
8244062ef modules: fix long... |
298 299 300 301 302 |
struct mod_kallsyms { Elf_Sym *symtab; unsigned int num_symtab; char *strtab; }; |
1ce15ef4f module: preserve ... |
303 304 305 306 307 308 309 310 |
#ifdef CONFIG_LIVEPATCH struct klp_modinfo { Elf_Ehdr hdr; Elf_Shdr *sechdrs; char *secstrings; unsigned int symndx; }; #endif |
e865d06b1 module: fix codin... |
311 |
struct module { |
1da177e4c Linux-2.6.12-rc2 |
312 313 314 315 316 317 318 319 320 321 |
enum module_state state; /* Member of list of modules */ struct list_head list; /* Unique handle for this module */ char name[MODULE_NAME_LEN]; /* Sysfs stuff. */ struct module_kobject mkobj; |
03e88ae1b [PATCH] fix modul... |
322 |
struct module_attribute *modinfo_attrs; |
c988d2b28 [PATCH] modules: ... |
323 324 |
const char *version; const char *srcversion; |
270a6c4ca /sys/modules/*/ho... |
325 |
struct kobject *holders_dir; |
1da177e4c Linux-2.6.12-rc2 |
326 327 328 |
/* Exported symbols */ const struct kernel_symbol *syms; |
71810db27 modversions: trea... |
329 |
const s32 *crcs; |
af5406895 module: reorder s... |
330 |
unsigned int num_syms; |
1da177e4c Linux-2.6.12-rc2 |
331 |
|
e180a6b77 param: fix charp ... |
332 |
/* Kernel parameters. */ |
cf2fde7b3 param: fix module... |
333 |
#ifdef CONFIG_SYSFS |
b51d23e4e module: add per-m... |
334 |
struct mutex param_lock; |
cf2fde7b3 param: fix module... |
335 |
#endif |
e180a6b77 param: fix charp ... |
336 337 |
struct kernel_param *kp; unsigned int num_kp; |
1da177e4c Linux-2.6.12-rc2 |
338 |
/* GPL-only exported symbols. */ |
1da177e4c Linux-2.6.12-rc2 |
339 |
unsigned int num_gpl_syms; |
af5406895 module: reorder s... |
340 |
const struct kernel_symbol *gpl_syms; |
71810db27 modversions: trea... |
341 |
const s32 *gpl_crcs; |
1da177e4c Linux-2.6.12-rc2 |
342 |
|
f7f5b6755 Shrink struct mod... |
343 |
#ifdef CONFIG_UNUSED_SYMBOLS |
f71d20e96 [PATCH] Add EXPOR... |
344 345 |
/* unused exported symbols. */ const struct kernel_symbol *unused_syms; |
71810db27 modversions: trea... |
346 |
const s32 *unused_crcs; |
af5406895 module: reorder s... |
347 |
unsigned int num_unused_syms; |
f71d20e96 [PATCH] Add EXPOR... |
348 |
/* GPL-only, unused exported symbols. */ |
f71d20e96 [PATCH] Add EXPOR... |
349 |
unsigned int num_unused_gpl_syms; |
af5406895 module: reorder s... |
350 |
const struct kernel_symbol *unused_gpl_syms; |
71810db27 modversions: trea... |
351 |
const s32 *unused_gpl_crcs; |
f7f5b6755 Shrink struct mod... |
352 |
#endif |
f71d20e96 [PATCH] Add EXPOR... |
353 |
|
106a4ee25 module: signature... |
354 355 356 357 |
#ifdef CONFIG_MODULE_SIG /* Signature was verified. */ bool sig_ok; #endif |
f2411da74 driver-core: add ... |
358 |
bool async_probe_requested; |
9f28bb7e1 [PATCH] add EXPOR... |
359 360 |
/* symbols that will be GPL-only in the near future. */ const struct kernel_symbol *gpl_future_syms; |
71810db27 modversions: trea... |
361 |
const s32 *gpl_future_crcs; |
af5406895 module: reorder s... |
362 |
unsigned int num_gpl_future_syms; |
9f28bb7e1 [PATCH] add EXPOR... |
363 |
|
1da177e4c Linux-2.6.12-rc2 |
364 365 |
/* Exception table */ unsigned int num_exentries; |
5e458cc0f module: simplify ... |
366 |
struct exception_table_entry *extable; |
1da177e4c Linux-2.6.12-rc2 |
367 368 369 |
/* Startup function. */ int (*init)(void); |
7523e4dc5 module: use a str... |
370 371 372 |
/* Core layout: rbtree is accessed frequently, so keep together. */ struct module_layout core_layout __module_layout_align; struct module_layout init_layout; |
84e1c6bb3 x86: Add RO/NX pr... |
373 |
|
1da177e4c Linux-2.6.12-rc2 |
374 375 |
/* Arch-specific module values */ struct mod_arch_specific arch; |
7fd8329ba taint/module: Cle... |
376 |
unsigned long taints; /* same bits as kernel:taint_flags */ |
2bc2d61a9 [PATCH] list modu... |
377 |
|
7664c5a1d [PATCH] Generic B... |
378 379 |
#ifdef CONFIG_GENERIC_BUG /* Support for BUG */ |
af5406895 module: reorder s... |
380 |
unsigned num_bugs; |
7664c5a1d [PATCH] Generic B... |
381 382 |
struct list_head bug_list; struct bug_entry *bug_table; |
1da177e4c Linux-2.6.12-rc2 |
383 384 385 |
#endif #ifdef CONFIG_KALLSYMS |
8244062ef modules: fix long... |
386 387 388 |
/* Protected by RCU and/or module_mutex: use rcu_dereference() */ struct mod_kallsyms *kallsyms; struct mod_kallsyms core_kallsyms; |
c714965f5 module: remove tr... |
389 |
|
1da177e4c Linux-2.6.12-rc2 |
390 391 |
/* Section attributes */ struct module_sect_attrs *sect_attrs; |
6d7601338 Add /sys/module/n... |
392 393 394 |
/* Notes attributes */ struct module_notes_attrs *notes_attrs; |
1da177e4c Linux-2.6.12-rc2 |
395 |
#endif |
a288bd651 module: remove 64... |
396 397 398 |
/* The command line arguments (may be mangled). People like keeping pointers to this stuff */ char *args; |
259354dea module: encapsula... |
399 |
#ifdef CONFIG_SMP |
1da177e4c Linux-2.6.12-rc2 |
400 |
/* Per-cpu data. */ |
259354dea module: encapsula... |
401 402 403 |
void __percpu *percpu; unsigned int percpu_size; #endif |
1da177e4c Linux-2.6.12-rc2 |
404 |
|
97e1c18e8 tracing: Kernel T... |
405 |
#ifdef CONFIG_TRACEPOINTS |
97e1c18e8 tracing: Kernel T... |
406 |
unsigned int num_tracepoints; |
a288bd651 module: remove 64... |
407 |
struct tracepoint * const *tracepoints_ptrs; |
97e1c18e8 tracing: Kernel T... |
408 |
#endif |
bf5438fca jump label: Base ... |
409 410 411 412 |
#ifdef HAVE_JUMP_LABEL struct jump_entry *jump_entries; unsigned int num_jump_entries; #endif |
769b0441f tracing/core: dro... |
413 |
#ifdef CONFIG_TRACING |
1ba28e02a tracing: add trac... |
414 |
unsigned int num_trace_bprintk_fmt; |
a288bd651 module: remove 64... |
415 |
const char **trace_bprintk_fmt_start; |
1ba28e02a tracing: add trac... |
416 |
#endif |
6d723736e tracing/events: a... |
417 |
#ifdef CONFIG_EVENT_TRACING |
2425bcb92 tracing: Rename f... |
418 |
struct trace_event_call **trace_events; |
6d723736e tracing/events: a... |
419 |
unsigned int num_trace_events; |
99be647c5 trace: rename str... |
420 421 |
struct trace_eval_map **trace_evals; unsigned int num_trace_evals; |
6d723736e tracing/events: a... |
422 |
#endif |
93eb677d7 ftrace: use modul... |
423 |
#ifdef CONFIG_FTRACE_MCOUNT_RECORD |
93eb677d7 ftrace: use modul... |
424 |
unsigned int num_ftrace_callsites; |
a288bd651 module: remove 64... |
425 |
unsigned long *ftrace_callsites; |
93eb677d7 ftrace: use modul... |
426 |
#endif |
1ba28e02a tracing: add trac... |
427 |
|
8cb2c2dc4 livepatch: Fix su... |
428 |
#ifdef CONFIG_LIVEPATCH |
1ce15ef4f module: preserve ... |
429 |
bool klp; /* Is this a livepatch module? */ |
8cb2c2dc4 livepatch: Fix su... |
430 |
bool klp_alive; |
1ce15ef4f module: preserve ... |
431 432 433 |
/* Elf information */ struct klp_modinfo *klp_info; |
8cb2c2dc4 livepatch: Fix su... |
434 |
#endif |
af5406895 module: reorder s... |
435 436 |
#ifdef CONFIG_MODULE_UNLOAD /* What modules depend on me? */ |
2c02dfe7f module: Make the ... |
437 438 439 |
struct list_head source_list; /* What modules do I depend on? */ struct list_head target_list; |
af5406895 module: reorder s... |
440 |
|
af5406895 module: reorder s... |
441 442 |
/* Destruction function. */ void (*exit)(void); |
2f35c41f5 module: Replace m... |
443 |
atomic_t refcnt; |
af5406895 module: reorder s... |
444 |
#endif |
b99b87f70 kernel: construct... |
445 446 447 448 449 450 |
#ifdef CONFIG_CONSTRUCTORS /* Constructor functions. */ ctor_fn_t *ctors; unsigned int num_ctors; #endif |
3859a271a randstruct: Mark ... |
451 |
} ____cacheline_aligned __randomize_layout; |
e61a1c1c4 Allow arch to ini... |
452 453 454 |
#ifndef MODULE_ARCH_INIT #define MODULE_ARCH_INIT {} #endif |
1da177e4c Linux-2.6.12-rc2 |
455 |
|
c6b378019 module: Export sy... |
456 |
extern struct mutex module_mutex; |
1da177e4c Linux-2.6.12-rc2 |
457 458 459 460 461 462 463 |
/* 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; } |
1da177e4c Linux-2.6.12-rc2 |
464 |
struct module *__module_text_address(unsigned long addr); |
e610499e2 module: __module_... |
465 466 |
struct module *__module_address(unsigned long addr); bool is_module_address(unsigned long addr); |
383776fa7 locking/lockdep: ... |
467 |
bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr); |
10fad5e46 percpu, module: i... |
468 |
bool is_module_percpu_address(unsigned long addr); |
e610499e2 module: __module_... |
469 |
bool is_module_text_address(unsigned long addr); |
1da177e4c Linux-2.6.12-rc2 |
470 |
|
76681c8fa module: return bo... |
471 472 |
static inline bool within_module_core(unsigned long addr, const struct module *mod) |
a06f6211e module: add withi... |
473 |
{ |
7523e4dc5 module: use a str... |
474 475 |
return (unsigned long)mod->core_layout.base <= addr && addr < (unsigned long)mod->core_layout.base + mod->core_layout.size; |
a06f6211e module: add withi... |
476 |
} |
76681c8fa module: return bo... |
477 478 |
static inline bool within_module_init(unsigned long addr, const struct module *mod) |
a06f6211e module: add withi... |
479 |
{ |
7523e4dc5 module: use a str... |
480 481 |
return (unsigned long)mod->init_layout.base <= addr && addr < (unsigned long)mod->init_layout.base + mod->init_layout.size; |
a06f6211e module: add withi... |
482 |
} |
76681c8fa module: return bo... |
483 |
static inline bool within_module(unsigned long addr, const struct module *mod) |
9b20a352d module: add withi... |
484 485 486 |
{ return within_module_init(addr, mod) || within_module_core(addr, mod); } |
c6b378019 module: Export sy... |
487 488 489 490 491 |
/* Search for module by name: must hold module_mutex. */ struct module *find_module(const char *name); struct symsearch { const struct kernel_symbol *start, *stop; |
71810db27 modversions: trea... |
492 |
const s32 *crcs; |
c6b378019 module: Export sy... |
493 494 495 496 497 498 499 |
enum { NOT_GPL_ONLY, GPL_ONLY, WILL_BE_GPL_ONLY, } licence; bool unused; }; |
0be964be0 module: Sanitize ... |
500 501 502 503 504 |
/* * Search for an exported symbol by name. * * Must be called with module_mutex held or preemption disabled. */ |
c6b378019 module: Export sy... |
505 506 |
const struct kernel_symbol *find_symbol(const char *name, struct module **owner, |
71810db27 modversions: trea... |
507 |
const s32 **crc, |
c6b378019 module: Export sy... |
508 509 |
bool gplok, bool warn); |
0be964be0 module: Sanitize ... |
510 511 512 513 514 |
/* * Walk the exported symbol table * * Must be called with module_mutex held or preemption disabled. */ |
de4d8d534 module: each_symb... |
515 516 517 |
bool each_symbol_section(bool (*fn)(const struct symsearch *arr, struct module *owner, void *data), void *data); |
c6b378019 module: Export sy... |
518 |
|
ea07890a6 Fix race between ... |
519 |
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if |
1da177e4c Linux-2.6.12-rc2 |
520 |
symnum out of range. */ |
ea07890a6 Fix race between ... |
521 522 |
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported); |
1da177e4c Linux-2.6.12-rc2 |
523 524 525 |
/* Look for this name: can be of form module:name. */ unsigned long module_kallsyms_lookup_name(const char *name); |
75a66614d Ksplice: Add func... |
526 527 528 |
int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data); |
bf262dcec module: fix noret... |
529 530 |
extern void __noreturn __module_put_and_exit(struct module *mod, long code); |
74e22fac8 module.h: Remove ... |
531 |
#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code) |
1da177e4c Linux-2.6.12-rc2 |
532 533 |
#ifdef CONFIG_MODULE_UNLOAD |
d5db139ab module: make modu... |
534 |
int module_refcount(struct module *mod); |
1da177e4c Linux-2.6.12-rc2 |
535 |
void __symbol_put(const char *symbol); |
b92021b09 CONFIG_SYMBOL_PRE... |
536 |
#define symbol_put(x) __symbol_put(VMLINUX_SYMBOL_STR(x)) |
1da177e4c Linux-2.6.12-rc2 |
537 538 539 540 |
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). */ |
d53799be6 module: move __mo... |
541 |
extern void __module_get(struct module *module); |
e1783a240 module: Use this_... |
542 |
|
d53799be6 module: move __mo... |
543 544 545 |
/* This is the Right Way to get a module: if it fails, it's being removed, * so pretend it's not there. */ extern bool try_module_get(struct module *module); |
1da177e4c Linux-2.6.12-rc2 |
546 |
|
f6a570333 [PATCH] severing ... |
547 |
extern void module_put(struct module *module); |
1da177e4c Linux-2.6.12-rc2 |
548 549 |
#else /*!CONFIG_MODULE_UNLOAD*/ |
8ba4fcdf0 module: Unify the... |
550 |
static inline bool try_module_get(struct module *module) |
1da177e4c Linux-2.6.12-rc2 |
551 552 553 554 555 556 557 558 559 |
{ return !module || module_is_live(module); } static inline void module_put(struct module *module) { } static inline void __module_get(struct module *module) { } |
e865d06b1 module: fix codin... |
560 561 |
#define symbol_put(x) do { } while (0) #define symbol_put_addr(p) do { } while (0) |
1da177e4c Linux-2.6.12-rc2 |
562 563 |
#endif /* CONFIG_MODULE_UNLOAD */ |
dfd62d1d8 module: Update pr... |
564 |
int ref_module(struct module *a, struct module *b); |
1da177e4c Linux-2.6.12-rc2 |
565 566 567 568 569 570 571 |
/* 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"; \ }) |
6dd06c9fb module: make modu... |
572 573 574 |
/* For kallsyms to ask for address resolution. namebuf should be at * least KSYM_NAME_LEN long: a pointer to namebuf is returned if * found, otherwise NULL. */ |
92dfc9dc7 fix "modules: mak... |
575 |
const char *module_address_lookup(unsigned long addr, |
6dd06c9fb module: make modu... |
576 577 578 579 |
unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf); |
9d65cb4a1 Fix race between ... |
580 |
int lookup_module_symbol_name(unsigned long addr, char *symname); |
a5c43dae7 Fix race between ... |
581 |
int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); |
1da177e4c Linux-2.6.12-rc2 |
582 |
|
e865d06b1 module: fix codin... |
583 584 |
int register_module_notifier(struct notifier_block *nb); int unregister_module_notifier(struct notifier_block *nb); |
1da177e4c Linux-2.6.12-rc2 |
585 586 |
extern void print_modules(void); |
80c6e1465 driver-core: fix ... |
587 588 589 590 |
static inline bool module_requested_async_probing(struct module *module) { return module && module->async_probe_requested; } |
1ce15ef4f module: preserve ... |
591 592 593 594 595 596 597 598 599 600 601 |
#ifdef CONFIG_LIVEPATCH static inline bool is_livepatch_module(struct module *mod) { return mod->klp; } #else /* !CONFIG_LIVEPATCH */ static inline bool is_livepatch_module(struct module *mod) { return false; } #endif /* CONFIG_LIVEPATCH */ |
1da177e4c Linux-2.6.12-rc2 |
602 |
#else /* !CONFIG_MODULES... */ |
1da177e4c Linux-2.6.12-rc2 |
603 |
|
e610499e2 module: __module_... |
604 605 606 607 |
static inline struct module *__module_address(unsigned long addr) { return NULL; } |
1da177e4c Linux-2.6.12-rc2 |
608 609 610 611 |
static inline struct module *__module_text_address(unsigned long addr) { return NULL; } |
e610499e2 module: __module_... |
612 613 614 615 |
static inline bool is_module_address(unsigned long addr) { return false; } |
d5e50daf9 module: add stub ... |
616 617 618 619 |
static inline bool is_module_percpu_address(unsigned long addr) { return false; } |
383776fa7 locking/lockdep: ... |
620 621 622 623 |
static inline bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr) { return false; } |
e610499e2 module: __module_... |
624 |
static inline bool is_module_text_address(unsigned long addr) |
4d435f9d8 [PATCH] lockdep: ... |
625 |
{ |
e610499e2 module: __module_... |
626 |
return false; |
4d435f9d8 [PATCH] lockdep: ... |
627 |
} |
1da177e4c Linux-2.6.12-rc2 |
628 629 |
/* Get/put a kernel symbol (calls should be symmetric) */ #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) |
e865d06b1 module: fix codin... |
630 631 |
#define symbol_put(x) do { } while (0) #define symbol_put_addr(x) do { } while (0) |
1da177e4c Linux-2.6.12-rc2 |
632 633 634 635 |
static inline void __module_get(struct module *module) { } |
8ba4fcdf0 module: Unify the... |
636 |
static inline bool try_module_get(struct module *module) |
1da177e4c Linux-2.6.12-rc2 |
637 |
{ |
8ba4fcdf0 module: Unify the... |
638 |
return true; |
1da177e4c Linux-2.6.12-rc2 |
639 640 641 642 643 644 645 |
} static inline void module_put(struct module *module) { } #define module_name(mod) "kernel" |
1da177e4c Linux-2.6.12-rc2 |
646 |
/* For kallsyms to ask for address resolution. NULL means not found. */ |
92dfc9dc7 fix "modules: mak... |
647 |
static inline const char *module_address_lookup(unsigned long addr, |
6dd06c9fb module: make modu... |
648 649 650 651 |
unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf) |
1da177e4c Linux-2.6.12-rc2 |
652 653 654 |
{ return NULL; } |
9d65cb4a1 Fix race between ... |
655 656 657 658 |
static inline int lookup_module_symbol_name(unsigned long addr, char *symname) { return -ERANGE; } |
a5c43dae7 Fix race between ... |
659 660 661 662 |
static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name) { return -ERANGE; } |
ea07890a6 Fix race between ... |
663 664 665 |
static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported) |
1da177e4c Linux-2.6.12-rc2 |
666 |
{ |
ea07890a6 Fix race between ... |
667 |
return -ERANGE; |
1da177e4c Linux-2.6.12-rc2 |
668 669 670 671 672 673 |
} static inline unsigned long module_kallsyms_lookup_name(const char *name) { return 0; } |
75a66614d Ksplice: Add func... |
674 675 676 677 678 679 680 |
static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data) { return 0; } |
e865d06b1 module: fix codin... |
681 |
static inline int register_module_notifier(struct notifier_block *nb) |
1da177e4c Linux-2.6.12-rc2 |
682 683 684 685 |
{ /* no events will happen anyway, so this can always succeed */ return 0; } |
e865d06b1 module: fix codin... |
686 |
static inline int unregister_module_notifier(struct notifier_block *nb) |
1da177e4c Linux-2.6.12-rc2 |
687 688 689 690 691 692 693 694 695 |
{ return 0; } #define module_put_and_exit(code) do_exit(code) static inline void print_modules(void) { } |
80c6e1465 driver-core: fix ... |
696 697 698 699 700 |
static inline bool module_requested_async_probing(struct module *module) { return false; } |
ef665c1a0 sysfs: fix build ... |
701 |
#endif /* CONFIG_MODULES */ |
ef665c1a0 sysfs: fix build ... |
702 |
#ifdef CONFIG_SYSFS |
7405c1e15 kset: convert /sy... |
703 704 705 |
extern struct kset *module_kset; extern struct kobj_type module_ktype; extern int module_sysfs_initialized; |
ef665c1a0 sysfs: fix build ... |
706 |
#endif /* CONFIG_SYSFS */ |
1da177e4c Linux-2.6.12-rc2 |
707 708 709 |
#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ |
1da177e4c Linux-2.6.12-rc2 |
710 |
#define __MODULE_STRING(x) __stringify(x) |
0f5bf6d0a arch: Rename CONF... |
711 |
#ifdef CONFIG_STRICT_MODULE_RWX |
84e1c6bb3 x86: Add RO/NX pr... |
712 713 |
extern void set_all_modules_text_rw(void); extern void set_all_modules_text_ro(void); |
444d13ff1 modules: add ro_a... |
714 |
extern void module_enable_ro(const struct module *mod, bool after_init); |
85c898db6 module: clean up ... |
715 |
extern void module_disable_ro(const struct module *mod); |
84e1c6bb3 x86: Add RO/NX pr... |
716 717 718 |
#else static inline void set_all_modules_text_rw(void) { } static inline void set_all_modules_text_ro(void) { } |
444d13ff1 modules: add ro_a... |
719 |
static inline void module_enable_ro(const struct module *mod, bool after_init) { } |
85c898db6 module: clean up ... |
720 |
static inline void module_disable_ro(const struct module *mod) { } |
84e1c6bb3 x86: Add RO/NX pr... |
721 |
#endif |
0d9c25dde headers: move mod... |
722 723 |
#ifdef CONFIG_GENERIC_BUG |
5336377d6 modules: Fix modu... |
724 |
void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, |
0d9c25dde headers: move mod... |
725 726 727 728 |
struct module *); void module_bug_cleanup(struct module *); #else /* !CONFIG_GENERIC_BUG */ |
5336377d6 modules: Fix modu... |
729 |
static inline void module_bug_finalize(const Elf_Ehdr *hdr, |
0d9c25dde headers: move mod... |
730 731 732 |
const Elf_Shdr *sechdrs, struct module *mod) { |
0d9c25dde headers: move mod... |
733 734 735 |
} static inline void module_bug_cleanup(struct module *mod) {} #endif /* CONFIG_GENERIC_BUG */ |
64ac5483a x86, modpost: Rep... |
736 |
#ifdef CONFIG_RETPOLINE |
86b5b1eb1 module/retpoline:... |
737 738 739 740 741 742 743 |
extern bool retpoline_module_ok(bool has_retpoline); #else static inline bool retpoline_module_ok(bool has_retpoline) { return true; } #endif |
59afdc7b3 crypto: api - Mov... |
744 745 746 747 748 749 750 751 752 753 754 |
#ifdef CONFIG_MODULE_SIG static inline bool module_sig_ok(struct module *module) { return module->sig_ok; } #else /* !CONFIG_MODULE_SIG */ static inline bool module_sig_ok(struct module *module) { return true; } #endif /* CONFIG_MODULE_SIG */ |
1da177e4c Linux-2.6.12-rc2 |
755 |
#endif /* _LINUX_MODULE_H */ |