############board.c在文件夹lib_arm中##################
gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
为全局变量gd_t结构体指定起始地址,变量gd在include/asm-arm/global_data.h中定义:
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8")
memset ((void*)gd, 0, sizeof (gd_t));
//清空gd_t结构体
gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
//为gd_bd指定起始地址
memset (gd->bd, 0, sizeof (bd_t));
//清空bd_t结构体
gd->flags |= GD_FLG_RELOC;
//gd->flags 标记程序已经运行在ram中
monitor_flash_len = _bss_start - _armboot_start;
//计算程序的大小
GD_FLG_RELOC在include/asm-arm/global_data.h中定义:
#define GD_FLG_RELOC 0x00001 /* Code was relocated to RAM */
bd_t结构体在include/asm-arm/u-boot.h中定义
/*************初始化操作序列*************/
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
hang ();
}
}
其中init_sequence是一个存放函数指针的数组,里面存放了一系列进行初始化操作的函数名,然后通过for循环一次调用这些函数。此数组就在就定义在lib_arm/board.c中,定义如下:
init_fnc_t *init_sequence[] = {
#if defined(CONFIG_ARCH_CPU_INIT)
arch_cpu_init,
/* basic arch cpu dependent setup */
#endif
board_init,
/* basic board dependent setup */
#if defined(CONFIG_USE_IRQ)
interrupt_init,
/* set up exceptions */
#endif
timer_init,
/* initialize timer */
#ifdef CONFIG_FSL_ESDHC
get_clocks,
#endif
env_init,
/* initialize environment */
init_baudrate,
/* initialze baudrate settings */
serial_init,
/* serial communications setup */
console_init_f,
/* stage 1 init of console */
display_banner,
/* say that we are here */
#if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo,
/* display cpu info (and speed) */
#endif
#if defined(CONFIG_DISPLAY_BOARDINFO)
checkboard,
/* display board info */
#endif
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
init_func_i2c,
#endif
dram_init,
/* configure available RAM banks */
#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
arm_pci_init,
#endif
display_dram_config,
NULL,
};
依次说明各个函数的作用:
/************************ arch_cpu_init *************************************/
这个函数在cpu/arm_cortexa8/s5pc1xx/clock_info.c中定义
int arch_cpu_init(void)
{
s5pc1xx_cpu_id = readl(S5PC1XX_PRO_ID);