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

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