一. bootz启动Linux
uboot 启动Linux内核使用bootz命令。当然还有其它的启动命令,例如,bootm命令等等。
本文只分析 bootz命令启动 Linux内核的过程,具体分析 bootz启动 Linux内核过程涉及的 do_bootz 函数。
本文继上一篇文章,地址如下:
bootz启动 Linux内核过程中涉及的全局变量images_凌肖战的博客-优快云博客
二. bootz 启动 Linux 内核过程
1. do_bootz 函数
bootz 命令的执行函数为 do_bootz函数,在文件 cmd/bootm.c 中有如下定义:
int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int ret;
/* Consume 'bootz' */
argc--; argv++;
if (bootz_start(cmdtp, flag, argc, argv, &images))
return 1;
/*
* We are doing the BOOTM_STATE_LOADOS state ourselves, so must
* disable interrupts ourselves
*/
bootm_disable_interrupts();
images.os.os = IH_OS_LINUX;
ret = do_bootm_states(cmdtp, flag, argc, argv,
BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
BOOTM_STATE_OS_GO,
&images, 1);
return ret;
}
第 8
行,调用
bootz_start
函数。
第
15
行,调用函数
bootm_disable_interrupts
关闭中断。
第
17
行,设置
images.os.os
为
IH_OS_LINUX
,也就是设置系统镜像为
Linux
,表示我们
要启动的是
Linux
系统!后面会用到
images.os.os
来挑选具体的启动函数。
第
18
行,调用函数
do_bootm_states
来执行不同的
BOOT
阶段,这里要执行的
BOOT
阶
段有:
BOOTM_STATE_OS_PREP
、
BOOTM_STATE_OS_FAKE_GO
和
BOOTM_STATE_OS_GO
。
三. 函数调用关系
do_bootz 函数的调用关系如下:
后面的几篇文章,简单分析一下关键booz启动内核时涉及的几个关键函数。