00001
00002
00003
00004
00005
00006
00007 #ifndef _LINUX_MODULE_H
00008 #define _LINUX_MODULE_H
00009
00010 #include <linux/config.h>
00011
00012 #ifdef __GENKSYMS__
00013 # define _set_ver(sym) sym
00014 # undef MODVERSIONS
00015 # define MODVERSIONS
00016 #else
00017 # if !defined(MODVERSIONS) && defined(EXPORT_SYMTAB)
00018 # define _set_ver(sym) sym
00019 # include <linux/modversions.h>
00020 # endif
00021 #endif
00022
00023 #include <asm/atomic.h>
00024
00025
00026 struct exception_table_entry;
00027
00028
00029 struct kernel_sym
00030 {
00031 unsigned long value;
00032 char name[60];
00033 };
00034
00035 struct module_symbol
00036 {
00037 unsigned long value;
00038 const char *name;
00039 };
00040
00041 struct module_ref
00042 {
00043 struct module *dep;
00044 struct module *ref;
00045 struct module_ref *next_ref;
00046 };
00047
00048
00049 struct module_persist;
00050
00051 struct module
00052 {
00053 unsigned long size_of_struct;
00054 struct module *next;
00055 const char *name;
00056 unsigned long size;
00057
00058 union
00059 {
00060 atomic_t usecount;
00061 long pad;
00062 } uc;
00063
00064 unsigned long flags;
00065
00066 unsigned nsyms;
00067 unsigned ndeps;
00068
00069 struct module_symbol *syms;
00070 struct module_ref *deps;
00071 struct module_ref *refs;
00072 int (*init)(void);
00073 void (*cleanup)(void);
00074 const struct exception_table_entry *ex_table_start;
00075 const struct exception_table_entry *ex_table_end;
00076 #ifdef __alpha__
00077 unsigned long gp;
00078 #endif
00079
00080
00081
00082 const struct module_persist *persist_start;
00083 const struct module_persist *persist_end;
00084 int (*can_unload)(void);
00085 };
00086
00087 struct module_info
00088 {
00089 unsigned long addr;
00090 unsigned long size;
00091 unsigned long flags;
00092 long usecount;
00093 };
00094
00095
00096
00097 #define MOD_UNINITIALIZED 0
00098 #define MOD_RUNNING 1
00099 #define MOD_DELETED 2
00100 #define MOD_AUTOCLEAN 4
00101 #define MOD_VISITED 8
00102 #define MOD_USED_ONCE 16
00103 #define MOD_JUST_FREED 32
00104 #define MOD_INITIALIZING 64
00105
00106
00107
00108 #define QM_MODULES 1
00109 #define QM_DEPS 2
00110 #define QM_REFS 3
00111 #define QM_SYMBOLS 4
00112 #define QM_INFO 5
00113
00114
00115 #define MOD_CAN_QUERY(mod) (((mod)->flags & (MOD_RUNNING | MOD_INITIALIZING)) && !((mod)->flags & MOD_DELETED))
00116
00117
00118
00119
00120
00121 #define mod_member_present(mod,member) \
00122 ((unsigned long)(&((struct module *)0L)->member + 1) \
00123 <= (mod)->size_of_struct)
00124
00125
00126
00127 #define GET_USE_COUNT(module) (atomic_read(&(module)->uc.usecount))
00128
00129
00130
00131 #define __MOD_INC_USE_COUNT(mod) \
00132 (atomic_inc(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED|MOD_USED_ONCE)
00133 #define __MOD_DEC_USE_COUNT(mod) \
00134 (atomic_dec(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED)
00135 #define __MOD_IN_USE(mod) \
00136 (mod_member_present((mod), can_unload) && (mod)->can_unload \
00137 ? (mod)->can_unload() : atomic_read(&(mod)->uc.usecount))
00138
00139 extern int try_inc_mod_count(struct module *mod);
00140
00141
00142 #define __MODULE_STRING_1(x) #x
00143 #define __MODULE_STRING(x) __MODULE_STRING_1(x)
00144
00145
00146 #ifndef CONFIG_MODULES
00147 static inline unsigned long get_module_symbol(char *A, char *B) { return 0; };
00148 #else
00149 extern unsigned long get_module_symbol(char *, char *);
00150 #endif
00151 #if defined(MODULE) && !defined(__GENKSYMS__)
00152
00153
00154
00155
00156
00157 #define MODULE_AUTHOR(name) \
00158 const char __module_author[] __attribute__((section(".modinfo"))) = \
00159 "author=" name
00160
00161 #define MODULE_DESCRIPTION(desc) \
00162 const char __module_description[] __attribute__((section(".modinfo"))) = \
00163 "description=" desc
00164
00165
00166
00167 #define MODULE_SUPPORTED_DEVICE(dev) \
00168 const char __module_device[] __attribute__((section(".modinfo"))) = \
00169 "device=" dev
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 #define MODULE_LICENSE(var)
00186
00187 #define MODULE_PARM(var,type) \
00188 const char __module_parm_##var[] \
00189 __attribute__((section(".modinfo"))) = \
00190 "parm_" __MODULE_STRING(var) "=" type
00191
00192 #define MODULE_PARM_DESC(var,desc) \
00193 const char __module_parm_desc_##var[] \
00194 __attribute__((section(".modinfo"))) = \
00195 "parm_desc_" __MODULE_STRING(var) "=" desc
00196
00197
00198
00199
00200 __asm__(".section .modinfo\n\t.previous");
00201
00202
00203 extern struct module __this_module;
00204
00205 #define THIS_MODULE (&__this_module)
00206 #define MOD_INC_USE_COUNT __MOD_INC_USE_COUNT(&__this_module)
00207 #define MOD_DEC_USE_COUNT __MOD_DEC_USE_COUNT(&__this_module)
00208 #define MOD_IN_USE __MOD_IN_USE(&__this_module)
00209
00210 #ifndef __NO_VERSION__
00211 #include <linux/version.h>
00212 const char __module_kernel_version[] __attribute__((section(".modinfo"))) =
00213 "kernel_version=" UTS_RELEASE;
00214 #ifdef MODVERSIONS
00215 const char __module_using_checksums[] __attribute__((section(".modinfo"))) =
00216 "using_checksums=1";
00217 #endif
00218 #endif
00219
00220 #else
00221
00222 #define MODULE_AUTHOR(name)
00223 #define MODULE_DESCRIPTION(desc)
00224 #define MODULE_SUPPORTED_DEVICE(name)
00225 #define MODULE_LICENSE(var)
00226 #define MODULE_PARM(var,type)
00227 #define MODULE_PARM_DESC(var,desc)
00228 #define THIS_MODULE NULL
00229
00230 #ifndef __GENKSYMS__
00231
00232 #define MOD_INC_USE_COUNT do { } while (0)
00233 #define MOD_DEC_USE_COUNT do { } while (0)
00234 #define MOD_IN_USE 1
00235
00236 extern struct module *module_list;
00237
00238 #endif
00239
00240 #endif
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 #if defined(__GENKSYMS__)
00252
00253
00254
00255 #elif !defined(AUTOCONF_INCLUDED)
00256
00257 #define __EXPORT_SYMBOL(sym,str) error config_must_be_included_before_module
00258 #define EXPORT_SYMBOL(var) error config_must_be_included_before_module
00259 #define EXPORT_SYMBOL_NOVERS(var) error config_must_be_included_before_module
00260
00261 #elif !defined(CONFIG_MODULES)
00262
00263 #define __EXPORT_SYMBOL(sym,str)
00264 #define EXPORT_SYMBOL(var)
00265 #define EXPORT_SYMBOL_NOVERS(var)
00266
00267 #elif !defined(EXPORT_SYMTAB)
00268
00269
00270
00271 #define __EXPORT_SYMBOL(sym,str) error EXPORT_SYMTAB_not_defined
00272 #define EXPORT_SYMBOL(var) error EXPORT_SYMTAB_not_defined
00273 #define EXPORT_SYMBOL_NOVERS(var) error EXPORT_SYMTAB_not_defined
00274
00275 #else
00276
00277 #define __EXPORT_SYMBOL(sym, str) \
00278 const char __kstrtab_##sym[] \
00279 __attribute__((section(".kstrtab"))) = str; \
00280 const struct module_symbol __ksymtab_##sym \
00281 __attribute__((section("__ksymtab"))) = \
00282 { (unsigned long)&sym, __kstrtab_##sym }
00283
00284 #if defined(MODVERSIONS) || !defined(CONFIG_MODVERSIONS)
00285 #define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var))
00286 #else
00287 #define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var)))
00288 #endif
00289
00290 #define EXPORT_SYMBOL_NOVERS(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var))
00291
00292 #endif
00293
00294 #ifdef MODULE
00295
00296 #define EXPORT_NO_SYMBOLS __asm__(".section __ksymtab\n.previous")
00297 #else
00298 #define EXPORT_NO_SYMBOLS
00299 #endif
00300
00301 #endif