| [2] | 1 | #ifndef _LINUX_MODULE_H |
|---|
| 2 | #define _LINUX_MODULE_H |
|---|
| 3 | /* |
|---|
| 4 | * Dynamic loading of modules into the kernel. |
|---|
| 5 | * |
|---|
| 6 | * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 |
|---|
| 7 | * Rewritten again by Rusty Russell, 2002 |
|---|
| 8 | */ |
|---|
| 9 | #include <linux/sched.h> |
|---|
| 10 | #include <linux/cache.h> |
|---|
| 11 | #include <linux/kmod.h> |
|---|
| 12 | #include <linux/stringify.h> |
|---|
| 13 | #include <linux/moduleparam.h> |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | /* Not Yet Implemented */ |
|---|
| 17 | #define MODULE_SUPPORTED_DEVICE(name) |
|---|
| 18 | |
|---|
| 19 | /* v850 toolchain uses a `_' prefix for all user symbols */ |
|---|
| 20 | #ifndef MODULE_SYMBOL_PREFIX |
|---|
| 21 | #define MODULE_SYMBOL_PREFIX "" |
|---|
| 22 | #endif |
|---|
| 23 | |
|---|
| 24 | #define MODULE_NAME_LEN (64 - sizeof(unsigned long)) |
|---|
| 25 | |
|---|
| 26 | struct kernel_symbol |
|---|
| 27 | { |
|---|
| 28 | unsigned long value; |
|---|
| 29 | const char *name; |
|---|
| 30 | }; |
|---|
| 31 | |
|---|
| 32 | struct modversion_info |
|---|
| 33 | { |
|---|
| 34 | unsigned long crc; |
|---|
| 35 | char name[MODULE_NAME_LEN]; |
|---|
| 36 | }; |
|---|
| 37 | |
|---|
| 38 | struct module; |
|---|
| 39 | |
|---|
| 40 | struct module_attribute { |
|---|
| 41 | struct attribute attr; |
|---|
| 42 | ssize_t (*show)(struct module_attribute *, struct module *, char *); |
|---|
| 43 | ssize_t (*store)(struct module_attribute *, struct module *, |
|---|
| 44 | const char *, size_t count); |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | struct module_kobject |
|---|
| 48 | { |
|---|
| 49 | struct kobject kobj; |
|---|
| 50 | struct module *mod; |
|---|
| 51 | }; |
|---|
| 52 | |
|---|
| 53 | /* These are either module local, or the kernel's dummy ones. */ |
|---|
| 54 | extern int init_module(void); |
|---|
| 55 | extern void cleanup_module(void); |
|---|
| 56 | |
|---|
| 57 | /* Archs provide a method of finding the correct exception table. */ |
|---|
| 58 | struct exception_table_entry; |
|---|
| 59 | |
|---|
| 60 | const struct exception_table_entry * |
|---|
| 61 | search_extable(const struct exception_table_entry *first, |
|---|
| 62 | const struct exception_table_entry *last, |
|---|
| 63 | unsigned long value); |
|---|
| 64 | void sort_extable(struct exception_table_entry *start, |
|---|
| 65 | struct exception_table_entry *finish); |
|---|
| 66 | void sort_main_extable(void); |
|---|
| 67 | |
|---|
| 68 | extern struct subsystem module_subsys; |
|---|
| 69 | |
|---|
| 70 | #ifdef MODULE |
|---|
| 71 | #define MODULE_GENERIC_TABLE(gtype,name) \ |
|---|
| 72 | extern const struct gtype##_id __mod_##gtype##_table \ |
|---|
| 73 | __attribute__ ((unused, alias(__stringify(name)))) |
|---|
| 74 | |
|---|
| 75 | extern struct module __this_module; |
|---|
| 76 | #define THIS_MODULE (&__this_module) |
|---|
| 77 | #else /* !MODULE */ |
|---|
| 78 | #define MODULE_GENERIC_TABLE(gtype,name) |
|---|
| 79 | #define THIS_MODULE ((struct module *)0) |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | /* Generic info of form tag = "info" */ |
|---|
| 83 | #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) |
|---|
| 84 | |
|---|
| 85 | /* For userspace: you can also call me... */ |
|---|
| 86 | #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) |
|---|
| 87 | |
|---|
| 88 | /* |
|---|
| 89 | * The following license idents are currently accepted as indicating free |
|---|
| 90 | * software modules |
|---|
| 91 | * |
|---|
| 92 | * "GPL" [GNU Public License v2 or later] |
|---|
| 93 | * "GPL v2" [GNU Public License v2] |
|---|
| 94 | * "GPL and additional rights" [GNU Public License v2 rights and more] |
|---|
| 95 | * "Dual BSD/GPL" [GNU Public License v2 |
|---|
| 96 | * or BSD license choice] |
|---|
| 97 | * "Dual MPL/GPL" [GNU Public License v2 |
|---|
| 98 | * or Mozilla license choice] |
|---|
| 99 | * |
|---|
| 100 | * The following other idents are available |
|---|
| 101 | * |
|---|
| 102 | * "Proprietary" [Non free products] |
|---|
| 103 | * |
|---|
| 104 | * There are dual licensed components, but when running with Linux it is the |
|---|
| 105 | * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL |
|---|
| 106 | * is a GPL combined work. |
|---|
| 107 | * |
|---|
| 108 | * This exists for several reasons |
|---|
| 109 | * 1. So modinfo can show license info for users wanting to vet their setup |
|---|
| 110 | * is free |
|---|
| 111 | * 2. So the community can ignore bug reports including proprietary modules |
|---|
| 112 | * 3. So vendors can do likewise based on their own policies |
|---|
| 113 | */ |
|---|
| 114 | #define MODULE_LICENSE(_license) MODULE_INFO(license, _license) |
|---|
| 115 | |
|---|
| 116 | /* Author, ideally of form NAME <EMAIL>[, NAME <EMAIL>]*[ and NAME <EMAIL>] */ |
|---|
| 117 | #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) |
|---|
| 118 | |
|---|
| 119 | /* What your module does. */ |
|---|
| 120 | #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) |
|---|
| 121 | |
|---|
| 122 | /* One for each parameter, describing how to use it. Some files do |
|---|
| 123 | multiple of these per line, so can't just use MODULE_INFO. */ |
|---|
| 124 | #define MODULE_PARM_DESC(_parm, desc) \ |
|---|
| 125 | __MODULE_INFO(parm, _parm, #_parm ":" desc) |
|---|
| 126 | |
|---|
| 127 | #define MODULE_DEVICE_TABLE(type,name) \ |
|---|
| 128 | MODULE_GENERIC_TABLE(type##_device,name) |
|---|
| 129 | |
|---|
| 130 | /* Version of form [<epoch>:]<version>[-<extra-version>]. |
|---|
| 131 | Or for CVS/RCS ID version, everything but the number is stripped. |
|---|
| 132 | <epoch>: A (small) unsigned integer which allows you to start versions |
|---|
| 133 | anew. If not mentioned, it's zero. eg. "2:1.0" is after |
|---|
| 134 | "1:2.0". |
|---|
| 135 | <version>: The <version> may contain only alphanumerics and the |
|---|
| 136 | character `.'. Ordered by numeric sort for numeric parts, |
|---|
| 137 | ascii sort for ascii parts (as per RPM or DEB algorithm). |
|---|
| 138 | <extraversion>: Like <version>, but inserted for local |
|---|
| 139 | customizations, eg "rh3" or "rusty1". |
|---|
| 140 | |
|---|
| 141 | Using this automatically adds a checksum of the .c files and the |
|---|
| 142 | local headers in "srcversion". |
|---|
| 143 | */ |
|---|
| 144 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) |
|---|
| 145 | |
|---|
| 146 | /* Given an address, look for it in the exception tables */ |
|---|
| 147 | const struct exception_table_entry *search_exception_tables(unsigned long add); |
|---|
| 148 | |
|---|
| 149 | struct notifier_block; |
|---|
| 150 | |
|---|
| 151 | #ifdef CONFIG_MODULES |
|---|
| 152 | |
|---|
| 153 | /* Get/put a kernel symbol (calls must be symmetric) */ |
|---|
| 154 | void *__symbol_get(const char *symbol); |
|---|
| 155 | void *__symbol_get_gpl(const char *symbol); |
|---|
| 156 | #define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) |
|---|
| 157 | |
|---|
| 158 | #ifndef __GENKSYMS__ |
|---|
| 159 | #ifdef CONFIG_MODVERSIONS |
|---|
| 160 | /* Mark the CRC weak since genksyms apparently decides not to |
|---|
| 161 | * generate a checksums for some symbols */ |
|---|
| 162 | #define __CRC_SYMBOL(sym, sec) \ |
|---|
| 163 | extern void *__crc_##sym __attribute__((weak)); \ |
|---|
| 164 | static const unsigned long __kcrctab_##sym \ |
|---|
| 165 | __attribute__((section("__kcrctab" sec), unused)) \ |
|---|
| 166 | = (unsigned long) &__crc_##sym; |
|---|
| 167 | #else |
|---|
| 168 | #define __CRC_SYMBOL(sym, sec) |
|---|
| 169 | #endif |
|---|
| 170 | |
|---|
| 171 | /* For every exported symbol, place a struct in the __ksymtab section */ |
|---|
| 172 | #define __EXPORT_SYMBOL(sym, sec) \ |
|---|
| 173 | __CRC_SYMBOL(sym, sec) \ |
|---|
| 174 | static const char __kstrtab_##sym[] \ |
|---|
| 175 | __attribute__((section("__ksymtab_strings"))) \ |
|---|
| 176 | = MODULE_SYMBOL_PREFIX #sym; \ |
|---|
| 177 | static const struct kernel_symbol __ksymtab_##sym \ |
|---|
| 178 | __attribute__((section("__ksymtab" sec), unused)) \ |
|---|
| 179 | = { (unsigned long)&sym, __kstrtab_##sym } |
|---|
| 180 | |
|---|
| 181 | #define EXPORT_SYMBOL(sym) \ |
|---|
| 182 | __EXPORT_SYMBOL(sym, "") |
|---|
| 183 | |
|---|
| 184 | #define EXPORT_SYMBOL_GPL(sym) \ |
|---|
| 185 | __EXPORT_SYMBOL(sym, "_gpl") |
|---|
| 186 | |
|---|
| 187 | #endif |
|---|
| 188 | |
|---|
| 189 | struct module_ref |
|---|
| 190 | { |
|---|
| 191 | local_t count; |
|---|
| 192 | } ____cacheline_aligned; |
|---|
| 193 | |
|---|
| 194 | enum module_state |
|---|
| 195 | { |
|---|
| 196 | MODULE_STATE_LIVE, |
|---|
| 197 | MODULE_STATE_COMING, |
|---|
| 198 | MODULE_STATE_GOING, |
|---|
| 199 | }; |
|---|
| 200 | |
|---|
| 201 | /* Similar stuff for section attributes. */ |
|---|
| 202 | #define MODULE_SECT_NAME_LEN 32 |
|---|
| 203 | struct module_sect_attr |
|---|
| 204 | { |
|---|
| 205 | struct module_attribute mattr; |
|---|
| 206 | char name[MODULE_SECT_NAME_LEN]; |
|---|
| 207 | unsigned long address; |
|---|
| 208 | }; |
|---|
| 209 | |
|---|
| 210 | struct module_sect_attrs |
|---|
| 211 | { |
|---|
| 212 | struct attribute_group grp; |
|---|
| 213 | struct module_sect_attr attrs[0]; |
|---|
| 214 | }; |
|---|
| 215 | |
|---|
| 216 | struct module_param_attrs; |
|---|
| 217 | |
|---|
| 218 | struct module |
|---|
| 219 | { |
|---|
| 220 | enum module_state state; |
|---|
| 221 | |
|---|
| 222 | /* Member of list of modules */ |
|---|
| 223 | struct list_head list; |
|---|
| 224 | |
|---|
| 225 | /* Unique handle for this module */ |
|---|
| 226 | char name[MODULE_NAME_LEN]; |
|---|
| 227 | |
|---|
| 228 | /* Sysfs stuff. */ |
|---|
| 229 | struct module_kobject mkobj; |
|---|
| 230 | struct module_param_attrs *param_attrs; |
|---|
| 231 | |
|---|
| 232 | /* Exported symbols */ |
|---|
| 233 | const struct kernel_symbol *syms; |
|---|
| 234 | unsigned int num_syms; |
|---|
| 235 | const unsigned long *crcs; |
|---|
| 236 | |
|---|
| 237 | /* GPL-only exported symbols. */ |
|---|
| 238 | const struct kernel_symbol *gpl_syms; |
|---|
| 239 | unsigned int num_gpl_syms; |
|---|
| 240 | const unsigned long *gpl_crcs; |
|---|
| 241 | |
|---|
| 242 | /* Exception table */ |
|---|
| 243 | unsigned int num_exentries; |
|---|
| 244 | const struct exception_table_entry *extable; |
|---|
| 245 | |
|---|
| 246 | /* Startup function. */ |
|---|
| 247 | int (*init)(void); |
|---|
| 248 | |
|---|
| 249 | /* If this is non-NULL, vfree after init() returns */ |
|---|
| 250 | void *module_init; |
|---|
| 251 | |
|---|
| 252 | /* Here is the actual code + data, vfree'd on unload. */ |
|---|
| 253 | void *module_core; |
|---|
| 254 | |
|---|
| 255 | /* Here are the sizes of the init and core sections */ |
|---|
| 256 | unsigned long init_size, core_size; |
|---|
| 257 | |
|---|
| 258 | /* The size of the executable code in each section. */ |
|---|
| 259 | unsigned long init_text_size, core_text_size; |
|---|
| 260 | |
|---|
| 261 | /* Arch-specific module values */ |
|---|
| 262 | struct mod_arch_specific arch; |
|---|
| 263 | |
|---|
| 264 | /* Am I unsafe to unload? */ |
|---|
| 265 | int unsafe; |
|---|
| 266 | |
|---|
| 267 | /* Am I GPL-compatible */ |
|---|
| 268 | int license_gplok; |
|---|
| 269 | |
|---|
| 270 | #ifdef CONFIG_MODULE_UNLOAD |
|---|
| 271 | /* Reference counts */ |
|---|
| 272 | struct module_ref ref[NR_CPUS]; |
|---|
| 273 | |
|---|
| 274 | /* What modules depend on me? */ |
|---|
| 275 | struct list_head modules_which_use_me; |
|---|
| 276 | |
|---|
| 277 | /* Who is waiting for us to be unloaded */ |
|---|
| 278 | struct task_struct *waiter; |
|---|
| 279 | |
|---|
| 280 | /* Destruction function. */ |
|---|
| 281 | void (*exit)(void); |
|---|
| 282 | #endif |
|---|
| 283 | |
|---|
| 284 | #ifdef CONFIG_KALLSYMS |
|---|
| 285 | /* We keep the symbol and string tables for kallsyms. */ |
|---|
| 286 | Elf_Sym *symtab; |
|---|
| 287 | unsigned long num_symtab; |
|---|
| 288 | char *strtab; |
|---|
| 289 | |
|---|
| 290 | /* Section attributes */ |
|---|
| 291 | struct module_sect_attrs *sect_attrs; |
|---|
| 292 | #endif |
|---|
| 293 | |
|---|
| 294 | /* Per-cpu data. */ |
|---|
| 295 | void *percpu; |
|---|
| 296 | |
|---|
| 297 | /* The command line arguments (may be mangled). People like |
|---|
| 298 | keeping pointers to this stuff */ |
|---|
| 299 | char *args; |
|---|
| 300 | }; |
|---|
| 301 | |
|---|
| 302 | /* FIXME: It'd be nice to isolate modules during init, too, so they |
|---|
| 303 | aren't used before they (may) fail. But presently too much code |
|---|
| 304 | (IDE & SCSI) require entry into the module during init.*/ |
|---|
| 305 | static inline int module_is_live(struct module *mod) |
|---|
| 306 | { |
|---|
| 307 | return mod->state != MODULE_STATE_GOING; |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | /* Is this address in a module? (second is with no locks, for oops) */ |
|---|
| 311 | struct module *module_text_address(unsigned long addr); |
|---|
| 312 | struct module *__module_text_address(unsigned long addr); |
|---|
| 313 | |
|---|
| 314 | /* Returns module and fills in value, defined and namebuf, or NULL if |
|---|
| 315 | symnum out of range. */ |
|---|
| 316 | struct module *module_get_kallsym(unsigned int symnum, |
|---|
| 317 | unsigned long *value, |
|---|
| 318 | char *type, |
|---|
| 319 | char namebuf[128]); |
|---|
| 320 | |
|---|
| 321 | /* Look for this name: can be of form module:name. */ |
|---|
| 322 | unsigned long module_kallsyms_lookup_name(const char *name); |
|---|
| 323 | |
|---|
| 324 | int is_exported(const char *name, const struct module *mod); |
|---|
| 325 | |
|---|
| 326 | extern void __module_put_and_exit(struct module *mod, long code) |
|---|
| 327 | __attribute__((noreturn)); |
|---|
| 328 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); |
|---|
| 329 | |
|---|
| 330 | #ifdef CONFIG_MODULE_UNLOAD |
|---|
| 331 | unsigned int module_refcount(struct module *mod); |
|---|
| 332 | void __symbol_put(const char *symbol); |
|---|
| 333 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) |
|---|
| 334 | void symbol_put_addr(void *addr); |
|---|
| 335 | |
|---|
| 336 | /* Sometimes we know we already have a refcount, and it's easier not |
|---|
| 337 | to handle the error case (which only happens with rmmod --wait). */ |
|---|
| 338 | static inline void __module_get(struct module *module) |
|---|
| 339 | { |
|---|
| 340 | if (module) { |
|---|
| 341 | BUG_ON(module_refcount(module) == 0); |
|---|
| 342 | local_inc(&module->ref[get_cpu()].count); |
|---|
| 343 | put_cpu(); |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | static inline int try_module_get(struct module *module) |
|---|
| 348 | { |
|---|
| 349 | int ret = 1; |
|---|
| 350 | |
|---|
| 351 | if (module) { |
|---|
| 352 | unsigned int cpu = get_cpu(); |
|---|
| 353 | if (likely(module_is_live(module))) |
|---|
| 354 | local_inc(&module->ref[cpu].count); |
|---|
| 355 | else |
|---|
| 356 | ret = 0; |
|---|
| 357 | put_cpu(); |
|---|
| 358 | } |
|---|
| 359 | return ret; |
|---|
| 360 | } |
|---|
| 361 | |
|---|
| 362 | static inline void module_put(struct module *module) |
|---|
| 363 | { |
|---|
| 364 | if (module) { |
|---|
| 365 | unsigned int cpu = get_cpu(); |
|---|
| 366 | local_dec(&module->ref[cpu].count); |
|---|
| 367 | /* Maybe they're waiting for us to drop reference? */ |
|---|
| 368 | if (unlikely(!module_is_live(module))) |
|---|
| 369 | wake_up_process(module->waiter); |
|---|
| 370 | put_cpu(); |
|---|
| 371 | } |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | #else /*!CONFIG_MODULE_UNLOAD*/ |
|---|
| 375 | static inline int try_module_get(struct module *module) |
|---|
| 376 | { |
|---|
| 377 | return !module || module_is_live(module); |
|---|
| 378 | } |
|---|
| 379 | static inline void module_put(struct module *module) |
|---|
| 380 | { |
|---|
| 381 | } |
|---|
| 382 | static inline void __module_get(struct module *module) |
|---|
| 383 | { |
|---|
| 384 | } |
|---|
| 385 | #define symbol_put(x) do { } while(0) |
|---|
| 386 | #define symbol_put_addr(p) do { } while(0) |
|---|
| 387 | |
|---|
| 388 | #endif /* CONFIG_MODULE_UNLOAD */ |
|---|
| 389 | |
|---|
| 390 | /* This is a #define so the string doesn't get put in every .o file */ |
|---|
| 391 | #define module_name(mod) \ |
|---|
| 392 | ({ \ |
|---|
| 393 | struct module *__mod = (mod); \ |
|---|
| 394 | __mod ? __mod->name : "kernel"; \ |
|---|
| 395 | }) |
|---|
| 396 | |
|---|
| 397 | #define __unsafe(mod) \ |
|---|
| 398 | do { \ |
|---|
| 399 | if (mod && !(mod)->unsafe) { \ |
|---|
| 400 | printk(KERN_WARNING \ |
|---|
| 401 | "Module %s cannot be unloaded due to unsafe usage in" \ |
|---|
| 402 | " %s:%u\n", (mod)->name, __FILE__, __LINE__); \ |
|---|
| 403 | (mod)->unsafe = 1; \ |
|---|
| 404 | } \ |
|---|
| 405 | } while(0) |
|---|
| 406 | |
|---|
| 407 | /* For kallsyms to ask for address resolution. NULL means not found. */ |
|---|
| 408 | const char *module_address_lookup(unsigned long addr, |
|---|
| 409 | unsigned long *symbolsize, |
|---|
| 410 | unsigned long *offset, |
|---|
| 411 | char **modname); |
|---|
| 412 | |
|---|
| 413 | /* For extable.c to search modules' exception tables. */ |
|---|
| 414 | const struct exception_table_entry *search_module_extables(unsigned long addr); |
|---|
| 415 | |
|---|
| 416 | int register_module_notifier(struct notifier_block * nb); |
|---|
| 417 | int unregister_module_notifier(struct notifier_block * nb); |
|---|
| 418 | |
|---|
| 419 | extern void print_modules(void); |
|---|
| 420 | |
|---|
| 421 | struct device_driver; |
|---|
| 422 | void module_add_driver(struct module *, struct device_driver *); |
|---|
| 423 | void module_remove_driver(struct device_driver *); |
|---|
| 424 | |
|---|
| 425 | #else /* !CONFIG_MODULES... */ |
|---|
| 426 | #define EXPORT_SYMBOL(sym) |
|---|
| 427 | #define EXPORT_SYMBOL_GPL(sym) |
|---|
| 428 | |
|---|
| 429 | /* Given an address, look for it in the exception tables. */ |
|---|
| 430 | static inline const struct exception_table_entry * |
|---|
| 431 | search_module_extables(unsigned long addr) |
|---|
| 432 | { |
|---|
| 433 | return NULL; |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | /* Is this address in a module? */ |
|---|
| 437 | static inline struct module *module_text_address(unsigned long addr) |
|---|
| 438 | { |
|---|
| 439 | return NULL; |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | /* Is this address in a module? (don't take a lock, we're oopsing) */ |
|---|
| 443 | static inline struct module *__module_text_address(unsigned long addr) |
|---|
| 444 | { |
|---|
| 445 | return NULL; |
|---|
| 446 | } |
|---|
| 447 | |
|---|
| 448 | /* Get/put a kernel symbol (calls should be symmetric) */ |
|---|
| 449 | #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) |
|---|
| 450 | #define symbol_put(x) do { } while(0) |
|---|
| 451 | #define symbol_put_addr(x) do { } while(0) |
|---|
| 452 | |
|---|
| 453 | static inline void __module_get(struct module *module) |
|---|
| 454 | { |
|---|
| 455 | } |
|---|
| 456 | |
|---|
| 457 | static inline int try_module_get(struct module *module) |
|---|
| 458 | { |
|---|
| 459 | return 1; |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | static inline void module_put(struct module *module) |
|---|
| 463 | { |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | #define module_name(mod) "kernel" |
|---|
| 467 | |
|---|
| 468 | #define __unsafe(mod) |
|---|
| 469 | |
|---|
| 470 | /* For kallsyms to ask for address resolution. NULL means not found. */ |
|---|
| 471 | static inline const char *module_address_lookup(unsigned long addr, |
|---|
| 472 | unsigned long *symbolsize, |
|---|
| 473 | unsigned long *offset, |
|---|
| 474 | char **modname) |
|---|
| 475 | { |
|---|
| 476 | return NULL; |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | static inline struct module *module_get_kallsym(unsigned int symnum, |
|---|
| 480 | unsigned long *value, |
|---|
| 481 | char *type, |
|---|
| 482 | char namebuf[128]) |
|---|
| 483 | { |
|---|
| 484 | return NULL; |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | static inline unsigned long module_kallsyms_lookup_name(const char *name) |
|---|
| 488 | { |
|---|
| 489 | return 0; |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | static inline int is_exported(const char *name, const struct module *mod) |
|---|
| 493 | { |
|---|
| 494 | return 0; |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | static inline int register_module_notifier(struct notifier_block * nb) |
|---|
| 498 | { |
|---|
| 499 | /* no events will happen anyway, so this can always succeed */ |
|---|
| 500 | return 0; |
|---|
| 501 | } |
|---|
| 502 | |
|---|
| 503 | static inline int unregister_module_notifier(struct notifier_block * nb) |
|---|
| 504 | { |
|---|
| 505 | return 0; |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | #define module_put_and_exit(code) do_exit(code) |
|---|
| 509 | |
|---|
| 510 | static inline void print_modules(void) |
|---|
| 511 | { |
|---|
| 512 | } |
|---|
| 513 | |
|---|
| 514 | struct device_driver; |
|---|
| 515 | struct module; |
|---|
| 516 | |
|---|
| 517 | static inline void module_add_driver(struct module *module, struct device_driver *driver) |
|---|
| 518 | { |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | static inline void module_remove_driver(struct device_driver *driver) |
|---|
| 522 | { |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | #endif /* CONFIG_MODULES */ |
|---|
| 526 | |
|---|
| 527 | #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) |
|---|
| 528 | |
|---|
| 529 | /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ |
|---|
| 530 | |
|---|
| 531 | struct obsolete_modparm { |
|---|
| 532 | char name[64]; |
|---|
| 533 | char type[64-sizeof(void *)]; |
|---|
| 534 | void *addr; |
|---|
| 535 | }; |
|---|
| 536 | #ifdef MODULE |
|---|
| 537 | /* DEPRECATED: Do not use. */ |
|---|
| 538 | #define MODULE_PARM(var,type) \ |
|---|
| 539 | struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \ |
|---|
| 540 | { __stringify(var), type }; |
|---|
| 541 | |
|---|
| 542 | static inline void MOD_INC_USE_COUNT(struct module *module) |
|---|
| 543 | { |
|---|
| 544 | __unsafe(module); |
|---|
| 545 | |
|---|
| 546 | #if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE) |
|---|
| 547 | local_inc(&module->ref[get_cpu()].count); |
|---|
| 548 | put_cpu(); |
|---|
| 549 | #else |
|---|
| 550 | (void)try_module_get(module); |
|---|
| 551 | #endif |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | static inline void MOD_DEC_USE_COUNT(struct module *module) |
|---|
| 555 | { |
|---|
| 556 | module_put(module); |
|---|
| 557 | } |
|---|
| 558 | |
|---|
| 559 | #define MOD_INC_USE_COUNT MOD_INC_USE_COUNT(THIS_MODULE) |
|---|
| 560 | #define MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT(THIS_MODULE) |
|---|
| 561 | #else |
|---|
| 562 | #define MODULE_PARM(var,type) |
|---|
| 563 | #define MOD_INC_USE_COUNT do { } while (0) |
|---|
| 564 | #define MOD_DEC_USE_COUNT do { } while (0) |
|---|
| 565 | #endif |
|---|
| 566 | |
|---|
| 567 | #define __MODULE_STRING(x) __stringify(x) |
|---|
| 568 | |
|---|
| 569 | /* Use symbol_get and symbol_put instead. You'll thank me. */ |
|---|
| 570 | #define HAVE_INTER_MODULE |
|---|
| 571 | extern void inter_module_register(const char *, struct module *, const void *); |
|---|
| 572 | extern void inter_module_unregister(const char *); |
|---|
| 573 | extern const void *inter_module_get(const char *); |
|---|
| 574 | extern const void *inter_module_get_request(const char *, const char *); |
|---|
| 575 | extern void inter_module_put(const char *); |
|---|
| 576 | |
|---|
| 577 | #endif /* _LINUX_MODULE_H */ |
|---|