linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / include / linux / module.h
index 0a86652..84d75f3 100644 (file)
 #include <linux/kmod.h>
 #include <linux/elf.h>
 #include <linux/stringify.h>
+#include <linux/kobject.h>
+#include <linux/moduleparam.h>
 #include <asm/local.h>
 
 #include <asm/module.h>
 
 /* Not Yet Implemented */
 #define MODULE_SUPPORTED_DEVICE(name)
-#define print_modules()
 
 /* v850 toolchain uses a `_' prefix for all user symbols */
 #ifndef MODULE_SYMBOL_PREFIX
@@ -43,6 +44,24 @@ struct modversion_info
        char name[MODULE_NAME_LEN];
 };
 
+struct module;
+
+struct module_attribute {
+        struct attribute attr;
+        ssize_t (*show)(struct module_attribute *, struct module *, char *);
+        ssize_t (*store)(struct module_attribute *, struct module *,
+                        const char *, size_t count);
+       void (*setup)(struct module *, const char *);
+       int (*test)(struct module *);
+       void (*free)(struct module *);
+};
+
+struct module_kobject
+{
+       struct kobject kobj;
+       struct module *mod;
+};
+
 /* These are either module local, or the kernel's dummy ones. */
 extern int init_module(void);
 extern void cleanup_module(void);
@@ -58,25 +77,17 @@ void sort_extable(struct exception_table_entry *start,
                  struct exception_table_entry *finish);
 void sort_main_extable(void);
 
-#ifdef MODULE
-#define ___module_cat(a,b) __mod_ ## a ## b
-#define __module_cat(a,b) ___module_cat(a,b)
-#define __MODULE_INFO(tag, name, info)                                   \
-static const char __module_cat(name,__LINE__)[]                                  \
-  __attribute_used__                                                     \
-  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
+extern struct subsystem module_subsys;
 
+#ifdef MODULE
 #define MODULE_GENERIC_TABLE(gtype,name)                       \
 extern const struct gtype##_id __mod_##gtype##_table           \
   __attribute__ ((unused, alias(__stringify(name))))
 
 extern struct module __this_module;
 #define THIS_MODULE (&__this_module)
-
 #else  /* !MODULE */
-
 #define MODULE_GENERIC_TABLE(gtype,name)
-#define __MODULE_INFO(tag, name, info)
 #define THIS_MODULE ((struct module *)0)
 #endif
 
@@ -140,11 +151,9 @@ extern struct module __this_module;
            customizations, eg "rh3" or "rusty1".
 
   Using this automatically adds a checksum of the .c files and the
-  local headers to the end.  Use MODULE_VERSION("") if you want just
-  this.  Macro includes room for this.
+  local headers in "srcversion".
 */
-#define MODULE_VERSION(_version) \
-  MODULE_INFO(version, _version "\0xxxxxxxxxxxxxxxxxxxxxxxx")
+#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
 
 /* Given an address, look for it in the exception tables */
 const struct exception_table_entry *search_exception_tables(unsigned long add);
@@ -191,10 +200,6 @@ void *__symbol_get_gpl(const char *symbol);
 
 #endif
 
-/* We don't mangle the actual symbol anymore, so no need for
- * special casing EXPORT_SYMBOL_NOVERS.  FIXME: Deprecated */
-#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym)
-
 struct module_ref
 {
        local_t count;
@@ -207,6 +212,23 @@ enum module_state
        MODULE_STATE_GOING,
 };
 
+/* Similar stuff for section attributes. */
+#define MODULE_SECT_NAME_LEN 32
+struct module_sect_attr
+{
+       struct module_attribute mattr;
+       char name[MODULE_SECT_NAME_LEN];
+       unsigned long address;
+};
+
+struct module_sect_attrs
+{
+       struct attribute_group grp;
+       struct module_sect_attr attrs[0];
+};
+
+struct module_param_attrs;
+
 struct module
 {
        enum module_state state;
@@ -217,6 +239,12 @@ struct module
        /* Unique handle for this module */
        char name[MODULE_NAME_LEN];
 
+       /* Sysfs stuff. */
+       struct module_kobject mkobj;
+       struct module_param_attrs *param_attrs;
+       const char *version;
+       const char *srcversion;
+
        /* Exported symbols */
        const struct kernel_symbol *syms;
        unsigned int num_syms;
@@ -274,6 +302,9 @@ struct module
        Elf_Sym *symtab;
        unsigned long num_symtab;
        char *strtab;
+
+       /* Section attributes */
+       struct module_sect_attrs *sect_attrs;
 #endif
 
        /* Per-cpu data. */
@@ -292,8 +323,9 @@ static inline int module_is_live(struct module *mod)
        return mod->state != MODULE_STATE_GOING;
 }
 
