powerpc: mpc85xx: Enable pre-relocation malloc for MPC85xx
authormario.six@gdsys.cc <mario.six@gdsys.cc>
Tue, 5 Apr 2016 13:05:37 +0000 (15:05 +0200)
committerYork Sun <york.sun@nxp.com>
Fri, 8 Apr 2016 22:42:10 +0000 (15:42 -0700)
To enable DM on MPC85xx, we need pre-relocation malloc, which is
implemented in this patch.

We also make sure that the IVORs are always 4-aligned on e500 to prevent
alignment exceptions caused by code changes in start.S.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
Cc: York Sun <york.sun@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: York Sun <york.sun@nxp.com>
arch/powerpc/cpu/mpc85xx/cpu_init_early.c
arch/powerpc/cpu/mpc85xx/start.S
include/ppc_asm.tmpl

index 235a635c22f9d42456523e6f42780c15428353b2..aa519b03fe3fd31e2349b997083e38dfea28fdb7 100644 (file)
@@ -82,7 +82,6 @@ void setup_ifc(void)
 void cpu_init_early_f(void *fdt)
 {
        u32 mas0, mas1, mas2, mas3, mas7;
-       int i;
 #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549
        ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 #endif
@@ -90,17 +89,13 @@ void cpu_init_early_f(void *fdt)
        ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
        u32  *dst, *src;
        void (*setup_ifc_sram)(void);
+       int i;
 #endif
 
        /* 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
-        *   we don't use memset so we can share this code with NAND_SPL
-        */
-       for (i = 0; i < sizeof(gd_t); i++)
-               ((char *)gd)[i] = 0;
+       /* gd area was zeroed during startup */
 
 #ifdef CONFIG_QEMU_E500
        /*
index d867e2a767a4f5b91c5e70211d13dd943c136957..82a151a0d0e14726e2a0578a5a6f0028a464409e 100644 (file)
@@ -1152,6 +1152,36 @@ _start_cont:
        /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
        lis     r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
        ori     r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */
+
+#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
+
+       /* Leave 16+ byte for back chain termination and NULL return address */
+       subi    r3,r3,((CONFIG_SYS_MALLOC_F_LEN+16+15)&~0xf)
+#endif
+
+       /* End of RAM */
+       lis     r4,(CONFIG_SYS_INIT_RAM_ADDR)@h
+       ori     r4,r4,(CONFIG_SYS_INIT_RAM_SIZE)@l
+
+       li      r0,0
+
+1:     subi    r4,r4,4
+       stw     r0,0(r4)
+       cmplw   r4,r3
+       bne     1b
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       lis     r4,(CONFIG_SYS_INIT_RAM_ADDR)@h
+       ori     r4,r4,(CONFIG_SYS_GBL_DATA_OFFSET)@l
+
+       addi    r3,r3,16        /* Pre-relocation malloc area */
+       stw     r3,GD_MALLOC_BASE(r4)
+       subi    r3,r3,16
+#endif
        li      r0,0
        stw     r0,0(r3)        /* Terminate Back Chain */
        stw     r0,+4(r3)       /* NULL return address. */
index ba166ebdd4d62a16ae38234bba269a6e45019b9e..379c493919bf27f42b4835a6f9b2961ac1ab7da3 100644 (file)
        b       transfer_to_handler
 
 #define STD_EXCEPTION(n, label, hdlr)                          \
+.align 4;                                                      \
 label:                                                         \
        EXCEPTION_PROLOG(SRR0, SRR1);                           \
        addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
        EXC_XFER_TEMPLATE(n, label, hdlr, MSR_KERNEL, NOCOPY)   \
 
 #define CRIT_EXCEPTION(n, label, hdlr)                         \
+.align 4;                                                      \
 label:                                                         \
        EXCEPTION_PROLOG(CSRR0, CSRR1);                         \
        addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
@@ -276,6 +278,7 @@ label:                                                              \
        MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE), NOCOPY)           \
 
 #define MCK_EXCEPTION(n, label, hdlr)                          \
+.align 4;                                                      \
 label:                                                         \
        EXCEPTION_PROLOG(MCSRR0, MCSRR1);                       \
        addi    r3,r1,STACK_FRAME_OVERHEAD;                     \