aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/cpu/mpc83xx/start.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/cpu/mpc83xx/start.S')
-rw-r--r--arch/powerpc/cpu/mpc83xx/start.S36
1 files changed, 31 insertions, 5 deletions
diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S
index 00016877030..ff312892bc1 100644
--- a/arch/powerpc/cpu/mpc83xx/start.S
+++ b/arch/powerpc/cpu/mpc83xx/start.S
@@ -258,14 +258,40 @@ in_flash:
#endif
/* set up the stack pointer in our newly created
- * cache-ram (r1) */
- lis r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@h
- ori r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@l
+ * cache-ram; use r3 to keep the new SP for now to
+ * avoid overiding the SP it uselessly */
+ lis r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@h
+ ori r3, r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@l
+ /* r4 = end of GD area */
+ addi r4, r3, GENERATED_GBL_DATA_SIZE
+
+ /* Zero GD area */
+ li r0, 0
+1:
+ subi r4, r4, 1
+ stb r0, 0(r4)
+ cmplw r3, r4
+ bne 1b
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+
+#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE
+#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM."
+#endif
+
+ /* r3 = new stack pointer / pre-reloc malloc area */
+ subi r3, r3, CONFIG_SYS_MALLOC_F_LEN
+
+ /* Set pointer to pre-reloc malloc area in GD */
+ stw r3, GD_MALLOC_BASE(r4)
+#endif
li r0, 0 /* Make room for stack frame header and */
- stwu r0, -4(r1) /* clear final stack frame so that */
- stwu r0, -4(r1) /* stack backtraces terminate cleanly */
+ stwu r0, -4(r3) /* clear final stack frame so that */
+ stwu r0, -4(r3) /* stack backtraces terminate cleanly */
+ /* Finally, actually set SP */
+ mr r1, r3
/* let the C-code set up the rest */
/* */