typedef int (init_fnc_t) (void); //int InitFunction() (void);此时表示申明了一个函数名为InitFunction的函数, 函数没有任何的形参,返回值类型为int型。对于 typedef int(init_fnc_t) (void); 就是对一个 int (void)类型的函数类型进行取别名init_fnc_t。 我们可以利用这个别名进行创建这个类型的函数对象。init_fnc_t *MyFunction;这里就是一个函数的指针。
init_fnc_t **init_fnc_ptr;
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,
};
//初始化IRQ/FIQ模式的栈,设置系统时钟、初始化定时器、检查Flash上的环境参数是否有效,初始化串口控制台、检测系统内存映射。
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
hang ();
}
}
参考:
http://blog.163.com/wodegoodfriends@yeah/blog/static/167983845201121893553397/
Uboot移植之board.c中函数指针数组,布布扣,bubuko.com
Uboot移植之board.c中函数指针数组
原文:http://blog.csdn.net/yuesichiu/article/details/21086339