之前文章简单分析了 uboot启动流程的开始,从链接脚本文件 u-boot.lds 中,我们已经知道了入口点是 arch/arm/lib/vectors.S 文件中的 _start函数。
_start函数:调用了 reset 函数,reset 函数内部:最终调用了 save_boot_params_ret 函数。
save_boot_params_ret 函数:
① 将处理器设置为SVC模式,并且关闭FIQ和IRQ.
② 设置中断向量。
③ 初始化CP15 (cpu_init_cp15), 调用了 cpu_init_crit 函数。
其中, cpu_init_crit 函数 调用了函数 lowlevel_init函数。
本文继续简单分析 lowlevel_init函数(即cpu_init_crit 函数 所调用的函数)做了什么?
本文继上一篇文章的分析,地址如下:
uboot启动流程涉及reset函数_凌肖战的博客-CSDN博客
lowlevel_init 函数在文件 arch/arm/cpu/armv7/lowlevel_init.S 中定义,内容如下:
- 18 ENTRY(lowlevel_init)
- 19 /*
- 20 * Setup a temporary stack. Global data is not available yet.
- 21 */
- 22 ldr sp, =CONFIG_SYS_INIT_SP_ADDR
- 23 bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
- 24 #ifdef CONFIG_SPL_DM
- 25 mov r9, #0
- 26 #else
- 27 /*
- 28 * Set up global data for boards that still need it. This will be
- 29 * removed soon.
- 30 */
- 31 #ifdef CONFIG_SPL_BUILD
- 32 ldr r9, =gdata
- 33 #else
- 34 sub sp, sp, #GD_SIZE
- 35 bic sp, sp, #7
- 36 mov r9, sp
- 37 #endif
- 38 #endif
- 39 /*
- 40 * Save the old lr(passed in ip) and the current lr to stack
- 41 */
- 42 push {ip, lr}
- 43
- 44 /*
- 45 * Call the very early init function. This should do only the
- 46 * absolute bare minimum to get started. It should not:
- 47 *
- 48 * - set up DRAM
- 49 * - use global_data
- 50 * - clear BSS
- 51 * - try to start a console
- 52 *
- 53 * For boards with SPL this should be empty since SPL can do all
- 54 * of this init in the SPL board_init_f() function which is
- 55 * called immediately after this.
- 56 */
- 57 bl s_init
- 58 pop {ip, pc}
- 59 ENDPROC(lowlevel_init)
- 234 #define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
- 235 #define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
- 236
- 237 #define CONFIG_SYS_INIT_SP_OFFSET \
- 238 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
- 239 #define CONFIG_SYS_INIT_SP_ADDR \
- 240 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
- 71 #define IRAM_BASE_ADDR 0x00900000
- ......
- 408 #if !(defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || \
- 409 defined(CONFIG_MX6SLL) || defined(CONFIG_MX6SL))
- 410 #define IRAM_SIZE 0x00040000
- 411 #else
- 412 #define IRAM_SIZE 0x00020000
- 413 #endif
CONFIG_SYS_INIT_RAM_ADDR = IRAM_BASE_ADDR = 0x00900000 。CONFIG_SYS_INIT_RAM_SIZE = 0x00020000 =128KB 。
- 9 #define GENERATED_GBL_DATA_SIZE 256
- 10 #define GENERATED_BD_INFO_SIZE 80
- 11 #define GD_SIZE 248
- CONFIG_SYS_INIT_SP_OFFSET = 0x00020000 – 256 = 0x1FF00
- CONFIG_SYS_INIT_SP_ADDR = 0x00900000 + 0X1FF00 = 0X0091FF00


lowlevel_init.S 文件中的 lowlevel_init 函数:
下一篇文章分析:
lowlevel_init函数调用的函数:s_init 函数