u-boot-2014.10移植第11天----深入分析代碼(六),uboot2014.10移植
硬體平台:tq2440
開發環境:Ubuntu-3.11
u-boot版本:2014.10
本文允許轉載,請註明出處:http://blog.csdn.net/fulinus
“從relocate_code回到_main中,接下來是main最後一段代碼”也就是arch/arm/lib/crt0.S檔案中:
b relocate_code
here:
//從這裡開始u-boot已經在重定位的地方運行了
/* Set up final (full) environment */
bl c_runtime_cpu_setup /* we still call old routine here */ 但是這裡還需要調用一下重定位之前的代碼。??為什麼呢?難道這個函數值沒有被修改嗎?估計是,rel.dyn段中放著的應該是C函數中用到的一些變數,而彙編中用到的地址沒有改變吧?(有待進一步研究),我們進入c_runtime_cpu_setup函數中去。明天繼續。
ldr r0, =__bss_start /* this is auto-relocated! */
ldr r1, =__bss_end /* this is auto-relocated! */
mov r2, #0x00000000 /* prepare zero to clear BSS */
clbss_l:cmp r0, r1 /* while not at end of BSS */
strlo r2, [r0] /* clear 32-bit BSS word */
addlo r0, r0, #4 /* move to next */
blo clbss_l
bl coloured_LED_init
bl red_led_on
/* call board_init_r(gd_t *id, ulong dest_addr) */
mov r0, r9 /* gd_t */
ldr r1, [r9, #GD_RELOCADDR] /* dest_addr */
/* call board_init_r */
ldr pc, =board_init_r /* this is auto-relocated! */
/* we should not return here. */
#endif
ENDPROC(_main)