I'm working on a device driver under Linux 2.2.13. I have some parameters defined and want to pass the values when doing the insmod. I did some thing as follow: insmod driver.o param1=xx added a line in /etc/conf.modules file: options driver param1=xx. Both of them can't pass the parameter value to the driver. The insmod version is 2.1.121. I knew it's pretty old one. But I think it should work.
The parameters are put in the .sdata section by the compile. I have checked the modules.h and found code as follow: Is there any difference between using .sdata section and .modinfo section?
Thanks,
Leiying #if defined(MODULE) && !defined(__GENKSYMS__) /* Embedded module documentation macros. */
/* For documentation purposes only. */
#define MODULE_AUTHOR(name) \ const char __module_author[] __attribute__((section(".modinfo"))) = \ "author=" name
#define MODULE_DESCRIPTION(desc) \ const char __module_description[] __attribute__((section(".modinfo"))) = \ "description=" desc
/* Could potentially be used by kmod... */
#define MODULE_SUPPORTED_DEVICE(dev) \ const char __module_device[] __attribute__((section(".modinfo"))) = \ "device=" dev
/* Used to verify parameters given to the module. The TYPE arg should be a string in the following format: [min[-max]]{b,h,i,l,s} The MIN and MAX specifiers delimit the length of the array. If MAX is omitted, it defaults to MIN; if both are omitted, the default is 1. The final character is a type specifier: b byte h short i int l long s string
*/#define MODULE_PARM(var,type) \ const char __module_parm_##var[] \ __attribute__((section(".modinfo"))) = \ "parm_" __MODULE_STRING(var) "=" type
#define MODULE_PARM_DESC(var,desc) \ const char __module_parm_desc_##var[] \ __attribute__((section(".modinfo"))) = \ "parm_desc_" __MODULE_STRING(var) "=" desc
/* The attributes of a section are set the first time the section is seen; we want .modinfo to not be allocated. */
__asm__(".section .modinfo\n\t.previous");
/* Define the module variable, and usage macros. */ extern struct module __this_module;
#define MOD_INC_USE_COUNT __MOD_INC_USE_COUNT(&__this_module) #define MOD_DEC_USE_COUNT __MOD_DEC_USE_COUNT(&__this_module) #define MOD_IN_USE __MOD_IN_USE(&__this_module)
#ifndef __NO_VERSION__ #include const char __module_kernel_version[] __attribute__((section(".modinfo"))) = "kernel_version=" UTS_RELEASE; #ifdef MODVERSIONS const char __module_using_checksums[] __attribute__((section(".modinfo"))) = "using_checksums=1"; #endif #endif
#else /* MODULE */
#define MODULE_AUTHOR(name) #define MODULE_DESCRIPTION(desc) #define MODULE_SUPPORTED_DEVICE(name) #define MODULE_PARM(var,type) #define MODULE_PARM_DESC(var,desc)
#ifndef __GENKSYMS__
#define MOD_INC_USE_COUNT do { } while (0) #define MOD_DEC_USE_COUNT do { } while (0) #define MOD_IN_USE 1
extern struct module *module_list;
#endif /* !__GENKSYMS__ */
#endif /* MODULE */