DSP

uclinux内核参数处理(2):parse_cmdline_early

2019-07-13 16:51发布

rev 0.1   快乐虾 http://blog.csdn.net/lights_joy/ lights@hb165.com    本文适用于 ADI bf561 DSP 优视BF561EVB开发板 uclinux-2008r1.5-rc3 (smp patch) Visual DSP++ 5.0(update 5)   欢迎转载,但请保留作者信息   这是内核第一次对传递进来的参数进行分析,对此函数的调用出现在setup_arch函数中,此时,内核仅仅对CPU的基本参数进行的进行了设置,如运行频率,EBIU等等。 void __init setup_arch(char **cmdline_p) { ……………………        /* Keep a copy of command line */      *cmdline_p = &command_line[0];      memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);      boot_command_line[COMMAND_LINE_SIZE - 1] = '/0';        /* setup memory defaults from the user config */      physical_mem_end = 0;      _ramend = CONFIG_MEM_SIZE * 1024 * 1024;        parse_cmdline_early(&command_line[0]); ……………………. } parse_cmdline_early函数的实现则为: /*  * Initial parsing of the command line.  Currently, we support:  *  - Controlling the linux memory size: mem=xxx[KMG]  *  - Controlling the physical memory size: max_mem=xxx[KMG][$][#]  *       $ -> reserved memory is dcacheable  *       # -> reserved memory is icacheable  */ static __init void parse_cmdline_early(char *cmdline_p) {      char c = ' ', *to = cmdline_p;      unsigned int memsize;      for (;;) {          if (c == ' ') {                 if (!memcmp(to, "mem=", 4)) {                    to += 4;                    memsize = memparse(to, &to);                    if (memsize)                        _ramend = memsize;                 } else if (!memcmp(to, "max_mem=", 8)) {                    to += 8;                    memsize = memparse(to, &to);                    if (memsize) {                        physical_mem_end = memsize;                        if (*to != ' ') {                             if (*to == '$'                                 || *(to + 1) == '$')                                  reserved_mem_dcache_on =                                      1;                             if (*to == '#'                                 || *(to + 1) == '#')                                  reserved_mem_icache_on =                                      1;                        }                    }               } else if (!memcmp(to, "earlyprintk=", 12)) {                    to += 12;                    setup_early_printk(to);               }          }          c = *(to++);          if (!c)               break;      } } 从这段代码可以很容易看出此时内核只处理必要的3个参数:memmax_memearlyprintk  

1       参考资料

uclinux内核参数处理(1):参数接收(2009-1-29)