Merge branch 'master' of git://www.denx.de/git/u-boot-dm
[oweals/u-boot.git] / arch / arm / lib / crt0.S
index 4f2a7121c4b5277836805f91950b33e3242d652d..8415f77e1b1e02b5159b3059dd19c572ccb16098 100644 (file)
@@ -85,6 +85,8 @@ ENTRY(_main)
        mov     r0, sp
        bl      board_init_f_alloc_reserve
        mov     sp, r0
+       /* set up gd here, outside any C code */
+       mov     r9, r0
        bl      board_init_f_init_reserve
 
        mov     r0, #0
@@ -134,6 +136,7 @@ here:
        bl      spl_relocate_stack_gd
        cmp     r0, #0
        movne   sp, r0
+       movne   r9, r0
 # endif
        ldr     r0, =__bss_start        /* this is auto-relocated! */
 
@@ -164,8 +167,12 @@ clbss_l:cmp        r0, r1                  /* while not at end of BSS */
        mov     r0, r9                  /* gd_t */
        ldr     r1, [r9, #GD_RELOCADDR] /* dest_addr */
        /* call board_init_r */
+#if defined(CONFIG_SYS_THUMB_BUILD)
+       ldr     lr, =board_init_r       /* this is auto-relocated! */
+       bx      lr
+#else
        ldr     pc, =board_init_r       /* this is auto-relocated! */
-
+#endif
        /* we should not return here. */
 #endif