调用 board_init_r,传入全局 GD 和 SDRAM 中的目的地址 gd->rellocaddr

 void board_init_r(gd_t *new_gd, ulong dest_addr)
{
/*
* Set up the new global data pointer. So far only x86 does this
* here.
* TODO(sjg@chromium.org): Consider doing this for all archs, or
* dropping the new_gd parameter.
*/
/* 打开LOG标志*/
gd->flags &= ~GD_FLG_LOG_READY; if (initcall_run_list(init_sequence_r))
hang(); /* NOTREACHED - run_main_loop() does not return */
hang();
}

  这里同样建立了一个链表,分析里面的设置即可。

11.1 init_sequence_r

  里面只是进行了一系列的初始化。

 static init_fnc_t init_sequence_r[] = {
initr_trace,
initr_reloc,
#ifdef CONFIG_ARM
initr_caches,
#endif
initr_reloc_global_data,
initr_barrier,
initr_malloc,
log_init,
initr_bootstage, /* Needs malloc() but has its own timer */
initr_console_record,
bootstage_relocate,
#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
board_init, /* Setup chipselects */
#endif
#ifdef CONFIG_EFI_LOADER
efi_memory_init,
#endif
stdio_init_tables,
initr_serial,
initr_announce,
INIT_FUNC_WATCHDOG_RESET
INIT_FUNC_WATCHDOG_RESET
INIT_FUNC_WATCHDOG_RESET
power_init_board,
#ifdef CONFIG_MTD_NOR_FLASH
initr_flash,
#endif
INIT_FUNC_WATCHDOG_RESET
#ifdef CONFIG_CMD_NAND
initr_nand,
#endif
initr_env,
INIT_FUNC_WATCHDOG_RESET
initr_secondary_cpu,
INIT_FUNC_WATCHDOG_RESET
stdio_add_devices,
initr_jumptable,
console_init_r, /* fully init console as a device */
INIT_FUNC_WATCHDOG_RESET
interrupt_init,
#ifdef CONFIG_ARM
initr_enable_interrupts,
#endif
/* PPC has a udelay(20) here dating from 2002. Why? */
#ifdef CONFIG_CMD_NET
initr_ethaddr,
#endif
#ifdef CONFIG_CMD_NET
INIT_FUNC_WATCHDOG_RESET
initr_net,
#endif
run_main_loop,
};

  到最后执行run_main_loop 函数,进行内核的调用。

11.2 main_loop

  run_main_loop  调用 main_loop,main_loop定义在common/main.c中:

 /* We come here after U-Boot is initialised and ready to process commands */
void main_loop(void)
{
const char *s; /* bootstage_mark_name函数调用了show_boot_progress,利用它显示启动进程(progress),
此处为空函数 */
bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); #ifdef CONFIG_VERSION_VARIABLE
/* setenv 设置环境变量 ver 为 version_string,后者在common/cmd_version.c中定义为:
const char __weak version_string[] = U_BOOT_VERSION_STRING; */
/* U_BOOT_VERSION_STRING在version.h中定义 */
env_set("ver", version_string); /* set version variable */
#endif /* CONFIG_VERSION_VARIABLE */ /* cli_init用来初始化hush shell使用的一些变量。 */
cli_init(); /* run_preboot_environment_command函数从环境变量中获取"preboot"的定义,*/
/* 该变量包含了一些预启动命令,一般环境变量中不包含该项配置。 */
run_preboot_environment_command(); #if defined(CONFIG_UPDATE_TFTP)
update_tftp(0UL, NULL, NULL);
#endif /* CONFIG_UPDATE_TFTP */ /* bootdelay_process从环境变量中取出"bootdelay"和"bootcmd"的配置值 */
/* 将取出的"bootdelay"配置值转换成整数,赋值给全局变量stored_bootdelay */
/* 最后返回"bootcmd"的配置值 */
/*bootdelay为u-boot的启动延时计数值,计数期间内如无用户按键输入干预,那么将执行"bootcmd"配置中的命令。*/
s = bootdelay_process();
if (cli_process_fdt(&s))
cli_secure_boot_cmd(s); /* autoboot_command,该函数在common/autoboot.c中实现 */
autoboot_command(s); /* 进入 uboot 命令行中 */
cli_loop();
panic("No CLI available");
}

