]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
powerpc: mpc83xx: Enable pre-relocation malloc
authormario.six@gdsys.cc <mario.six@gdsys.cc>
Tue, 17 Jan 2017 07:33:48 +0000 (08:33 +0100)
committerYork Sun <york.sun@nxp.com>
Wed, 1 Feb 2017 01:50:35 +0000 (17:50 -0800)
To enable DM on MPC83xx, we need pre-relocation malloc, which is
implemented in this patch.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
[York S: Fixed compiling warning for unused variable 'i']
Reviewed-by: York Sun <york.sun@nxp.com>
arch/powerpc/cpu/mpc83xx/cpu_init.c
arch/powerpc/cpu/mpc83xx/spl_minimal.c
arch/powerpc/cpu/mpc83xx/start.S

index f911275b25f92e7c698dfc4c9238d816065a480a..3a0916bdbf55d4d945a82427d998b8597a977bc1 100644 (file)
@@ -205,8 +205,7 @@ void cpu_init_f (volatile immap_t * im)
        /* Pointer is writable since we allocated a register for it */
        gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
 
-       /* Clear initial global data */
-       memset ((void *) gd, 0, sizeof (gd_t));
+       /* global data region was cleared in start.S */
 
        /* system performance tweaking */
        clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val);
index 845861eea7facf9ffba9ea2e1ffe140e2715fe29..1c65e4cb78ddd53f7c41fb697542d056c091699d 100644 (file)
@@ -18,14 +18,10 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 void cpu_init_f (volatile immap_t * im)
 {
-       int i;
-
        /* Pointer is writable since we allocated a register for it */
        gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
 
-       /* Clear initial global data */
-       for (i = 0; i < sizeof(gd_t); i++)
-               ((char *)gd)[i] = 0;
+       /* global data region was cleared in start.S */
 
        /* system performance tweaking */
 
index c366f615e7965c071e475aa5da3bee8b9a928616..ff312892bc13b5a4af3344523f193ea397c1e972 100644 (file)
@@ -263,6 +263,29 @@ in_flash:
        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(r3)      /* clear final stack frame so that      */
        stwu    r0, -4(r3)      /* stack backtraces terminate cleanly   */