调用 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. 覆盖的面积 HDU - 1255 (扫描线, 面积交)

    求n个矩阵面积相交的部分,和求面积并一样,不过这里需要开两个数组保存覆盖一次和覆盖两次以上的次数的部分,还是模板,主要注意点就是pushup部分,如果我已经被两次覆盖,那我的两个数组在这个root点的 ...

  2. 【算法】php计算出丑数

    丑数描述 把只包含因子2,3,5的正整数被称作丑数,比如4,10,12都是丑数,而7,23,111则不是丑数. 判断方法    首先除2,直到不能整除为止,然后除5到不能整除为止,然后除3直到不能整除 ...

  3. springcloud干货之服务注册与发现(Eureka)

    springcloud系列文章的第一篇 springcloud服务注册与发现 使用Eureka实现服务治理 作用:实现服务治理(服务注册与发现) 简介: Spring Cloud Eureka是Spr ...

  4. vue $emit 用法

    1.父组件可以用props传递给子组件. 2.子组件可以利用$emit触发父组件事件. vm.$emit('父组件方法',参数); vm.$on(event,fn); $on监听event事件后运行f ...

  5. JS截取文件后缀名

    let fileName = this.file.name.lastIndexOf(".");//取到文件名开始到最后一个点的长度 let fileNameLength = thi ...

  6. malloc() 和 calloc()有啥区别

    calloc()在动态分配完内存后,自动初始化该内存空间为零(会将所分配的内存空间中的每一位都初始化为零). 而malloc()不初始化,里边数据是随机的垃圾数据. calloc(size_t n, ...

  7. JS事件(四)坐标位置

    1.客户区坐标位置  (相对于客户端视口,而无关浏览器缩放) clientX与clientY:表示事件发生时鼠标在视口的坐标,不包括页面滚动距离,因此不代表鼠标在页面上的位置. 2.页面坐标位置 pa ...

  8. SqlServer查询Excel中的数据

    步骤如下: --1.开启远程查询支持 reconfigure reconfigure --2.链接Excel Microsoft ACE 12.0 OLE DB Provider 读Excel数据(注 ...

  9. M1-SaltStack&Flask-Day4

    1.virtualenv 虚拟环境 2.virtualenv env1 -p= 解释器路径 3. 进入Scripts 执行activate 激活配置 4.执行deactivate 取消激活配置 2.1 ...

  10. nlp知识

    1.词集模型 将每个词的出现与否作为一个特征,不考虑词频.也就是一个词在文本在文本中出现1次和多次特征处理是一样的. 2.词袋模型 与词集相比,会考虑词频 sklearn中 CountVectoriz ...