{"id":517,"date":"2008-03-23T08:55:15","date_gmt":"2008-03-23T08:55:15","guid":{"rendered":"http:\/\/pchero21.com\/?p=517"},"modified":"2008-03-23T08:55:15","modified_gmt":"2008-03-23T08:55:15","slug":"module-h","status":"publish","type":"post","link":"http:\/\/pchero21.com\/?p=517","title":{"rendered":"module.h"},"content":{"rendered":"<p>&nbsp;module.h \uc5d0\ub294 \uc784\ubca0\ub514\ub4dc \ud504\ub85c\uadf8\ub7a8\uc744 \ub9cc\ub4dc\ub294\ub370 \uc720\uc6a9\ud55c \ub9e4\ud06c\ub85c\ub4e4\uc774 \ud3ec\ud568\ub418\uc5b4 \uc788\ub2e4.<\/p>\n<p>&nbsp;\uc5ec\uae30\uc5d0 \uadf8 \ub0b4\uc6a9\uc744 \uc2e3\ub294\ub2e4.(\ucee4\ub110 \ubc84\uc804\uc740 2.4.19)<\/p>\n<p>\/*<br \/>&nbsp;* Dynamic loading of modules into the kernel.<br \/>&nbsp;*<br \/>&nbsp;* Rewritten by Richard Henderson &lt;rth@tamu.edu&gt; Dec 1996<br \/>&nbsp;*\/<\/p>\n<p>#ifndef _LINUX_MODULE_H<br \/>#define _LINUX_MODULE_H<\/p>\n<p>#include &lt;linux\/config.h&gt;<br \/>#include &lt;linux\/spinlock.h&gt;<br \/>#include &lt;linux\/list.h&gt;<\/p>\n<p>#ifdef __GENKSYMS__<br \/>#&nbsp; define _set_ver(sym) sym<br \/>#&nbsp; undef&nbsp; MODVERSIONS<br \/>#&nbsp; define MODVERSIONS<br \/>#else \/* ! __GENKSYMS__ *\/<br \/># if !defined(MODVERSIONS) &amp;&amp; defined(EXPORT_SYMTAB)<br \/># &nbsp; define _set_ver(sym) sym<br \/># &nbsp; include &lt;linux\/modversions.h&gt;<br \/># endif<br \/>#endif \/* __GENKSYMS__ *\/<\/p>\n<p>#include &lt;asm\/atomic.h&gt;<\/p>\n<p>\/* Don&#8217;t need to bring in all of uaccess.h just for this decl.&nbsp; *\/<br \/>struct exception_table_entry;<\/p>\n<p>\/* Used by get_kernel_syms, which is obsolete.&nbsp; *\/<br \/>struct kernel_sym<br \/>{<br \/>&nbsp;&nbsp; &nbsp;unsigned long value;<br \/>&nbsp;&nbsp; &nbsp;char name[60]; &nbsp; &nbsp; &nbsp; &nbsp;\/* should have been 64-sizeof(long); oh well *\/<br \/>};<\/p>\n<p>struct module_symbol<br \/>{<br \/>&nbsp;&nbsp; &nbsp;unsigned long value;<br \/>&nbsp;&nbsp; &nbsp;const char *name;<br \/>};<\/p>\n<p>struct module_ref<br \/>{<br \/>&nbsp;&nbsp; &nbsp;struct module *dep; &nbsp; &nbsp;\/* &#8220;parent&#8221; pointer *\/<br \/>&nbsp;&nbsp; &nbsp;struct module *ref; &nbsp; &nbsp;\/* &#8220;child&#8221; pointer *\/<br \/>&nbsp;&nbsp; &nbsp;struct module_ref *next_ref;<br \/>};<\/p>\n<p>\/* TBD *\/<br \/>struct module_persist;<\/p>\n<p>struct module<br \/>{<br \/>&nbsp;&nbsp; &nbsp;unsigned long size_of_struct; &nbsp; &nbsp;\/* == sizeof(module) *\/<br \/>&nbsp;&nbsp; &nbsp;struct module *next;<br \/>&nbsp;&nbsp; &nbsp;const char *name;<br \/>&nbsp;&nbsp; &nbsp;unsigned long size;<\/p>\n<p>&nbsp;&nbsp; &nbsp;union<br \/>&nbsp;&nbsp; &nbsp;{<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;atomic_t usecount;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;long pad;<br \/>&nbsp;&nbsp; &nbsp;} uc; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/* Needs to keep its size &#8211; so says rth *\/<\/p>\n<p>&nbsp;&nbsp; &nbsp;unsigned long flags; &nbsp; &nbsp; &nbsp; &nbsp;\/* AUTOCLEAN et al *\/<\/p>\n<p>&nbsp;&nbsp; &nbsp;unsigned nsyms;<br \/>&nbsp;&nbsp; &nbsp;unsigned ndeps;<\/p>\n<p>&nbsp;&nbsp; &nbsp;struct module_symbol *syms;<br \/>&nbsp;&nbsp; &nbsp;struct module_ref *deps;<br \/>&nbsp;&nbsp; &nbsp;struct module_ref *refs;<br \/>&nbsp;&nbsp; &nbsp;int (*init)(void);<br \/>&nbsp;&nbsp; &nbsp;void (*cleanup)(void);<br \/>&nbsp;&nbsp; &nbsp;const struct exception_table_entry *ex_table_start;<br \/>&nbsp;&nbsp; &nbsp;const struct exception_table_entry *ex_table_end;<br \/>#ifdef __alpha__<br \/>&nbsp;&nbsp; &nbsp;unsigned long gp;<br \/>#endif<br \/>&nbsp;&nbsp; &nbsp;\/* Members past this point are extensions to the basic<br \/>&nbsp;&nbsp; &nbsp; &nbsp; module support and are optional.&nbsp; Use mod_member_present()<br \/>&nbsp;&nbsp; &nbsp; &nbsp; to examine them.&nbsp; *\/<br \/>&nbsp;&nbsp; &nbsp;const struct module_persist *persist_start;<br \/>&nbsp;&nbsp; &nbsp;const struct module_persist *persist_end;<br \/>&nbsp;&nbsp; &nbsp;int (*can_unload)(void);<br \/>&nbsp;&nbsp; &nbsp;int runsize; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/* In modutils, not currently used *\/<br \/>&nbsp;&nbsp; &nbsp;const char *kallsyms_start; &nbsp; &nbsp;\/* All symbols for kernel debugging *\/<br \/>&nbsp;&nbsp; &nbsp;const char *kallsyms_end;<br \/>&nbsp;&nbsp; &nbsp;const char *archdata_start; &nbsp; &nbsp;\/* arch specific data for module *\/<br \/>&nbsp;&nbsp; &nbsp;const char *archdata_end;<br \/>&nbsp;&nbsp; &nbsp;const char *kernel_data; &nbsp; &nbsp;\/* Reserved for kernel internal use *\/<br \/>};<\/p>\n<p>struct module_info<br \/>{<br \/>&nbsp;&nbsp; &nbsp;unsigned long addr;<br \/>&nbsp;&nbsp; &nbsp;unsigned long size;<br \/>&nbsp;&nbsp; &nbsp;unsigned long flags;<br \/>&nbsp;&nbsp; &nbsp;long usecount;<br \/>};<\/p>\n<p>\/* Bits of module.flags.&nbsp; *\/<\/p>\n<p>#define MOD_UNINITIALIZED &nbsp; &nbsp;0<br \/>#define MOD_RUNNING &nbsp; &nbsp; &nbsp; &nbsp;1<br \/>#define MOD_DELETED &nbsp; &nbsp; &nbsp; &nbsp;2<br \/>#define MOD_AUTOCLEAN &nbsp; &nbsp; &nbsp; &nbsp;4<br \/>#define MOD_VISITED &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8<br \/>#define MOD_USED_ONCE &nbsp; &nbsp; &nbsp; &nbsp;16<br \/>#define MOD_JUST_FREED &nbsp; &nbsp; &nbsp; &nbsp;32<br \/>#define MOD_INITIALIZING &nbsp; &nbsp;64<\/p>\n<p>\/* Values for query_module&#8217;s which.&nbsp; *\/<\/p>\n<p>#define QM_MODULES &nbsp; &nbsp;1<br \/>#define QM_DEPS &nbsp; &nbsp; &nbsp; &nbsp;2<br \/>#define QM_REFS &nbsp; &nbsp; &nbsp; &nbsp;3<br \/>#define QM_SYMBOLS &nbsp; &nbsp;4<br \/>#define QM_INFO &nbsp; &nbsp; &nbsp; &nbsp;5<\/p>\n<p>\/* Can the module be queried? *\/<br \/>#define MOD_CAN_QUERY(mod) (((mod)-&gt;flags &amp; (MOD_RUNNING | MOD_INITIALIZING)) &amp;&amp; !((mod)-&gt;flags &amp; MOD_DELETED))<\/p>\n<p>\/* When struct module is extended, we must test whether the new member<br \/>&nbsp;&nbsp; is present in the header received from insmod before we can use it. &nbsp;<br \/>&nbsp;&nbsp; This function returns true if the member is present.&nbsp; *\/<\/p>\n<p>#define mod_member_present(mod,member) &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;((unsigned long)(&amp;((struct module *)0L)-&gt;member + 1) &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp; &lt;= (mod)-&gt;size_of_struct)<\/p>\n<p>\/*<br \/>&nbsp;* Ditto for archdata.&nbsp; Assumes mod-&gt;archdata_start and mod-&gt;archdata_end<br \/>&nbsp;* are validated elsewhere.<br \/>&nbsp;*\/<br \/>#define mod_archdata_member_present(mod, type, member) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;(((unsigned long)(&amp;((type *)0L)-&gt;member) + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;&nbsp; sizeof(((type *)0L)-&gt;member)) &lt;= &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp; ((mod)-&gt;archdata_end &#8211; (mod)-&gt;archdata_start))<br \/>&nbsp;&nbsp; &nbsp; <\/p>\n<p>\/* Check if an address p with number of entries n is within the body of module m *\/<br \/>#define mod_bound(p, n, m) ((unsigned long)(p) &gt;= ((unsigned long)(m) + ((m)-&gt;size_of_struct)) &amp;&amp; <br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (unsigned long)((p)+(n)) &lt;= (unsigned long)(m) + (m)-&gt;size)<\/p>\n<p>\/* Backwards compatibility definition.&nbsp; *\/<\/p>\n<p>#define GET_USE_COUNT(module) &nbsp; &nbsp;(atomic_read(&amp;(module)-&gt;uc.usecount))<\/p>\n<p>\/* Poke the use count of a module.&nbsp; *\/<\/p>\n<p>#define __MOD_INC_USE_COUNT(mod) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;(atomic_inc(&amp;(mod)-&gt;uc.usecount), (mod)-&gt;flags |= MOD_VISITED|MOD_USED_ONCE)<br \/>#define __MOD_DEC_USE_COUNT(mod) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;(atomic_dec(&amp;(mod)-&gt;uc.usecount), (mod)-&gt;flags |= MOD_VISITED)<br \/>#define __MOD_IN_USE(mod) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;(mod_member_present((mod), can_unload) &amp;&amp; (mod)-&gt;can_unload &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp; ? (mod)-&gt;can_unload() : atomic_read(&amp;(mod)-&gt;uc.usecount))<\/p>\n<p>\/* Indirect stringification.&nbsp; *\/<\/p>\n<p>#define __MODULE_STRING_1(x) &nbsp; &nbsp;#x<br \/>#define __MODULE_STRING(x) &nbsp; &nbsp;__MODULE_STRING_1(x)<\/p>\n<p>\/* Generic inter module communication.<br \/>&nbsp;*<br \/>&nbsp;* NOTE: This interface is intended for small amounts of data that are<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; passed between two objects and either or both of the objects<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; might be compiled as modules.&nbsp; Do not over use this interface.<br \/>&nbsp;*<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; If more than two objects need to communicate then you probably<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; need a specific interface instead of abusing this generic<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; interface.&nbsp; If both objects are *always* built into the kernel<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; then a global extern variable is good enough, you do not need<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; this interface.<br \/>&nbsp;*<br \/>&nbsp;* Keith Owens &lt;kaos@ocs.com.au&gt; 28 Oct 2000.<br \/>&nbsp;*\/<\/p>\n<p>#ifdef __KERNEL__<br \/>#define HAVE_INTER_MODULE<br \/>extern void inter_module_register(const char *, struct module *, const void *);<br \/>extern void inter_module_unregister(const char *);<br \/>extern const void *inter_module_get(const char *);<br \/>extern const void *inter_module_get_request(const char *, const char *);<br \/>extern void inter_module_put(const char *);<\/p>\n<p>struct inter_module_entry {<br \/>&nbsp;&nbsp; &nbsp;struct list_head list;<br \/>&nbsp;&nbsp; &nbsp;const char *im_name;<br \/>&nbsp;&nbsp; &nbsp;struct module *owner;<br \/>&nbsp;&nbsp; &nbsp;const void *userdata;<br \/>};<\/p>\n<p>extern int try_inc_mod_count(struct module *mod);<br \/>#endif \/* __KERNEL__ *\/<\/p>\n<p>#if defined(MODULE) &amp;&amp; !defined(__GENKSYMS__)<\/p>\n<p>\/* Embedded module documentation macros.&nbsp; *\/<\/p>\n<p>\/* For documentation purposes only.&nbsp; *\/<\/p>\n<p>#define MODULE_AUTHOR(name) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>const char __module_author[] __attribute__((section(&#8220;.modinfo&#8221;))) = &nbsp;&nbsp; &nbsp; &nbsp; <br \/>&#8220;author=&#8221; name<\/p>\n<p>#define MODULE_DESCRIPTION(desc) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>const char __module_description[] __attribute__((section(&#8220;.modinfo&#8221;))) = &nbsp; <br \/>&#8220;description=&#8221; desc<\/p>\n<p>\/* Could potentially be used by kmod&#8230;&nbsp; *\/<\/p>\n<p>#define MODULE_SUPPORTED_DEVICE(dev) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>const char __module_device[] __attribute__((section(&#8220;.modinfo&#8221;))) = &nbsp;&nbsp; &nbsp; &nbsp; <br \/>&#8220;device=&#8221; dev<\/p>\n<p>\/* Used to verify parameters given to the module.&nbsp; The TYPE arg should<br \/>&nbsp;&nbsp; be a string in the following format:<br \/>&nbsp; &nbsp; &nbsp; &nbsp;[min[-max]]{b,h,i,l,s}<br \/>&nbsp;&nbsp; The MIN and MAX specifiers delimit the length of the array.&nbsp; If MAX<br \/>&nbsp;&nbsp; is omitted, it defaults to MIN; if both are omitted, the default is 1.<br \/>&nbsp;&nbsp; The final character is a type specifier:<br \/>&nbsp;&nbsp; &nbsp;b &nbsp; &nbsp;byte<br \/>&nbsp;&nbsp; &nbsp;h &nbsp; &nbsp;short<br \/>&nbsp;&nbsp; &nbsp;i &nbsp; &nbsp;int<br \/>&nbsp;&nbsp; &nbsp;l &nbsp; &nbsp;long<br \/>&nbsp;&nbsp; &nbsp;s &nbsp; &nbsp;string<br \/>*\/<\/p>\n<p>#define MODULE_PARM(var,type) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>const char __module_parm_##var[] &nbsp; &nbsp; &nbsp; &nbsp;<br \/>__attribute__((section(&#8220;.modinfo&#8221;))) = &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&#8220;parm_&#8221; __MODULE_STRING(var) &#8220;=&#8221; type<\/p>\n<p>#define MODULE_PARM_DESC(var,desc) &nbsp; &nbsp; &nbsp; &nbsp;<br \/>const char __module_parm_desc_##var[] &nbsp; &nbsp; &nbsp; &nbsp;<br \/>__attribute__((section(&#8220;.modinfo&#8221;))) = &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&#8220;parm_desc_&#8221; __MODULE_STRING(var) &#8220;=&#8221; desc<\/p>\n<p>\/*<br \/>&nbsp;* MODULE_DEVICE_TABLE exports information about devices<br \/>&nbsp;* currently supported by this module.&nbsp; A device type, such as PCI,<br \/>&nbsp;* is a C-like identifier passed as the first arg to this macro.<br \/>&nbsp;* The second macro arg is the variable containing the device<br \/>&nbsp;* information being made public.<br \/>&nbsp;*<br \/>&nbsp;* The following is a list of known device types (arg 1),<br \/>&nbsp;* and the C types which are to be passed as arg 2.<br \/>&nbsp;* pci &#8211; struct pci_device_id &#8211; List of PCI ids supported by this module<br \/>&nbsp;* isapnp &#8211; struct isapnp_device_id &#8211; List of ISA PnP ids supported by this module<br \/>&nbsp;* usb &#8211; struct usb_device_id &#8211; List of USB ids supported by this module<br \/>&nbsp;*\/<br \/>#define MODULE_GENERIC_TABLE(gtype,name) &nbsp; &nbsp;<br \/>static const unsigned long __module_##gtype##_size <br \/>&nbsp; __attribute__ ((unused)) = sizeof(struct gtype##_id); <br \/>static const struct gtype##_id * __module_##gtype##_table <br \/>&nbsp; __attribute__ ((unused)) = name<\/p>\n<p>\/*<br \/>&nbsp;* The following license idents are currently accepted as indicating free<br \/>&nbsp;* software modules<br \/>&nbsp;*<br \/>&nbsp;* &nbsp; &nbsp;&#8220;GPL&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[GNU Public License v2 or later]<br \/>&nbsp;* &nbsp; &nbsp;&#8220;GPL v2&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[GNU Public License v2]<br \/>&nbsp;* &nbsp; &nbsp;&#8220;GPL and additional rights&#8221; &nbsp; &nbsp;[GNU Public License v2 rights and more]<br \/>&nbsp;* &nbsp; &nbsp;&#8220;Dual BSD\/GPL&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[GNU Public License v2 or BSD license choice]<br \/>&nbsp;* &nbsp; &nbsp;&#8220;Dual MPL\/GPL&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[GNU Public License v2 or Mozilla license choice]<br \/>&nbsp;*<br \/>&nbsp;* The following other idents are available<br \/>&nbsp;*<br \/>&nbsp;* &nbsp; &nbsp;&#8220;Proprietary&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[Non free products]<br \/>&nbsp;*<br \/>&nbsp;* There are dual licensed components, but when running with Linux it is the<br \/>&nbsp;* GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL<br \/>&nbsp;* is a GPL combined work.<br \/>&nbsp;*<br \/>&nbsp;* This exists for several reasons<br \/>&nbsp;* 1. &nbsp; &nbsp;So modinfo can show license info for users wanting to vet their setup <br \/>&nbsp;* &nbsp; &nbsp;is free<br \/>&nbsp;* 2. &nbsp; &nbsp;So the community can ignore bug reports including proprietary modules<br \/>&nbsp;* 3. &nbsp; &nbsp;So vendors can do likewise based on their own policies<br \/>&nbsp;*\/<br \/>&nbsp;<br \/>#define MODULE_LICENSE(license) &nbsp;&nbsp; &nbsp;<br \/>static const char __module_license[] __attribute__((section(&#8220;.modinfo&#8221;))) = &nbsp; <br \/>&#8220;license=&#8221; license<\/p>\n<p>\/* Define the module variable, and usage macros.&nbsp; *\/<br \/>extern struct module __this_module;<\/p>\n<p>#define THIS_MODULE &nbsp; &nbsp; &nbsp; &nbsp;(&amp;__this_module)<br \/>#define MOD_INC_USE_COUNT &nbsp; &nbsp;__MOD_INC_USE_COUNT(THIS_MODULE)<br \/>#define MOD_DEC_USE_COUNT &nbsp; &nbsp;__MOD_DEC_USE_COUNT(THIS_MODULE)<br \/>#define MOD_IN_USE &nbsp; &nbsp; &nbsp; &nbsp;__MOD_IN_USE(THIS_MODULE)<\/p>\n<p>#include &lt;linux\/version.h&gt;<br \/>static const char __module_kernel_version[] __attribute__((section(&#8220;.modinfo&#8221;))) =<br \/>&#8220;kernel_version=&#8221; UTS_RELEASE;<br \/>#ifdef MODVERSIONS<br \/>static const char __module_using_checksums[] __attribute__((section(&#8220;.modinfo&#8221;))) =<br \/>&#8220;using_checksums=1&#8221;;<br \/>#endif<\/p>\n<p>#else \/* MODULE *\/<\/p>\n<p>#define MODULE_AUTHOR(name)<br \/>#define MODULE_LICENSE(license)<br \/>#define MODULE_DESCRIPTION(desc)<br \/>#define MODULE_SUPPORTED_DEVICE(name)<br \/>#define MODULE_PARM(var,type)<br \/>#define MODULE_PARM_DESC(var,desc)<\/p>\n<p>\/* Create a dummy reference to the table to suppress gcc unused warnings.&nbsp; Put<br \/>&nbsp;* the reference in the .data.exit section which is discarded when code is built<br \/>&nbsp;* in, so the reference does not bloat the running kernel.&nbsp; Note: cannot be<br \/>&nbsp;* const, other exit data may be writable.<br \/>&nbsp;*\/<br \/>#define MODULE_GENERIC_TABLE(gtype,name) <br \/>static const struct gtype##_id * __module_##gtype##_table <br \/>&nbsp; __attribute__ ((unused, __section__(&#8220;.data.exit&#8221;))) = name<\/p>\n<p>#ifndef __GENKSYMS__<\/p>\n<p>#define THIS_MODULE &nbsp; &nbsp; &nbsp; &nbsp;NULL<br \/>#define MOD_INC_USE_COUNT &nbsp; &nbsp;do { } while (0)<br \/>#define MOD_DEC_USE_COUNT &nbsp; &nbsp;do { } while (0)<br \/>#define MOD_IN_USE &nbsp; &nbsp; &nbsp; &nbsp;1<\/p>\n<p>extern struct module *module_list;<\/p>\n<p>#endif \/* !__GENKSYMS__ *\/<\/p>\n<p>#endif \/* MODULE *\/<\/p>\n<p>#define MODULE_DEVICE_TABLE(type,name) &nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp; MODULE_GENERIC_TABLE(type##_device,name)<\/p>\n<p>\/* Export a symbol either from the kernel or a module.<\/p>\n<p>&nbsp;&nbsp; In the kernel, the symbol is added to the kernel&#8217;s global symbol table.<\/p>\n<p>&nbsp;&nbsp; In a module, it controls which variables are exported.&nbsp; If no<br \/>&nbsp;&nbsp; variables are explicitly exported, the action is controled by the<br \/>&nbsp;&nbsp; insmod -[xX] flags.&nbsp; Otherwise, only the variables listed are exported.<br \/>&nbsp;&nbsp; This obviates the need for the old register_symtab() function.&nbsp; *\/<\/p>\n<p>#if defined(__GENKSYMS__)<\/p>\n<p>\/* We want the EXPORT_SYMBOL tag left intact for recognition.&nbsp; *\/<\/p>\n<p>#elif !defined(AUTOCONF_INCLUDED)<\/p>\n<p>#define __EXPORT_SYMBOL(sym,str) &nbsp; error config_must_be_included_before_module<br \/>#define EXPORT_SYMBOL(var) &nbsp; &nbsp; &nbsp; error config_must_be_included_before_module<br \/>#define EXPORT_SYMBOL_NOVERS(var)&nbsp; error config_must_be_included_before_module<br \/>#define EXPORT_SYMBOL_GPL(var)&nbsp; error config_must_be_included_before_module<\/p>\n<p>#elif !defined(CONFIG_MODULES)<\/p>\n<p>#define __EXPORT_SYMBOL(sym,str)<br \/>#define EXPORT_SYMBOL(var)<br \/>#define EXPORT_SYMBOL_NOVERS(var)<br \/>#define EXPORT_SYMBOL_GPL(var)<\/p>\n<p>#elif !defined(EXPORT_SYMTAB)<\/p>\n<p>#define __EXPORT_SYMBOL(sym,str) &nbsp; error this_object_must_be_defined_as_export_objs_in_the_Makefile<br \/>#define EXPORT_SYMBOL(var) &nbsp; &nbsp; &nbsp; error this_object_must_be_defined_as_export_objs_in_the_Makefile<br \/>#define EXPORT_SYMBOL_NOVERS(var)&nbsp; error this_object_must_be_defined_as_export_objs_in_the_Makefile<br \/>#define EXPORT_SYMBOL_GPL(var)&nbsp; error this_object_must_be_defined_as_export_objs_in_the_Makefile<\/p>\n<p>#else<\/p>\n<p>#define __EXPORT_SYMBOL(sym, str) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>const char __kstrtab_##sym[] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>__attribute__((section(&#8220;.kstrtab&#8221;))) = str; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>const struct module_symbol __ksymtab_##sym &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br \/>__attribute__((section(&#8220;__ksymtab&#8221;))) = &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>{ (unsigned long)&amp;sym, __kstrtab_##sym }<\/p>\n<p>#define __EXPORT_SYMBOL_GPL(sym, str) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>const char __kstrtab_##sym[] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>__attribute__((section(&#8220;.kstrtab&#8221;))) = &#8220;GPLONLY_&#8221; str; &nbsp; &nbsp;<br \/>const struct module_symbol __ksymtab_##sym &nbsp; &nbsp; &nbsp; &nbsp;<br \/>__attribute__((section(&#8220;__ksymtab&#8221;))) = &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>{ (unsigned long)&amp;sym, __kstrtab_##sym }<\/p>\n<p>#if defined(MODVERSIONS) || !defined(CONFIG_MODVERSIONS)<br \/>#define EXPORT_SYMBOL(var)&nbsp; __EXPORT_SYMBOL(var, __MODULE_STRING(var))<br \/>#define EXPORT_SYMBOL_GPL(var)&nbsp; __EXPORT_SYMBOL_GPL(var, __MODULE_STRING(var))<br \/>#else<br \/>#define EXPORT_SYMBOL(var)&nbsp; __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var)))<br \/>#define EXPORT_SYMBOL_GPL(var)&nbsp; __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var)))<br \/>#endif<\/p>\n<p>#define EXPORT_SYMBOL_NOVERS(var)&nbsp; __EXPORT_SYMBOL(var, __MODULE_STRING(var))<\/p>\n<p>#endif \/* __GENKSYMS__ *\/<\/p>\n<p>#ifdef MODULE<br \/>\/* Force a module to export no symbols.&nbsp; *\/<br \/>#define EXPORT_NO_SYMBOLS&nbsp; __asm__(&#8220;.section __ksymtabn.previous&#8221;)<br \/>#else<br \/>#define EXPORT_NO_SYMBOLS<br \/>#endif \/* MODULE *\/<\/p>\n<p>#ifdef CONFIG_MODULES<br \/>#define SET_MODULE_OWNER(some_struct) do { (some_struct)-&gt;owner = THIS_MODULE; } while (0)<br \/>#else<br \/>#define SET_MODULE_OWNER(some_struct) do { } while (0)<br \/>#endif<\/p>\n<p>#endif \/* _LINUX_MODULE_H *\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;module.h \uc5d0\ub294 \uc784\ubca0\ub514\ub4dc \ud504\ub85c\uadf8\ub7a8\uc744 \ub9cc\ub4dc\ub294\ub370 \uc720\uc6a9\ud55c \ub9e4\ud06c\ub85c\ub4e4\uc774 \ud3ec\ud568\ub418\uc5b4 \uc788\ub2e4. &nbsp;\uc5ec\uae30\uc5d0 \uadf8 \ub0b4\uc6a9\uc744 \uc2e3\ub294\ub2e4.(\ucee4\ub110 \ubc84\uc804\uc740 2.4.19) \/*&nbsp;* Dynamic loading of modules into the kernel.&nbsp;*&nbsp;* Rewritten by Richard Henderson &lt;rth@tamu.edu&gt; Dec 1996&nbsp;*\/ #ifndef _LINUX_MODULE_H#define _LINUX_MODULE_H #include &lt;linux\/config.h&gt;#include &lt;linux\/spinlock.h&gt;#include &lt;linux\/list.h&gt; #ifdef __GENKSYMS__#&nbsp; define &hellip; <a href=\"http:\/\/pchero21.com\/?p=517\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21],"tags":[261],"_links":{"self":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/517"}],"collection":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=517"}],"version-history":[{"count":0,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}