]> git.sur5r.net Git - u-boot/blobdiff - arch/mips/cpu/mips32/start.S
MIPS: add support for pre-relocation malloc
[u-boot] / arch / mips / cpu / mips32 / start.S
index f5ebe79564cfe863fa404c2792a15a600955e3aa..36b92cc6874d873070784640bacae0aaa16442dd 100644 (file)
 #define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
 #endif
 
+#ifndef CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SYS_INIT_SP_ADDR        (CONFIG_SYS_SDRAM_BASE + \
+                               CONFIG_SYS_INIT_SP_OFFSET)
+#endif
+
        /*
         * For the moment disable interrupts, mark the kernel mode and
         * set ST0_KX so that the CPU does not spit fire when using
@@ -51,7 +56,7 @@ _start:
         */
        .word CONFIG_SYS_XWAY_EBU_BOOTCFG
        .word 0x0
-#elif defined(CONFIG_QEMU_MALTA)
+#elif defined(CONFIG_MALTA)
        /*
         * Linux expects the Board ID here.
         */
@@ -135,11 +140,34 @@ reset:
 #endif
 
        /* Set up temporary stack */
-       li      sp, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_INIT_SP_OFFSET
+       li      t0, -16
+       li      t1, CONFIG_SYS_INIT_SP_ADDR
+       and     sp, t1, t0              # force 16 byte alignment
+       sub     sp, sp, GD_SIZE         # reserve space for gd
+       and     sp, sp, t0              # force 16 byte alignment
+       move    k0, sp                  # save gd pointer
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       li      t2, CONFIG_SYS_MALLOC_F_LEN
+       sub     sp, sp, t2              # reserve space for early malloc
+       and     sp, sp, t0              # force 16 byte alignment
+#endif
+       move    fp, sp
+
+       /* Clear gd */
+       move    t0, k0
+1:
+       sw      zero, 0(t0)
+       blt     t0, t1, 1b
+        addi   t0, 4
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       addu    t0, k0, GD_MALLOC_BASE  # gd->malloc_base offset
+       sw      sp, 0(t0)
+#endif
 
        la      t9, board_init_f
        jr      t9
-        nop
+        move   ra, zero
 
 /*
  * void relocate_code (addr_sp, gd, addr_moni)
@@ -155,6 +183,7 @@ reset:
        .ent    relocate_code
 relocate_code:
        move    sp, a0                  # set new stack pointer
+       move    fp, sp
 
        move    s0, a1                  # save gd in s0
        move    s2, a2                  # save destination address in s2
@@ -227,10 +256,10 @@ in_ram:
         addi   t1, 8
 
 1:
-       lw      t3, -4(t1)              # t3 <-- relocation info
+       lw      t8, -4(t1)              # t8 <-- relocation info
 
-       sub     t3, 3
-       bnez    t3, 2f                  # skip non R_MIPS_REL32 entries
+       li      t3, 3
+       bne     t8, t3, 2f              # skip non R_MIPS_REL32 entries
         nop
 
        lw      t3, -8(t1)              # t3 <-- location to fix up in FLASH
@@ -260,8 +289,9 @@ in_ram:
         addi   t1, 4
 
        move    a0, s0                  # a0 <-- gd
+       move    a1, s2
        la      t9, board_init_r
        jr      t9
-        move   a1, s2
+        move   ra, zero
 
        .end    relocate_code