]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - cpu/mpc5xx/start.S
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / cpu / mpc5xx / start.S
index 0637003ce29916b0fdd8ffd2b83a5a1e2335e41b..0af879e39130577fa757ab065f0acd28f327f472 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <config.h>
 #include <mpc5xx.h>
+#include <timestamp.h>
 #include <version.h>
 
 #define CONFIG_5xx 1           /* needed for Linux kernel header files */
@@ -55,7 +56,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
        START_GOT
        GOT_ENTRY(_GOT2_TABLE_)
        .globl  version_string
 version_string:
        .ascii U_BOOT_VERSION
-       .ascii " (", __DATE__, " - ", __TIME__, ")"
+       .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
        .ascii CONFIG_IDENT_STRING, "\0"
 
        . = EXC_OFF_SYS_RESET
        .globl  _start
 _start:
        mfspr   r3, 638
-       li      r4, CFG_ISB                     /* Set ISB bit */
+       li      r4, CONFIG_SYS_ISB                      /* Set ISB bit */
        or      r3, r3, r4
        mtspr   638, r3
        li      r21, BOOTFLAG_COLD              /* Normal Power-On: Boot from FLASH     */
@@ -121,12 +122,12 @@ boot_warm:
        /* the external flash access on PATI fails if programming the PLL to 40MHz.
         * Copy the PLL programming code to the internal RAM and execute it
         *----------------------------------------------------------------------*/
-       lis     r3, CFG_MONITOR_BASE@h
-       ori     r3, r3, CFG_MONITOR_BASE@l
+       lis     r3, CONFIG_SYS_MONITOR_BASE@h
+       ori     r3, r3, CONFIG_SYS_MONITOR_BASE@l
        addi    r3, r3, pll_prog_code_start - _start + EXC_OFF_SYS_RESET
 
-       lis     r4, CFG_INIT_RAM_ADDR@h
-       ori     r4, r4, CFG_INIT_RAM_ADDR@l
+       lis     r4, CONFIG_SYS_INIT_RAM_ADDR@h
+       ori     r4, r4, CONFIG_SYS_INIT_RAM_ADDR@l
        mtlr    r4
        addis   r5,0,0x0
        ori     r5,r5,((pll_prog_code_end - pll_prog_code_start) >>2)
@@ -144,8 +145,8 @@ boot_warm:
         * Calculate absolute address in FLASH and jump there
         *----------------------------------------------------------------------*/
 
-       lis     r3, CFG_MONITOR_BASE@h
-       ori     r3, r3, CFG_MONITOR_BASE@l
+       lis     r3, CONFIG_SYS_MONITOR_BASE@h
+       ori     r3, r3, CONFIG_SYS_MONITOR_BASE@l
        addi    r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
        mtlr    r3
        blr
@@ -155,9 +156,9 @@ in_flash:
        /* Initialize some SPRs that are hard to access from C                  */
        /*----------------------------------------------------------------------*/
 
-       lis     r3, CFG_IMMR@h                  /* Pass IMMR as arg1 to C routine */
-       lis     r2, CFG_INIT_SP_ADDR@h
-       ori     r1, r2, CFG_INIT_SP_ADDR@l      /* Set up the stack in internal SRAM */
+       lis     r3, CONFIG_SYS_IMMR@h                   /* Pass IMMR as arg1 to C routine */
+       lis     r2, CONFIG_SYS_INIT_SP_ADDR@h
+       ori     r1, r2, CONFIG_SYS_INIT_SP_ADDR@l       /* Set up the stack in internal SRAM */
        /* Note: R0 is still 0 here */
        stwu    r0, -4(r1)                      /* Clear final stack frame so that      */
        stwu    r0, -4(r1)                      /* stack backtraces terminate cleanly   */
@@ -173,8 +174,8 @@ in_flash:
 
        /* Set up debug mode entry */
 
-       lis     r2, CFG_DER@h
-       ori     r2, r2, CFG_DER@l
+       lis     r2, CONFIG_SYS_DER@h
+       ori     r2, r2, CONFIG_SYS_DER@l
        mtspr   DER, r2
 
        /* Let the C-code set up the rest                                       */
@@ -216,28 +217,15 @@ Alignment:
        mfspr   r5,DSISR
        stw     r5,_DSISR(r21)
        addi    r3,r1,STACK_FRAME_OVERHEAD
-       li      r20,MSR_KERNEL
-       rlwimi  r20,r23,0,16,16         /* copy EE bit from saved MSR */
-       lwz     r6,GOT(transfer_to_handler)
-       mtlr    r6
-       blrl
-.L_Alignment:
-       .long   AlignmentException - _start + EXC_OFF_SYS_RESET
-       .long   int_return - _start + EXC_OFF_SYS_RESET
+       EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
 
 /* Program check exception */
        . = 0x700
 ProgramCheck:
        EXCEPTION_PROLOG(SRR0, SRR1)
        addi    r3,r1,STACK_FRAME_OVERHEAD
