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

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