linux之early_param()和__setup
2016-08-27 11:14
447 查看
原理:
在linux启动时,调用在init/main.c里面的start_kernel()时,执行到parse_early_param()时,uboot传递的cmdline里面有相应的命令,就会调用early_param()和__setup注册的函数。可以在驱动模块的任何c文件里面用early_param(),__setup()注册,只需要包含include/linux/init.h头文件
用法例子:
如在printk.c里面的:
如果uboot传递的cmdline里面有"boot_delay",则函数boot_delay_setup()在linux启动时会被调用
参考:
http://blog.chinaunix.net/uid-27717694-id-3495617.html
在linux启动时,调用在init/main.c里面的start_kernel()时,执行到parse_early_param()时,uboot传递的cmdline里面有相应的命令,就会调用early_param()和__setup注册的函数。可以在驱动模块的任何c文件里面用early_param(),__setup()注册,只需要包含include/linux/init.h头文件
用法例子:
如在printk.c里面的:
static int __init boot_delay_setup(char *str) { unsigned long lpj; lpj = preset_lpj ? preset_lpj : 1000000;/* some guess */ loops_per_msec = (unsigned long long)lpj / 1000 * HZ; get_option(&str, &boot_delay); if (boot_delay > 10 * 1000) boot_delay = 0; pr_debug("boot_delay: %u, preset_lpj: %ld, lpj: %lu, " "HZ: %d, loops_per_msec: %llu\n", boot_delay, preset_lpj, lpj, HZ, loops_per_msec); return 0; } early_param("boot_delay", boot_delay_setup);
如果uboot传递的cmdline里面有"boot_delay",则函数boot_delay_setup()在linux启动时会被调用
参考:
http://blog.chinaunix.net/uid-27717694-id-3495617.html
相关文章推荐
- Linux启动参数及实现 __setup与early_param
- Linux启动参数及实现 __setup与early_param
- Linux启动参数及实现 __setup与early_param
- Linux启动参数及实现 __setup与early_param
- Linux启动参数及实现 __setup与early_param .
- Linux启动参数及实现 __setup与early_param
- Linux启动参数及实现 __setup与early_param
- Linux启动参数及实现 __setup与early_param(讲的不错,转载)
- __setup、early_param的解析
- linux 内核的early_param
- early_param("earlyprintk", setup_early_printk);
- early_param、__setup、__tagtable分析
- Linux kernel mips early_param
- Linux 引导解析(使用bootsect.s+setup.s方式)
- Linux VMTOOLS setup
- How to setup tomcat in linux?
- 用nasm语言重新实现linux-0.11 setup.s (博古以通今)
- 小白学Linux之module_param()函数学习
- How to setup tomcat in linux?
- [转贴]linux内核编译选项详解(一):General setup