bootz启动 Linux内核涉及 bootm_os_get_boot_func 函数

本文详细解析了bootz命令在启动Linux内核过程中的do_bootm_states函数,以及它如何调用bootm_os_get_boot_func获取对应系统的启动函数。重点讨论了bootm_os_get_boot_func函数的工作原理和Linux系统启动函数do_bootm_linux。

一.  bootz启动Linux

uboot 启动Linux内核使用bootz命令。当然还有其它的启动命令,例如,bootm命令等等。

本文只分析 bootz命令启动 Linux内核的过程中涉及的几个重要函数。具体分析  do_bootm_states 函数执行过程。

本文继上一篇文章,地址如下:
bootz启动 Linux内核过程中涉及的 do_bootm_states 函数-优快云博客

bootz 命令的执行函数为 do_bootz函数。而 do_bootz函数主要调用如下函数:

bootz_start 函数,bootm_disable_interrupts 函数,设置 images.os.os ,do_bootm_states 函数。

二.  bootz 启动 Linux 内核涉及函数

1.  bootm_os_get_boot_func 函数

do_bootm_states 函数 会调用 bootm_os_get_boot_func 函数来查找对应系统的启动函数,

这里简单分析一下 bootm_os_get_boot_func 函数。

此函数定义 在文件 common/bootm_os.c 中,函数内容如下:

boot_os_fn *bootm_os_get_boot_func(int os)
{
#ifdef CONFIG_NEEDS_MANUAL_RELOC
	static bool relocated;

	if (!relocated) {
		int i;

		/* relocate boot function table */
		for (i = 0; i < ARRAY_SIZE(boot_os); i++)
			if (boot_os[i] != NULL)
				boot_os[i] += gd->reloc_off;

		relocated = true;
	}
#endif
	return boot_os[os];
}

3~16 行是条件编译,在本 uboot 中没有用到,因此这段代码无效,只有 17 行代码有效。
第17 行中 boot_os 是个数组,这个数组里面存放着不同的系统对应的启动函数。 boot_os 也定 义在文件 common/bootm_os.c 中,这里只列出了此处可执行到代码,如下所示:
static boot_os_fn *boot_os[] = {
	[IH_OS_U_BOOT] = do_bootm_standalone,
#ifdef CONFIG_BOOTM_LINUX
	[IH_OS_LINUX] = do_bootm_linux,
#endif
............
#ifdef CONFIG_BOOTM_OPENRTOS
	[IH_OS_OPENRTOS] = do_bootm_openrtos,
#endif
};

4 行就是 Linux 系统对应的启动函数: do_bootm_linux函数

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值