十、uboot 代码流程分析---run_main_loop的更多相关文章

  1. 六、uboot 代码流程分析---start.S

    6.1 _start 入口函数 6.1.1 vectors.S (arch\arm\lib) 从上一节可以知道,uboot 的入口函数为 _start .此 函数定义在 vectors.S (arch ...

  2. 八、uboot 代码流程分析---board_init_f

    接着上一节,板子开始做前期初始化工作. 8.1 board_init_f Board_f.c (common) /* 板子初次初始化.boot_flags = 0 */ void board_init ...

  3. 七、uboot 代码流程分析---C环境建立

    7.1 start.S 修改 在上一节中的流程中,发现初始化的过程并没由设置看门狗,也未进行中断屏蔽 如果看门狗不禁用,会导致系统反复重启,因此需要在初始化的时候禁用看门狗:中断屏蔽保证启动过程中不出 ...

  4. 九、uboot 代码流程分析---relloc_code

    执行完 board_init_f 后,重新跳转回 _main 中执行. 9.1 relloc_code 前 9.1.1 gd 设置 在调用board_init_f()完成板卡与全局结构体变量 gd 的 ...

  5. u-boot启动流程分析(2)_板级(board)部分

    转自:http://www.wowotech.net/u-boot/boot_flow_2.html 目录: 1. 前言 2. Generic Board 3. _main 4. global dat ...

  6. [国嵌笔记][030][U-Boot工作流程分析]

    uboot工作流程分析 程序入口 1.打开顶层目录的Makefile,找到目标smdk2440_config的命令中的第三项(smdk2440) 2.进入目录board/samsung/smdk244 ...

  7. imx6 uboot启动流程分析

    参考http://blog.csdn.net/skyflying2012/article/details/25804209 这里以imx6平台为例,分析uboot启动流程对于任何程序,入口函数是在链接 ...

  8. Uboot启动流程分析(三)

    1.前言 在前面的文章Uboot启动流程分析(二)中,链接如下: https://www.cnblogs.com/Cqlismy/p/12002764.html 已经对_main函数的整个大体调用流程 ...

  9. Uboot启动流程分析(二)

    1.前言 在前面的文章Uboot启动流程分析(一)中,链接如下: https://www.cnblogs.com/Cqlismy/p/12000889.html 已经简单地分析了low_level_i ...

随机推荐

  1. [AH2017/HNOI2017]礼物(FFT)

    题目描述 我的室友最近喜欢上了一个可爱的小女生.马上就要到她的生日了,他决定买一对情侣手 环,一个留给自己,一 个送给她.每个手环上各有 n 个装饰物,并且每个装饰物都有一定的亮度.但是在她生日的前一 ...

  2. Shiro中的Remember me设置

    1. 在Spring的相关配置文件中加入如下Remember me管理器配置: <!-- rememberMe管理器 --> <bean id="rememberMeMan ...

  3. TestNg 3.忽略测试

    有些测试本身不想执行,但是删掉显得不合理,需要忽略这个测试用例 package com.course.testng; import org.testng.annotations.Test; publi ...

  4. Elastic 安装篇(1)

    1.Elasticsearch下载安装 https://www.elastic.co/cn/downloads/elasticsearch 解压: 2.安装head https://github.co ...

  5. Luogu P1552 [APIO2012]派遣 主席树

    题目链接 Click Here 这个题好像大多数人用的都是左偏树啊?这里我来贡献一发主席树的解法. 把题目中的问题抽象出来,其实就是询问每一个点的子树中,工资前\(tot_i\)大的点,使它们的和满足 ...

  6. css3: 基本知识记录

    1.transition过渡: 元素从一种样式到另一种样式添加效果: div { transition: width 2s, height 2s, transform 2s; -moz-transit ...

  7. JS_一些小方法总结

    1.js中onclick事件同时调用两个方法 用分号隔开即可,比如 <input type="button" onclick="a();b();" val ...

  8. powershell 定时删除脚本

    powershell  定时删除脚本 $today=Get-Date #"今天是:$today" #昨天 #"昨天是:$($today.AddDays(-1))" ...

  9. 解决Navicat 出错:1130-host . is not allowed to connect to this MySql server,MySQL

    1. 改表法. 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入MySQL后,更改 "mysql" 数据库里的 " ...

  10. laravel 5.4 fopen(): Filename cannot be empty

    1.出错的报错信息(我在用laravel5.4文件上传时候出错的) laravel 5.4 fopen(): Filename cannot be empty 2.解决的方法 在php.ini中修改临 ...