Chinaunix首页 | 论坛 | 博客
  • 博客访问: 106959
  • 博文数量: 13
  • 博客积分: 316
  • 博客等级: 二等列兵
  • 技术积分: 292
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-02 10:39
文章存档

2022年(1)

2018年(1)

2012年(1)

2011年(10)

分类: LINUX

2011-12-02 08:56:17

   在bootloader工作完成后,在内存中加载Linux内核。同时把一些内核引导参数传递给内核。内核根据这些参数作为作为选项,对内核作初化。
   参数字符串,如:“ root=/dev/mtdblock1 rw console=tty0 console=ttyS1,115200 rootfstype=yaffs2 mem=64M, monitor=0”。这其中参数包括有“root”、“console”、“rootfstype”、“mem”、“monitor”,也就是参数字符串中“=”的左值。内核在启动时会调用parse_args函数分析这参数字符串,对于一个参数项都会执行与之绑定的操作(函数)。
   引导参数是通过__setup(string, function_handler)注册的。该函数把string中的字符串和function_handler函数绑定了起来。在内核启动时,若parse_args函数扫描到string字符串,就执行function_handler函数。
   其实__setup是生成了一个struct obs_kernel_param对象。struct obs_kernel_param的定义如下:
  1. struct obs_kernel_param {
  2.     const char *str;
  3.     int (*setup_func)(char *);
  4.     int early;
  5. }
 例如:

 
  1. int __init di_do_boot_setup(char *str)
  2. {
  3.     int ints[5];

  4.     printk("****************************\n");
  5.     printk("str: %s", str);

  6.     str = get_options(str, ARRAY_SIZE(ints), ints);
  7.     if (!str || !*str)
  8.         return 0;

  9.     printk("str: %s", str);

  10.     return 0;
  11. }

  12. __setup("dido=", di_do_boot_setup);
当然bootloader传入的参数为:ubi.mtd=0 root=ubi0:safefs console=ttyS0,115200 mem=64M rootfstype=ubifs ro dido=fuck 
   

阅读(2030) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:ubifs笔记

给主人留下些什么吧!~~