全部博文(51)
分类: LINUX
2015-09-06 22:43:21
static int alp_get_ontMajor(char *str) { gMajor = simple_strtoul(str + 2, NULL, 16); return 1; } __setup("major=", alp_get_ontMajor); //注册处理函数 unsigned long SYS_GetOntMajor(void) //提供给驱动使用 { return gMajor; } |
/* * Only for really core code. See moduleparam.h for the normal way. * * Force the alignment so the compiler doesn't space elements of the * obs_kernel_param "array" too far apart in .init.setup. */ #define __setup_param(str, unique_id, fn, early) \ static const char __setup_str_##unique_id[] __initconst \ __aligned(1) = str; \ static struct obs_kernel_param __setup_##unique_id \ __used __section(.init.setup) \ __attribute__((aligned((sizeof(long))))) \ = { __setup_str_##unique_id, fn, early } #define __setup(str, fn) \ __setup_param(str, fn, fn, 0) |
__setup("major=", alp_get_ontMajor); ----------------------------------------------------------------------------------------------------------------- __setup_param("major=", alp_get_ontMajor, alp_get_ontMajor, 0) ----------------------------------------------------------------------------------------------------------------- static const char __setup_str_alp_get_ontMajor[] __initconst __aligned(1) = "major"; static struct obs_kernel_param __setup_str_alp_get_ontMajor __used __section(.init.setup) __attribute__((aligned((sizeof(long))))) = {__setup_str_alp_get_ontMajor, alp_get_ontMajor, 0} |
struct obs_kernel_param { const char *str; int (*setup_func)(char *); int early; }; |
#define __init __section(.init.text) __cold notrace #define __initdata __section(.init.data) #define __initconst __section(.init.rodata) #define __exitdata __section(.exit.data) #define __exit_call __used __section(.exitcall.exit) |