-/* Is this address in a module? */
+/* Is this address in a module? (second is with no locks, for oops) */
 struct module *module_text_address(unsigned long addr);
+struct module *__module_text_address(unsigned long addr);
 
 /* Returns module and fills in value, defined and namebuf, or NULL if
    symnum out of range. */
@@ -400,10 +432,15 @@ const struct exception_table_entry *search_module_extables(unsigned long addr);
 int register_module_notifier(struct notifier_block * nb);
 int unregister_module_notifier(struct notifier_block * nb);
 
+extern void print_modules(void);
+
+struct device_driver;
+void module_add_driver(struct module *, struct device_driver *);
+void module_remove_driver(struct device_driver *);
+
 #else /* !CONFIG_MODULES... */
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
-#define EXPORT_SYMBOL_NOVERS(sym)
 
 /* Given an address, look for it in the exception tables. */
 static inline const struct exception_table_entry *
@@ -418,6 +455,12 @@ static inline struct module *module_text_address(unsigned long addr)
        return NULL;
 }
 
+/* Is this address in a module? (don't take a lock, we're oopsing) */
+static inline struct module *__module_text_address(unsigned long addr)
+{
+       return NULL;
+}
+
 /* Get/put a kernel symbol (calls should be symmetric) */
 #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
 #define symbol_put(x) do { } while(0)
@@ -480,6 +523,21 @@ static inline int unregister_module_notifier(struct notifier_block * nb)
 
 #define module_put_and_exit(code) do_exit(code)
 
+static inline void print_modules(void)
+{
+}
+
+struct device_driver;
+struct module;
+
+static inline void module_add_driver(struct module *module, struct device_driver *driver)
+{
+}
+
+static inline void module_remove_driver(struct device_driver *driver)
+{
+}
+
 #endif /* CONFIG_MODULES */
 
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
@@ -491,45 +549,29 @@ struct obsolete_modparm {
        char type[64-sizeof(void *)];
        void *addr;
 };
+
+static inline void MODULE_PARM_(void) { }
 #ifdef MODULE
 /* DEPRECATED: Do not use. */
 #define MODULE_PARM(var,type)                                              \
-struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \
-{ __stringify(var), type };
-
-static inline void __deprecated MOD_INC_USE_COUNT(struct module *module)
-{
-       __unsafe(module);
-
-#if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE)
-       local_inc(&module->ref[get_cpu()].count);
-       put_cpu();
-#else
-       (void)try_module_get(module);
-#endif
-}
-
-static inline void __deprecated MOD_DEC_USE_COUNT(struct module *module)
-{
-       module_put(module);
-}
-
-#define MOD_INC_USE_COUNT      MOD_INC_USE_COUNT(THIS_MODULE)
-#define MOD_DEC_USE_COUNT      MOD_DEC_USE_COUNT(THIS_MODULE)
+extern struct obsolete_modparm __parm_##var \
+__attribute__((section("__obsparm"))); \
+struct obsolete_modparm __parm_##var = \
+{ __stringify(var), type, &MODULE_PARM_ }; \
+__MODULE_PARM_TYPE(var, type);
 #else
-#define MODULE_PARM(var,type)
-#define MOD_INC_USE_COUNT      do { } while (0)
-#define MOD_DEC_USE_COUNT      do { } while (0)
+#define MODULE_PARM(var,type) static void __attribute__((__unused__)) *__parm_##var = &MODULE_PARM_;
 #endif
 
 #define __MODULE_STRING(x) __stringify(x)
 
 /* Use symbol_get and symbol_put instead.  You'll thank me. */
 #define HAVE_INTER_MODULE
-extern void inter_module_register(const char *, struct module *, const void *);
-extern void inter_module_unregister(const char *);
-extern const void *inter_module_get(const char *);
-extern const void *inter_module_get_request(const char *, const char *);
-extern void inter_module_put(const char *);
+extern void __deprecated inter_module_register(const char *,
+               struct module *, const void *);
+extern void __deprecated inter_module_unregister(const char *);
+extern const void * __deprecated inter_module_get_request(const char *,
+               const char *);
+extern void __deprecated inter_module_put(const char *);
 
 #endif /* _LINUX_MODULE_H */