内核启动的现在已经是开始执行函数start_kernel函数了。start_kernel函数在init/main.c中定义。start_kernel函数只是完成
相应的结构的初始化任务。
printk(KERN_NOTICE);
printk(linux_banner);
setup_arch(&command_line);
在uboot的一直过程中,uboot传递给kernel的参数:预先存放在某个地方的tag和机器类型id,机器类型id在函数__look_up_machine
中已经使用,tag列表是在函数setup_arch中调用的。setup_arch函数是在arch/arm/kernel/setup.c中定义:
void __init setup_arch(char **cmdline_p)
{
....
setup_processor(); // 处理器相关的设置
mdesc = setup_machine(machine_arch_type); // 得到machine_desc结构
machine_name = mdesc->name;
...
if (mdesc->boot_params) // 定义了uboot的参数
tags = phys_to_virt(mdesc->boot_params); // 得到uboot参数tag地址
...
if (tags->hdr.tag == ATAG_CORE) {
if (meminfo.nr_banks != 0) // 在内核中定义了meminfo
squash_mem_tags(tags); // 忽略内存中的信息
parse_tags(tags); // 解析tag
}
...
memcpy(boot_command_line, from, COMMAND_LINE_SIZE);
boot_command_line[COMMAND_LINE_SIZE-1] = '/0';
parse_cmdline(cmdline_p, from); // 解析命令行
paging_init(&meminfo, mdesc); // 重新初始化页表
request_standard_resources(&meminfo, mdesc);
...
}
上面函数的疑问是if (mdesc->boot_params) // 定义了uboot的参数,uboot的参数是在那里定义的?答案就是在arch/arm/
mach-s3c2410/mach-smdk2410.c中定义:
MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
...
.boot_params = S3C2410_SDRAM_PA + 0x100,
MACHINE_END
然后就是函数parse_tags的作用是什么?uboot在传递给kernenl的信息,在这里称之为tag,解析字符串tag,然后将得到的
信息保存到全局的变量中,在setup.c中定义如下:
unsigned int system_serial_low;
EXPORT_SYMBOL(system_serial_low);
...
static int __init parse_tag_serialnr(const struct tag *tag)
{
system_serial_low = tag->u.serialnr.low;
system_serial_high = tag->u.serialnr.high;
return 0;
}
...
/*
* Scan the tag table for this tag, and call its parse function.
* The tag table is built by the linker from all the __tagtable
* declarations.
*/
static int __init parse_tag(const struct tag *tag)
{
extern struct tagtable __tagtable_begin, __tagtable_end;
struct tagtable *t;
for (t = &__tagtable_begin; t < &__tagtable_end; t++)
if (tag->hdr.tag == t->tag) {
t->parse(tag);
break;
}
return t < &__tagtable_end;
}
...
/*
* Parse all tags in the list, checking both the global and architecture
* specific tag tables.
*/
static void __init parse_tags(const struct tag *t)
{
for (; t->hdr.size; t = tag_next(t))
if (!parse_tag(t))
printk(KERN_WARNING
"Ignoring unrecognised tag 0x%08x/n",
t->hdr.tag);
}
于是上面的函数调用是:在setup.c中调用函数parse_tags(tags);,在parse_tags(tags);函数中调用函数parse_tag,parse_tag
函数中根据不同的tag,调用 t->parse(tag)。
当然命令行的参数处理并不只是在setup_arch(,在start_kernel中同样还有,具体参见代码。
最后一个疑问是 paging_init(&meminfo, mdesc);完成了什么?该函数的调用形式:
paging_init(&meminfo, mdesc);
分享到:
相关推荐
linux2.6.33内核移植s3c2410以及交叉环境编译搭建
Linux内核在S3C2410上移植的研究.pdf
Linux-2.6内核在S3C2410上的移植分析和实现.pdf
内核linux2.6.33内核成功移植s3c2410详细过程
s3c2410开发板上LINUX内核移植文档 c语言
对S3C2410内核移植详解,包含了详细的操作步骤!!
基于S3C2410的Linux移植,内核移植,驱动开发
s3c2410上的Linux移植过程
如何移植Linux操作系统 ,在基于Arm微内核的三星S3C2410平台上移植
详细讲解了Linux系统的移植方法,并且有实际的操作,可按相应的步骤完成Linux系统的移植。... 压缩文件中有四个文件,它们是相关连的,总的是linux移植.txt文档,其次还有,u-boot移植,内核移植,文件系统移植。
高版本的arm-linux-gcc-3.4.1.tar.bz2可以编译kernel,低版本的armv4l-tools-2.95.2.tar.bz2可以编译vivi,解压当前文件夹命令$ tar jxvf arm-linux-gcc-3.4.1.tar -C / $ tar jvxf armv4l-tools-2.95.2.tar.bz2 -C ...
基于S3C2410平台移植Linux 2.6内核指南
ucosII在arm920T内核s3c2410移植的代码
资源包括了一份如何移植的文档、一份s3c2410-uda1341的源代码文档。 移植后可以直接运行
S3C2410开发平台上linux2.6内核移植以及其驱动程序开发
linux2.6.14内核移植到CVT2410上的文档(研究生嵌入式教学使用),包括内核移植(包括了所有的外设驱动移植),使用busybox制作根文件系统生成,jss2文件系统制作,QT桌面的制作,以及下载到s3c2410开发板上的所有...
linue2.6.14 内核移植到S3C2410 板子 过程详细介绍
支持linux 2.6.22-24内核移植的S3C2410 USB device驱动程序! linux 内核支持USB HOST但是,不支持 USB device的驱动!
基于s3c2410开发板的2.6.26.5内核移植; 内核移植代码及文档.
将嵌入式Linux 2.6内核移植到S3C2410处理器的目标板上的方法与具体实现过程.