您的位置:首页 > 其它

uboot参数区中的bootargs如何传给内核呢?

2012-12-22 20:00 363 查看
平台:STi7162

uboot版本:uboot 1.3.1(st已做过修改)

st平台的内存首地址是0x80000000,此地址不是固定的,不同类型的芯片是不同的,比如samsung的arm920t是0x30000000。uboot提供两种工作模式:一是启动加载模式(start loading),一是下载模式(downloading)。工作在启动加载模式时,uboot会自动执行bootcmd命令,比如:bootcmd=“nand read 0x100000 0x80000000 0x300000; bootm 0x80000000”

1、uboot首先把内核镜像拷贝到内存地址为0x80000000的地方,然后执行bootm 0x80000000命令

bootm命令来自 common/cmd_bootm.c文件,完成的功能有

》CRC校验image head struct的64个字节的正确性

》根据镜像头中指定的压缩类型(比如gzip),把kernel解压到指定的位置hdr->ih_load(0x80800000)

》调用来自lib_sh/sh_linux.c中的函数do_bootm_linux( . . . ),启动内核

2、接下来,分析do_bootm_linux函数的执行流程

传给kernel的命令行参数地址是宏定义 #define COMMAND_LINE ((char *)(param+0x100))

do_bootm_linux

{

》从参数去中获取环境变量bootargs的值

char *commandline = getenv("bootargs");

》从image head struct中获取kernel的入口地址

void (*theKernel)(void); // 函数指针

theKernel = (void (*) (void)) ntohl (hdr->ih_ep);

》从image head struct中获取kernel的指定存储参数的地址

ulong param;

param = ntohl (hdr->ih_load);

》把commandline拷贝到约定好的COMMAND_LINE地址

strcpy (COMMAND_LINE, commandline);

》最后,执行kernel的入口函数,把控制权交给kernel

/* now, finally, we pass control to the kernel itself ... */

theKernel();

}

3、uboot加载kernel后内存使用情况

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: