2 学习笔记——主函数void start_armboot (void)的注释
版本号:2010.06 主函数:先找出那些函数是要执行的 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,sizeof (gd_t)); ?????? gd->bd = (bd_t*)((char*)gd - sizeof(bd_t)); ?????? memset (gd->bd,sizeof (bd_t));// 各数据段清零 ? ?????? gd->flags |= GD_FLG_RELOC;//标记代码已经加载到ram中 ? ?????? 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 (); ????????????? } ?????? } ?????? /* armboot_start is defined in the board-specific linkerscript */ ?????? mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN, ???????????????????? CONFIG_SYS_MALLOC_LEN); //初始化malloc的内存空间 //具体的空间位置是(0x33f8 0000 – 0x3 0000)到0x33f8 0000 #ifndefCONFIG_SYS_NO_FLASH ?????? /* configure available FLASH banks */ ?????? display_flash_config (flash_init ());// 初始化flash,并打印信息 #endif /*CONFIG_SYS_NO_FLASH */ #ifdef CONFIG_VFD? VFD显示初始化,本开发板没有配置 #???? ifndef PAGE_SIZE #???? ? define PAGE_SIZE 4096 #???? endif ?????? /* ?????? ?* reserve memory forVFD display (always full pages) ?????? ?*/ ?????? /* bss_end is defined in the board-specific linker script */ ?????? addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); ?????? vfd_setmem (addr); ?????? gd->fb_base = addr; #endif /* CONFIG_VFD */ ? #ifdef CONFIG_LCD? LCD显示初始化,本开发板没有配置 ?????? /* board init may have inited fb_base */ ?????? if (!gd->fb_base) { #??????????? ifndef PAGE_SIZE #??????????? ? define PAGE_SIZE4096 #??????????? endif ????????????? /* ????????????? ?* reserve memoryfor LCD display (always full pages) ????????????? ?*/ ????????????? /* bss_end is defined in the board-specific linker script*/ ????????????? addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE -1); ????????????? lcd_setmem (addr); ????????????? gd->fb_base = addr; ?????? } #endif /* CONFIG_LCD */ ? #ifdefined(CONFIG_CMD_NAND) ?????? puts ("NAND:?"); ?????? nand_init();?????????? /*go init the NAND */NANDFLASH初始化,并打印信息 #endif ? #if defined(CONFIG_CMD_ONENAND) ?????? onenand_init();//拥有norflash接口的nandflash。 #endif ? #ifdefCONFIG_HAS_DATAFLASH ?????? AT91F_DataflashInit(); ?????? dataflash_print_info();// dataflash初始化,并打印信息 #endif ? ?????? /* initialize environment */ ?????? env_relocate ();// 环境变量初始化,具体怎么实现具体函数在commonenv_common.c中 ? #ifdef CONFIG_VFD ?????? /* must do this after the framebuffer is allocated */ ?????? drv_vfd_init(); #endif /* CONFIG_VFD */ #ifdefCONFIG_SERIAL_MULTI ?????? serial_initialize();//串口初始化,本开发板没有配置 #endif ? ?????? /* IP Address */ ?????? gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");//初始化全局变量IP ?????? stdio_init ();?? /* getthe devices list going. *///进入其他设备列表初始化函数 ?????? jumptable_init ();// 初始化/* jump table */,不知为什么, #if defined(CONFIG_API) ?????? /* Initialize API */ ?????? api_init ();// 正对其他开发板板的,功能函数初始化? 本开发板没有配置 #endif ? ?????? console_init_r ();??? /*fully init console as a device */串口第二阶段初始化 //在此次打印 In:??? serial???????????? Out:?? serial???????????? Err:?? serial这个信息 ? #ifdefined(CONFIG_ARCH_MISC_INIT) ?????? /* miscellaneous arch dependent initialisations */ ?????? arch_misc_init ();// 其他杂项外设的初始化? 本开发板没有配置 #endif #ifdefined(CONFIG_MISC_INIT_R) ?????? /* miscellaneous platform dependent initialisations */ ?????? misc_init_r ();//// 其他杂项外设的初始化,依赖平台的? 本开发板没有配置 #endif ? ?????? /* enable exceptions */ ?????? enable_interrupts ();// 中断使能,主要是在汇编语言阶段,关闭中断在此打开中断使能 ? ?????? /* Perform network card initialisation if necessary */ #ifdefCONFIG_DRIVER_TI_EMAC? TI的MAC初始化? 本开发板没有配置 ?????? /* XXX: this needs to be moved to board init */ extern voiddavinci_eth_set_mac_addr (const u_int8_t *addr); ?????? if (getenv ("ethaddr")) { ????????????? uchar enetaddr[6]; ????????????? eth_getenv_enetaddr("ethaddr",enetaddr); ????????????? davinci_eth_set_mac_addr(enetaddr); ?????? } #endif #ifdefined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96) ?????? /* XXX: this needs to be moved to board init */? 本开发板没有配置 ?????? if (getenv ("ethaddr")) { ????????????? uchar enetaddr[6]; ????????????? eth_getenv_enetaddr("ethaddr",enetaddr); ????????????? smc_set_mac_addr(enetaddr); ?????? } #endif /*CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */ ? ?????? /* Initialize from environment */ 从环境变量中初始化 ?????? if ((s = getenv ("loadaddr"))!= NULL) { ????????????? load_addr = simple_strtoul (s,NULL,16); ?????? }//读取环境loadaddr到全局变量load_addr #ifdefined(CONFIG_CMD_NET) ?????? if ((s = getenv ("bootfile")) != NULL) { ????????????? copy_filename (BootFile,s,sizeof (BootFile)); ?????? }//读取环境变量bootfile到全局变量BootFile 128字节 #endif ? #ifdef BOARD_LATE_INIT ?????? board_late_init ();//开发板后期初始化,本开发板没有配置 #endif #ifdef CONFIG_GENERIC_MMC ?????? puts ("MMC:??"); ?????? mmc_initialize (gd->bd);// 一种存储外设,本开发板没有配置 #endif #ifdef CONFIG_BITBANGMII ?????? bb_miiphy_init();网络接口初始化,本开发板没有配置 #endif #ifdefined(CONFIG_CMD_NET) #ifdefined(CONFIG_NET_MULTI) ?????? puts ("Net:??"); #endif ?????? eth_initialize(gd->bd); #ifdefined(CONFIG_RESET_PHY_R) ?????? debug ("Reset Ethernet PHYn"); ?????? reset_phy(); #endif #endif? // 网络接口初始化 ?????? /* main_loop() can return to retry autoboot,if so just run itagain. */ ?????? for (;;) { ????????????? main_loop (); ?????? } ?????? /* NOTREACHED - no way out of command loop except booting */ } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |