root/include/linux/module.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Dynamic loading of modules into the kernel.
   3  *
   4  * Modified by Bjorn Ekwall <bj0rn@blox.se>
   5  */
   6 
   7 #ifndef _LINUX_MODULE_H
   8 #define _LINUX_MODULE_H
   9 
  10 #ifdef __GENKSYMS__
  11 #  define _set_ver(sym,vers) sym
  12 #  undef  MODVERSIONS
  13 #  define MODVERSIONS
  14 #else /* ! __GENKSYMS__ */
  15 # if defined(MODVERSIONS) && !defined(MODULE) && defined(EXPORT_SYMTAB)
  16 #   define _set_ver(sym,vers) sym
  17 #   include <linux/modversions.h>
  18 # endif
  19 #endif /* __GENKSYMS__ */
  20 
  21 /* values of module.state */
  22 #define MOD_UNINITIALIZED 0
  23 #define MOD_RUNNING 1
  24 #define MOD_DELETED 2
  25 
  26 /* maximum length of module name */
  27 #define MOD_MAX_NAME 64
  28 
  29 /* magic marker for modules inserted from kerneld, to be auto-reaped */
  30 #define MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
  31 
  32 /* maximum length of symbol name */
  33 #define SYM_MAX_NAME 60
  34 
  35 struct kernel_sym { /* sent to "insmod" */
  36         unsigned long value;            /* value of symbol */
  37         char name[SYM_MAX_NAME];        /* name of symbol */
  38 };
  39 
  40 struct module_ref {
  41         struct module *module;
  42         struct module_ref *next;
  43 };
  44 
  45 struct internal_symbol {
  46         void *addr;
  47         const char *name;
  48         };
  49 
  50 struct symbol_table { /* received from "insmod" */
  51         int size; /* total, including string table!!! */
  52         int n_symbols;
  53         int n_refs;
  54         struct internal_symbol symbol[0]; /* actual size defined by n_symbols */
  55         struct module_ref ref[0]; /* actual size defined by n_refs */
  56 };
  57 /*
  58  * Note: The string table follows immediately after the symbol table in memory!
  59  */
  60 
  61 struct module {
  62         struct module *next;
  63         struct module_ref *ref; /* the list of modules that refer to me */
  64         struct symbol_table *symtab;
  65         const char *name;
  66         int size;                       /* size of module in pages */
  67         void* addr;                     /* address of module */
  68         int state;
  69         void (*cleanup)(void);          /* cleanup routine */
  70 };
  71 
  72 struct mod_routines {
  73         int (*init)(void);              /* initialization routine */
  74         void (*cleanup)(void);          /* cleanup routine */
  75 };
  76 
  77 /* rename_module_symbol(old_name, new_name)  WOW! */
  78 extern int rename_module_symbol(char *, char *);
  79 
  80 /* insert new symbol table */
  81 extern int register_symtab(struct symbol_table *);
  82 
  83 /*
  84  * The first word of the module contains the use count.
  85  */
  86 #define GET_USE_COUNT(module)   (* (long *) (module)->addr)
  87 /*
  88  * define the count variable, and usage macros.
  89  */
  90 
  91 #ifdef MODULE
  92 
  93 extern long mod_use_count_;
  94 #define MOD_INC_USE_COUNT      mod_use_count_++
  95 #define MOD_DEC_USE_COUNT      mod_use_count_--
  96 #define MOD_IN_USE             ((mod_use_count_ & ~MOD_AUTOCLEAN) != 0)
  97 
  98 #ifndef __NO_VERSION__
  99 #include <linux/version.h>
 100 char kernel_version[]=UTS_RELEASE;
 101 #endif
 102 
 103 #if defined(MODVERSIONS) && !defined(__GENKSYMS__)
 104 int Using_Versions; /* gcc will handle this global (used as a flag) correctly */
 105 #endif
 106 
 107 #else
 108 
 109 #define MOD_INC_USE_COUNT       do { } while (0)
 110 #define MOD_DEC_USE_COUNT       do { } while (0)
 111 #define MOD_IN_USE              1
 112 
 113 #endif
 114 
 115 #endif

/* [previous][next][first][last][top][bottom][index][help] */