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 /* maximum length of symbol name */
  30 #define SYM_MAX_NAME 60
  31 
  32 struct kernel_sym { /* sent to "insmod" */
  33         unsigned long value;            /* value of symbol */
  34         char name[SYM_MAX_NAME];        /* name of symbol */
  35 };
  36 
  37 struct module_ref {
  38         struct module *module;
  39         struct module_ref *next;
  40 };
  41 
  42 struct internal_symbol {
  43         void *addr;
  44         const char *name;
  45         };
  46 
  47 struct symbol_table { /* received from "insmod" */
  48         int size; /* total, including string table!!! */
  49         int n_symbols;
  50         int n_refs;
  51         struct internal_symbol symbol[0]; /* actual size defined by n_symbols */
  52         struct module_ref ref[0]; /* actual size defined by n_refs */
  53 };
  54 /*
  55  * Note: The string table follows immediately after the symbol table in memory!
  56  */
  57 
  58 struct module {
  59         struct module *next;
  60         struct module_ref *ref; /* the list of modules that refer to me */
  61         struct symbol_table *symtab;
  62         const char *name;
  63         int size;                       /* size of module in pages */
  64         void* addr;                     /* address of module */
  65         int state;
  66         void (*cleanup)(void);          /* cleanup routine */
  67 };
  68 
  69 struct mod_routines {
  70         int (*init)(void);              /* initialization routine */
  71         void (*cleanup)(void);          /* cleanup routine */
  72 };
  73 
  74 /* rename_module_symbol(old_name, new_name)  WOW! */
  75 extern int rename_module_symbol(char *, char *);
  76 
  77 /* insert new symbol table */
  78 extern int register_symtab(struct symbol_table *);
  79 
  80 /*
  81  * The first word of the module contains the use count.
  82  */
  83 #define GET_USE_COUNT(module)   (* (long *) (module)->addr)
  84 /*
  85  * define the count variable, and usage macros.
  86  */
  87 
  88 #ifdef MODULE
  89 
  90 extern long mod_use_count_;
  91 #define MOD_INC_USE_COUNT      mod_use_count_++
  92 #define MOD_DEC_USE_COUNT      mod_use_count_--
  93 #define MOD_IN_USE             (mod_use_count_ != 0)
  94 
  95 #ifndef __NO_VERSION__
  96 #include <linux/version.h>
  97 char kernel_version[]=UTS_RELEASE;
  98 #endif
  99 
 100 #if defined(MODVERSIONS) && !defined(__GENKSYMS__)
 101 int Using_Versions; /* gcc will handle this global (used as a flag) correctly */
 102 #endif
 103 
 104 #else
 105 
 106 #define MOD_INC_USE_COUNT       do { } while (0)
 107 #define MOD_DEC_USE_COUNT       do { } while (0)
 108 #define MOD_IN_USE              1
 109 
 110 #endif
 111 
 112 #endif

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