- void start_armboot (void)
-
{
-
init_fnc_t **init_fnc_ptr;
-
char *s;
-
#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
-
unsigned long addr;
-
#endif
-
-
/* Pointer is writable since we allocated a register for it */
-
gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
-
/* compiler optimization barrier needed for GCC >= 3.4 */
-
__asm__ __volatile__("": : :"memory");
-
-
memset ((void*)gd, 0, sizeof (gd_t));
-
gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
-
memset (gd->bd, 0, sizeof (bd_t));
-
-
gd->flags |= GD_FLG_RELOC;
-
-
monitor_flash_len = _bss_start - _armboot_start;
-
-
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-
if ((*init_fnc_ptr)() != 0) {
-
hang ();
-
}
-
}
首先定义了两个全局变量,然后执行一个for循环,进行相应的初始化,
- for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
- if ((*init_fnc_ptr)() != 0) {
- hang ();
- }
- }
来看下下init_sequence数组都执行了那些函数:
- 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,
-
};
上面都有注释,就不解释了,值得一提的是,在display _banner函数中,可以添加一些打印信息。
还有一个技巧就是这个数组里面的最后一个元素定义为NULL,用来给for循环使用,来判断是否所有的函数都执行完毕。
执行完这些函数之后,又执行了一些函数,最后执行了一个死循环
- /* main_loop() can return to retry autoboot, if so just run it again. */
-
for (;;) {
-
main_loop ();
-
}
-
-
/* NOTREACHED - no way out of command loop except booting */
-
}
简单分析到这,具体的源代码我也没有跟踪,仅仅看了个框架。
阅读(1141) | 评论(0) | 转发(3) |