u-boot bl_main分析
Posted idyllcheung
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了u-boot bl_main分析相关的知识,希望对你有一定的参考价值。
ldr r0, =(CONFIG_SYS_INIT_SP_ADDR):
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \
CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
#define CONFIG_SYS_INIT_RAM_ADDR 0x20000
#define CONFIG_SYS_INIT_RAM_SIZE 0x30000
GENERATED_GBL_DATA_SIZE宏定义,它是由DEFINE(GENERATED_GBL_DATA_SIZE,(sizeof(struct global_data) + 15) & ~15);获得的,也就是相当于#define GENERATED_GBL_DATA_SIZE ((sizeof(struct global_data) + 15) & ~15)。
bl board_init_f_alloc_reserve (参数CONFIG_SYS_INIT_SP_ADDR):
ulong board_init_f_alloc_reserve(ulong top)
/* Reserve early malloc arena */
#if CONFIG_VAL(SYS_MALLOC_F_LEN) #0x800
top -= CONFIG_VAL(SYS_MALLOC_F_LEN); # -0x800
#endif
/* LAST : reserve GD (rounded up to a multiple of 16 bytes) */
top = rounddown(top-sizeof(struct global_data), 16); # -global_data
return top;
board_init_f_init_reserve (参数top):
void board_init_f_init_reserve(ulong base)
struct global_data *gd_ptr;
/*
* clear GD entirely and set it up.
* Use gd_ptr, as gd may not be properly set yet.
*/
gd_ptr = (struct global_data *)base;
/* zero the area */
memset(gd_ptr, ‘\0‘, sizeof(*gd));
/* set GD unless architecture did it already */
#if !defined(CONFIG_ARM)
arch_setup_gd(gd_ptr);
#endif
/* next alloc will be higher by one GD plus 16-byte alignment */
base += roundup(sizeof(struct global_data), 16);
/*
* record early malloc arena start.
* Use gd as it is now properly set for all architectures.
*/
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
/* go down one ‘early malloc arena‘ */
gd->malloc_base = base;
/* next alloc will be higher by one ‘early malloc arena‘ size */
base += CONFIG_VAL(SYS_MALLOC_F_LEN);
#endif
mov r0, #0
bl board_init_f
以board_init_f和board_init_r两个板级的初始化接口为例,u-boot分别在common/board_f.c和common/board_r.c两个文件中提供了通用实现。查看common/Makefile可知:
ifndef CONFIG_SPL_BUILD
# # boards
obj-y += board_f.o
obj-y += board_r.o
endif # !CONFIG_SPL_BUILD
以上是关于u-boot bl_main分析的主要内容,如果未能解决你的问题,请参考以下文章