linux内核源代码导读.pdf
还剩
30页未读,
继续阅读
下载文档到电脑,马上远离加班熬夜!
亲,很抱歉,此页已超出免费预览范围啦!
如果喜欢就下载吧,价低环保!
内容要点:
独辟蹊径品内核 —— Linux 内核源代码导读 31 23 * so the expression can be used e.g. in a structure 24 * initializer (or where-ever else comma expressions 25 * aren't permitted). 26 */ 27 28 /* 本例中条件 (p独辟蹊径品内核 —— Linux 内核源代码导读 30 13 int *__check_debug(void) 14 { 15 return(&(debug)); 16 }; 17 18 /* __param_check(debug, debug, byte)展开: */ 19 static inline __attribute__((always_inline)) 2独辟蹊径品内核 —— Linux 内核源代码导读 29 15 }; 16 }; 模块可以使用宏 module_param()添加一个 kernel_param 实例到 __start_param 数组中。例如 AMD PCnet32 网卡驱动模块 pcnet32.c 中使用 module_param(debug, int, 0)告诉内核,该模块接收一个 int 型的 debug 参数。参独辟蹊径品内核 —— Linux 内核源代码导读 28 27 ...... 28 /* 29 * We try each of these until one succeeds. 30 * 31 * The Bourne shell can be used instead of init if we are 32 * trying to recover a really 独辟蹊径品内核 —— Linux 内核源代码导读 27 段的内存在启动结束后会被释放,但是没关系,因为它的值在随后的 18 行将被复制到obs_kernel_param 结构的实例中。而这个实例是在第 14 行定义的,并且由第 16 行指定这个结构放到 .init.setup 段中。在链接脚本 vmlinux.lds 中指定把所有 .o 文件中的 .init.setup 段都合成到一起。 __s独辟蹊径品内核 —— Linux 内核源代码导读 26 个注册的项目在内核中使用一个 obs_kernel_param 结构来表示,该结构定义如下: 代码片段 4.26. 节自 include/linux/init.h 1 struct obs_kernel_param { 2 /* 参数的名字。 */ 3 const char *str; 4 /* 参数对应的处理函独辟蹊径品内核 —— Linux 内核源代码导读 25 行处理。 代码片段 4.25. 节自 init/main.c 1 void __init parse_early_param(void) 2 { 3 static __initdata int done = 0; 4 static __initdata char tmp_cmdline[COMMAND_LINE_SI独辟蹊径品内核 —— Linux 内核源代码导读 24 26 __attribute__((__section__(".initcall" level ".init")))=fn 如果希望 do_initcalls()调用某一个初始化函数,就需要使用这些宏。比如上面的postcore_initcall 函数就是使用 postcore_initcall(pci_driver_in
发表评论
暂无评论,赶快抢占沙发吧。