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个参数:mem,max_mem和earlyprintk。
uclinux内核参数处理(1):参数接收(2009-1-29)
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