R> env_init, /*初始化环境变量---common/cmd_flash.c */ init_baudrate, /*初始化波特率设置—lib_arm/board.c */ serial_init, /* 串口通讯设置--- cpu/arm920t/serial.c */ console_init_f, /* 控制台初始化阶段1—common/console.c*/ display_banner, /* 打印u-boot信息---lib_arm/board.c */ dram_init, /* 配置可用的RAM—borad/smdk2442/smdk2442.c */ display_dram_config, /*显示RAM的配置大小---lib_arm/board.c */ #if defined(CONFIG_VCMA9) || defined (CONFIG_CMC_PU2) checkboard, #endif NULL, }; 使用以下语句调用执行 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { hang (); } } start_armboot的主要过程如下: void start_armboot (void) { DECLARE_GLOBAL_DATA_PTR; ulong size; gd_t gd_data; bd_t bd_data; init_fnc_t **init_fnc_ptr; char *s; #if defined(CONFIG_VFD) unsigned long addr; #endif /* Pointer is writable since we allocated a register for it */ gd = &gd_data; memset ((void *)gd, 0, sizeof (gd_t)); gd->bd = &bd_data; memset (gd->bd, 0, sizeof (bd_t)); monitor_flash_len = _armboot_end_data - _armboot_start; /*** 调用执行init_sequence数组按顺序执行初始化 ***/ for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { hang (); } }
#if 0 /**************** 配置可用的flash单元 *************/ size = flash_init (); //初始化flash display_flash_config (size); //显示flash的大小 /******** _arm_boot在armboot.lds链接脚本中定义 ********/ #endif #ifdef CONFIG_VFD # ifndef PAGE_SIZE # define PAGE_SIZE 4096 # endif /*********** 为VFD显示预留内存(整个页面) **********/ /******** armboot_real_end在board-specific链接脚本中定义********/ addr = (_armboot_real_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); size = vfd_setmem (addr); gd->fb_base = addr; /******* 进入下一个界面 ********/ addr += size; addr = (addr + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); mem_malloc_init (addr); #else /******** armboot_real_end 在board-specific链接脚本中定义 *******/ mem_malloc_init (_armboot_real_end); #endif /* CONFIG_VFD */ #if (CONFIG_COMMANDS & CFG_CMD_NAND) puts ("NAND:"); nand_init(); /* NAND初始化 */ #endif #ifdef CONFIG_HAS_DATAFLASH AT91F_DataflashInit(); dataflash_print_info(); #endif /********* 初始化环境 **********/ env_relocate (); /*********** 配置环境变量,重新定位 **********/ #ifdef CONFIG_VFD /* must do this after the framebuffer is allocated */ drv_vfd_init(); #endif /* 从环境中得到IP地址 */ bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr"); /*以太网接口MAC地址*/ { int i; ulong reg; char *s, *e; uchar tmp[64]; i = getenv_r ("ethaddr", tmp, sizeof (tmp)); s = (i > 0) ? tmp : NULL; for (reg = 0; reg < 6; ++reg) { bd_data.bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0; if (s) s = (*e) ? e + 1 : e; } } devices_init (); /* 获取列表中的设备. */ jumptable_init (); console_init_r (); /*完整地初始化控制台设备*/ #if defined(CONFIG_MISC_INIT_R) /* 其他平台由初始化决定*/ misc_init_r (); #endif /* 启用异常处理 */ enable_interrupts (); #ifdef CONFIG_DRIVER_CS8900 cs8900_get_enetaddr (gd->bd->bi_enetaddr); #endif #ifdef CONFIG_DRIVER_LAN91C96 if (getenv ("ethaddr")) { smc_set_mac_addr(gd->bd->bi_enetaddr); } /* eth_hw_init(); */ #endif /* CONFIG_DRIVER_LAN91C96 */ /* 通过环境变量初始化*/ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); } #if (CONFIG_COMMANDS & CFG_CMD_NET) if ((s = getenv ("bootfile")) != NULL) { copy_filename (BootFile, s, sizeof (BootFile)); } #endif /* CFG_CMD_NET */ #ifdef BOARD_POST_INIT board_post_init (); #endif /* main_loop() 总是试图自动启动,循环不断执行*/ for (;;) { main_loop (); /*主循环函数处理执行用户命令—common/main.c } /* NOTREACHED - no way out of command loop except booting */
|