-       li      r20,MSR_KERNEL
-       rlwimi  r20,r23,0,16,16         /* copy EE bit from saved MSR */
-       lwz     r6,GOT(transfer_to_handler)
-       mtlr    r6
-       blrl
-.L_ProgramCheck:
-       .long   ProgramCheckException - _start + EXC_OFF_SYS_RESET
-       .long   int_return - _start + EXC_OFF_SYS_RESET
+       EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
+               MSR_KERNEL, COPY_EE)
 
        /* FPU on MPC5xx available. We will use it later.
        */
@@ -384,23 +372,24 @@ relocate_code:
        mr      r9,  r4         /* Save copy of global data pointer in SRAM */
        mr      r10, r5         /* Save copy of monitor destination Address in SRAM */
 
+       GET_GOT
        mr      r3,  r5                         /* Destination Address  */
-       lis     r4, CFG_MONITOR_BASE@h          /* Source      Address  */
-       ori     r4, r4, CFG_MONITOR_BASE@l
+       lis     r4, CONFIG_SYS_MONITOR_BASE@h           /* Source      Address  */
+       ori     r4, r4, CONFIG_SYS_MONITOR_BASE@l
        lwz     r5, GOT(__init_end)
        sub     r5, r5, r4
 
        /*
         * Fix GOT pointer:
         *
-        * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
+        * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
         *
         * Offset:
         */
        sub     r15, r10, r4
 
        /* First our own GOT */
-       add     r14, r14, r15
+       add     r12, r12, r15
        /* the the one used by the C code */
        add     r30, r30, r15
 
@@ -445,7 +434,7 @@ relocate_code:
 in_ram:
 
        /*
-        * Relocation Function, r14 point to got2+0x8000
+        * Relocation Function, r12 point to got2+0x8000
         *
         * Adjust got2 pointers, no need to check for 0, this code
         * already puts a few entries in the table.
@@ -457,15 +446,17 @@ in_ram:
        sub     r11,r3,r11
        addi    r3,r3,-4
 1:     lwzu    r0,4(r3)
+       cmpwi   r0,0
+       beq-    2f
        add     r0,r0,r11
        stw     r0,0(r3)
-       bdnz    1b
+2:     bdnz    1b
 
        /*
         * Now adjust the fixups and the pointers to the fixups
         * in case we need to move ourselves again.
         */
-2:     li      r0,__fixup_entries@sectoff@l
+       li      r0,__fixup_entries@sectoff@l
        lwz     r3,GOT(_FIXUP_TABLE_)
        cmpwi   r0,0
        mtctr   r0
@@ -507,6 +498,8 @@ clear_bss:
         */
        .globl  trap_init
 trap_init:
+       mflr    r4                      /* save link register           */
+       GET_GOT
        lwz     r7, GOT(_start)
        lwz     r8, GOT(_end_of_vectors)
 
@@ -514,8 +507,6 @@ trap_init:
 
        cmplw   0, r7, r8
        bgelr                           /* return if r7>=r8 - just in case */
-
-       mflr    r4                      /* save link register           */
 1:
        lwz     r0, 0(r7)
        stw     r0, 0(r9)
@@ -560,36 +551,18 @@ trap_init:
        mtlr    r4                      /* restore link register        */
        blr
 
-       /*
-        * Function: relocate entries for one exception vector
-        */
-trap_reloc:
-       lwz     r0, 0(r7)               /* hdlr ...                     */
-       add     r0, r0, r3              /*  ... += dest_addr            */
-       stw     r0, 0(r7)
-
-       lwz     r0, 4(r7)               /* int_return ...               */
-       add     r0, r0, r3              /*  ... += dest_addr            */
-       stw     r0, 4(r7)
-
-       sync
-       isync
-
-       blr
-
-
 #if defined(CONFIG_PATI)
 /* Program the PLL */
 pll_prog_code_start:
-       lis     r4, (CFG_IMMR + 0x002fc384)@h
-       ori     r4, r4, (CFG_IMMR + 0x002fc384)@l
+       lis     r4, (CONFIG_SYS_IMMR + 0x002fc384)@h
+       ori     r4, r4, (CONFIG_SYS_IMMR + 0x002fc384)@l
        lis     r3, (0x55ccaa33)@h
        ori     r3, r3, (0x55ccaa33)@l
        stw     r3, 0(r4)
-       lis     r4, (CFG_IMMR + 0x002fc284)@h
-       ori     r4, r4, (CFG_IMMR + 0x002fc284)@l
-       lis     r3, CFG_PLPRCR@h
-       ori     r3, r3, CFG_PLPRCR@l
+       lis     r4, (CONFIG_SYS_IMMR + 0x002fc284)@h
+       ori     r4, r4, (CONFIG_SYS_IMMR + 0x002fc284)@l
+       lis     r3, CONFIG_SYS_PLPRCR@h
+       ori     r3, r3, CONFIG_SYS_PLPRCR@l
        stw     r3, 0(r4)
        addis   r3,0,0x0
        ori     r3,r3,0xA000