/********************************************************************************* @author Maoxiao Hu* @version V1.0.0* @date Jan-2015******************************************************************************* < COPYRIGHT 2015 ISE of SHANDONG UNIVERSITY >********************************************************************************/based on u-boot-2014.10。源代码以红色标示,其它均为添加的注释。
分析一下 crt0.S 文件开头的一段。crt0.S 位于u-boot-2014.10/arch/arm/lib/crt0.S。正如 crt0.S 文件开头所注释的一样:“1. Set up initial environment for calling board_init_f().This environment only provides a stack and a place to store the GD (‘global data’) structure, both located in some readily available RAM (SRAM, locked cache...). In this context, VARIABLE global data, initialized or not (BSS), are UNAVAILABLE; only CONSTANT initialized data are available.”最开始先为调用 board_init_f() 设定初始化条件。这个初始化条件就是:设定栈首地址,将栈往下移 GD_SIZE 个大小,然后将刚才经过的这段 SRAM 从头清空(写0)。话不多说看代码:ENTRY(_main)/* * Set up initial C runtime environment and call board_init_f(0). */