Skip to contentSkip to conversation

No GOT in IRQ and use r12 as GOT ptr

PATCH New Joakim Tjernlund 2 participants 16 messages Dec 30, 2009 – Jan 26, 2010

lore
Share & tools
lore
#0 lore raw

cover No GOT in IRQ and use r12 as GOT ptr

This series removes the needs to access the GOT in IRQ handlers, then switches GOT PTR in start.S asm to use r12 instead of r14. This leads up to the removal of -ffixed-r14 gcc option for ppc

This is a resend since the it seems like the series was lost

Joakim Tjernlund (3):
ppc: Loose GOT access in IRQ
ppc: Use r12 instead of r14 as GOT pointer.
ppc: remove -ffixed-r14 gcc option.
ppc: Update README about the new GOT ptr.

 cpu/74xx_7xx/config.mk |    2 +-
 cpu/74xx_7xx/start.S   |   47 +++++++---------------------------------
 cpu/mpc512x/config.mk  |    2 +-
 cpu/mpc512x/start.S    |   46 +++++++--------------------------------
 cpu/mpc5xx/config.mk   |    2 +-
 cpu/mpc5xx/start.S     |   48 +++++++----------------------------------
 cpu/mpc5xxx/config.mk  |    2 +-
 cpu/mpc5xxx/start.S    |   46 +++++++--------------------------------
 cpu/mpc8220/config.mk  |    2 +-
 cpu/mpc8220/start.S    |   46 +++++++--------------------------------
 cpu/mpc824x/config.mk  |    2 +-
 cpu/mpc824x/start.S    |   44 +++++++------------------------------
 cpu/mpc8260/config.mk  |    2 +-
 cpu/mpc8260/start.S    |   50 ++++++++++---------------------------------
 cpu/mpc83xx/config.mk  |    2 +-
 cpu/mpc83xx/start.S    |   45 +++++++-------------------------------
 cpu/mpc85xx/config.mk  |    2 +-
 cpu/mpc85xx/start.S    |   44 +++++++------------------------------
 cpu/mpc86xx/config.mk  |    2 +-
 cpu/mpc86xx/start.S    |   47 +++++++---------------------------------
 cpu/mpc8xx/config.mk   |    2 +-
 cpu/mpc8xx/start.S     |   47 +++++++---------------------------------
 cpu/ppc4xx/config.mk   |    2 +-
 cpu/ppc4xx/start.S     |   44 +++++++------------------------------
 include/ppc_asm.tmpl   |   55 ++++++++++++++++++++++-------------------------
 lib_ppc/Makefile       |    1 +
 lib_ppc/reloc.S        |   49 ++++++++++++++++++++++++++++++++++++++++++
 README                 |    4 +++-
 28 files changed, 202 insertions(+), 485 deletions(-)
 create mode 100644 lib_ppc/reloc.S
#1 lore raw

PATCH 1/4 ppc: Loose GOT access in IRQ

Using the GOT in IRQ handlers requires r14 to be -ffixed-r14. Avoid this by relocatate transfer_to_handler too. This will allow to free up r14 later on.

---
 cpu/74xx_7xx/start.S |   36 +++---------------------------------
 cpu/mpc512x/start.S  |   35 +++--------------------------------
 cpu/mpc5xx/start.S   |   37 +++----------------------------------
 cpu/mpc5xxx/start.S  |   35 +++--------------------------------
 cpu/mpc8220/start.S  |   35 +++--------------------------------
 cpu/mpc824x/start.S  |   33 +++------------------------------
 cpu/mpc8260/start.S  |   35 +++--------------------------------
 cpu/mpc83xx/start.S  |   34 +++-------------------------------
 cpu/mpc85xx/start.S  |   33 +++------------------------------
 cpu/mpc86xx/start.S  |   36 +++---------------------------------
 cpu/mpc8xx/start.S   |   36 +++---------------------------------
 cpu/ppc4xx/start.S   |   33 +++------------------------------
 include/ppc_asm.tmpl |   47 ++++++++++++++++++++++-------------------------
 lib_ppc/Makefile     |    1 +
 lib_ppc/reloc.S      |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 108 insertions(+), 407 deletions(-)
 create mode 100644 lib_ppc/reloc.S
cpu/74xx_7xx/start.S +3 -33
index 23381a3..efcd95f 100644
@@ -132,28 +132,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)
 
 	/* No FPU on MPC8xx.  This exception is not supposed to happen.
 	*/
@@ -837,23 +824,6 @@ 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
-
 #ifdef CONFIG_SYS_INIT_RAM_LOCK
 lock_ram_in_cache:
 	/* Allocate Initial RAM in data cache.
cpu/mpc512x/start.S +3 -32
index 4edc8e9..46c5efa 100644
@@ -127,30 +127,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 /* Floating Point Unit unavailable exception */
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
@@ -723,17 +708,3 @@ 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)
-
-	blr
cpu/mpc5xx/start.S +3 -34
index 85ea7a8..be980a1 100644
@@ -217,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.
 	*/
@@ -563,24 +550,6 @@ 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:
cpu/mpc5xxx/start.S +3 -32
index eb42939..075a7dd 100644
@@ -215,30 +215,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -797,17 +782,3 @@ 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)
-
-	blr
cpu/mpc8220/start.S +3 -32
index af9472d..5218c85 100644
@@ -176,30 +176,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 */
-	rlwimi	r20,r23,0,25,25	    /* copy IP 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 */
-	rlwimi	r20,r23,0,25,25	    /* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -762,17 +747,3 @@ 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)
-
-	blr
cpu/mpc824x/start.S +3 -30
index 750457b..7f40648 100644
@@ -227,28 +227,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 */
 	. = EXC_OFF_PROGRAM
 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)
 
 	/* No FPU on MPC8xx. This exception is not supposed to happen.
 	*/
@@ -695,20 +682,6 @@ 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)
-
-	blr
-
 	/* Setup the BAT registers.
 	 */
 setup_bats:
cpu/mpc8260/start.S +3 -32
index edb95e6..7d80af5 100644
@@ -286,30 +286,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -1033,17 +1018,3 @@ 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)
-
-	blr
cpu/mpc83xx/start.S +3 -31
index ee4b862..5a50b09 100644
@@ -338,30 +338,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -1086,19 +1071,6 @@ 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)
-
-	blr
 #endif /* !CONFIG_NAND_SPL */
 
 #ifdef CONFIG_SYS_INIT_RAM_LOCK
cpu/mpc85xx/start.S +3 -30
index 6a86528..6fafbb7 100644
@@ -409,28 +409,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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
 
 /* Program check exception */
 	. = 0x0700
 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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
+		MSR_KERNEL, COPY_EE)
 
 	/* No FPU on MPC85xx.  This exception is not supposed to happen.
 	*/
@@ -1083,20 +1070,6 @@ 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)
-
-	blr
-
 .globl unlock_ram_in_cache
 unlock_ram_in_cache:
 	/* invalidate the INIT_RAM section */
cpu/mpc86xx/start.S +3 -33
index e65f1c0..eaa2657 100644
@@ -121,28 +121,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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -848,23 +835,6 @@ 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
-
 .globl enable_ext_addr
 enable_ext_addr:
 	mfspr	r0, HID0
cpu/mpc8xx/start.S +3 -33
index e84326e..24e9053 100644
@@ -231,28 +231,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)
 
 	/* No FPU on MPC8xx.  This exception is not supposed to happen.
 	*/
@@ -694,20 +681,3 @@ 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
cpu/ppc4xx/start.S +3 -30
index 46f65aa..2eb21fa 100644
@@ -574,28 +574,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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
+		MSR_KERNEL, COPY_EE)
 
 #ifdef CONFIG_440
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
@@ -1742,20 +1729,6 @@ __440_msr_continue:
 	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)
-
-	blr
-
 #if defined(CONFIG_440)
 /*----------------------------------------------------------------------------+
 | dcbz_area.
include/ppc_asm.tmpl +22 -25

68 lines not on this page · raw message

lib_ppc/Makefile +1 -0
index 399b41e..3e209d0 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)lib$(ARCH).a
 SOBJS-y	+= ppccache.o
 SOBJS-y	+= ppcstring.o
 SOBJS-y	+= ticks.o
+SOBJS-y	+= reloc.o
 
 COBJS-y	+= bat_rw.o
 COBJS-y	+= board.o
lib_ppc/reloc.S new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#2 lore raw

PATCH 2/4 ppc: Use r12 instead of r14 as GOT pointer.

r14 is not supposed to be clobbered by functions. Switch to r12 and call GET_GOT when needed. This will allow u-boot to loose the -ffixed-r14 gcc option.

---
 cpu/74xx_7xx/start.S |   11 ++++++-----
 cpu/mpc512x/start.S  |   11 ++++++-----
 cpu/mpc5xx/start.S   |   11 ++++++-----
 cpu/mpc5xxx/start.S  |   11 ++++++-----
 cpu/mpc8220/start.S  |   11 ++++++-----
 cpu/mpc824x/start.S  |   11 ++++++-----
 cpu/mpc8260/start.S  |   15 +++++++++------
 cpu/mpc83xx/start.S  |   11 ++++++-----
 cpu/mpc85xx/start.S  |   11 ++++++-----
 cpu/mpc86xx/start.S  |   11 ++++++-----
 cpu/mpc8xx/start.S   |   11 ++++++-----
 cpu/ppc4xx/start.S   |   11 ++++++-----
 include/ppc_asm.tmpl |    8 ++++----
 13 files changed, 79 insertions(+), 65 deletions(-)
cpu/74xx_7xx/start.S +6 -5
index efcd95f..88fdf88 100644
@@ -63,7 +63,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_)
@@ -599,6 +599,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -616,7 +617,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -691,7 +692,7 @@ in_ram:
 	bl	board_init_ecc
 #endif
 	/*
-	 * 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.
@@ -765,6 +766,8 @@ in_ram:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -772,8 +775,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)
cpu/mpc512x/start.S +6 -5
index 46c5efa..d26b617 100644
@@ -65,7 +65,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_)
@@ -486,6 +486,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer */
 	mr	r10, r5		/* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address */
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address */
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -504,7 +505,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -584,7 +585,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.
@@ -648,6 +649,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)
 
@@ -655,8 +658,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)
cpu/mpc5xx/start.S +6 -5
index be980a1..0af879e 100644
@@ -56,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_)
@@ -372,6 +372,7 @@ 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, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -388,7 +389,7 @@ relocate_code:
 	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
 
@@ -433,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.
@@ -497,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)
 
@@ -504,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)
cpu/mpc5xxx/start.S +6 -5
index 075a7dd..d499da5 100644
@@ -56,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_)
@@ -567,6 +567,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -584,7 +585,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -657,7 +658,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.
@@ -722,6 +723,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)
 
@@ -729,8 +732,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)
cpu/mpc8220/start.S +6 -5
index 5218c85..e28999d 100644
@@ -55,7 +55,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_)
@@ -532,6 +532,7 @@ relocate_code:
 	mr	r9,  r4	    /* Save copy of Global Data pointer */
 	mr	r10, r5	    /* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5	    /* Destination Address		*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h	/* Source Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -549,7 +550,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -622,7 +623,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.
@@ -687,6 +688,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)
 
@@ -694,8 +697,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)
cpu/mpc824x/start.S +6 -5
index 7f40648..f3f595a 100644
@@ -63,7 +63,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_)
@@ -462,6 +462,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 #ifdef CONFIG_SYS_RAMBOOT
 	lis	r4, CONFIG_SYS_SDRAM_BASE at h		/* Source      Address	*/
@@ -484,7 +485,7 @@ relocate_code:
 	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
 
@@ -564,7 +565,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.
@@ -629,6 +630,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)
 
@@ -636,8 +639,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)
cpu/mpc8260/start.S +9 -6
index 7d80af5..1fc70bc 100644
@@ -56,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_)
@@ -650,7 +650,9 @@ init_debug:
 	/* RAM should now be operational */
 
 #define VEC_WRD_CNT	((_end_of_vectors - _start + EXC_OFF_SYS_RESET) / 4)
-
+	mflr	r3
+	GET_GOT
+	mtlr	r3
 	lwz	r3, GOT(_end_of_vectors)
 	rlwinm	r4, r3, 0, 18, 31	/* _end_of_vectors & 0x3FFF	*/
 	lis	r5, VEC_WRD_CNT at h
@@ -792,6 +794,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -809,7 +812,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -882,7 +885,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.
@@ -958,6 +961,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)
 
@@ -965,8 +970,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)
cpu/mpc83xx/start.S +6 -5
index 5a50b09..68bb620 100644
@@ -65,7 +65,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_)
@@ -830,6 +830,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer */
 	mr	r10, r5		/* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address */
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address */
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -848,7 +849,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -930,7 +931,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.
@@ -1010,6 +1011,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)
 
@@ -1017,8 +1020,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)
cpu/mpc85xx/start.S +6 -5
index 6fafbb7..79306e2 100644
@@ -51,7 +51,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_)
@@ -865,6 +865,7 @@ relocate_code:
 	mr	r9,r4		/* Save copy of Init Data pointer	*/
 	mr	r10,r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,r5				/* Destination Address	*/
 	lis	r4,CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4,r4,CONFIG_SYS_MONITOR_BASE at l
@@ -882,7 +883,7 @@ relocate_code:
 	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
 
@@ -952,7 +953,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.
@@ -1018,6 +1019,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7,GOT(_start_of_vectors)
 	lwz	r8,GOT(_end_of_vectors)
 
@@ -1025,8 +1028,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)
cpu/mpc86xx/start.S +6 -5
index eaa2657..ed1e4ca 100644
@@ -52,7 +52,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_)
@@ -630,6 +630,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -647,7 +648,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -708,7 +709,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.
@@ -775,6 +776,8 @@ in_ram:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -782,8 +785,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)
cpu/mpc8xx/start.S +6 -5
index 24e9053..7cf602f 100644
@@ -63,7 +63,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_)
@@ -482,6 +482,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -499,7 +500,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -564,7 +565,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.
@@ -629,6 +630,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)
 
@@ -636,8 +639,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)
cpu/ppc4xx/start.S +6 -5
index 2eb21fa..927c88c 100644
@@ -228,7 +228,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 #if !defined(CONFIG_NAND_SPL)
 	START_GOT
@@ -1489,6 +1489,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Init Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -1506,7 +1507,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -1571,7 +1572,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.
@@ -1645,6 +1646,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start_of_vectors)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -1652,8 +1655,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)
include/ppc_asm.tmpl +4 -4
index fa5c5f6..84de146 100644
@@ -50,13 +50,13 @@
 	.text	2		;	\
 0:	.long	.LCTOC1-1f	;	\
 	.text			;	\
-1:	mflr	r14		;	\
-	lwz	r0,0b-1b(r14)	;	\
-	add	r14,r0,r14	;
+1:	mflr	r12		;	\
+	lwz	r0,0b-1b(r12)	;	\
+	add	r12,r0,r12	;
 
 #define GOT_ENTRY(NAME)		.L_ ## NAME = . - .LCTOC1 ; .long NAME
 
-#define GOT(NAME)		.L_ ## NAME (r14)
+#define GOT(NAME)		.L_ ## NAME (r12)
 
 
 /***************************************************************************
Signature · 1 line
1.6.4.4
#3 lore raw

PATCH 3/4 ppc: remove -ffixed-r14 gcc option.

This is no loger needed, free up r14 for general usage.

---
 cpu/74xx_7xx/config.mk |    2 +-
 cpu/mpc512x/config.mk  |    2 +-
 cpu/mpc5xx/config.mk   |    2 +-
 cpu/mpc5xxx/config.mk  |    2 +-
 cpu/mpc8220/config.mk  |    2 +-
 cpu/mpc824x/config.mk  |    2 +-
 cpu/mpc8260/config.mk  |    2 +-
 cpu/mpc83xx/config.mk  |    2 +-
 cpu/mpc85xx/config.mk  |    2 +-
 cpu/mpc86xx/config.mk  |    2 +-
 cpu/mpc8xx/config.mk   |    2 +-
 cpu/ppc4xx/config.mk   |    2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)
cpu/74xx_7xx/config.mk +1 -1
index d589210..df1f6ac 100644
@@ -21,6 +21,6 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_74xx_7xx -ffixed-r2 -mstring
cpu/mpc512x/config.mk +1 -1
index 6ab34b1..fb0a563 100644
@@ -19,7 +19,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC512X -DCONFIG_E300 \
 			-ffixed-r2 -msoft-float -mcpu=603e
cpu/mpc5xx/config.mk +1 -1
index 157ddc5..7854924 100644
@@ -28,7 +28,7 @@
 #
 
 
-PLATFORM_RELFLAGS +=	-fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS +=	-fPIC -meabi
 
 PLATFORM_CPPFLAGS +=	-DCONFIG_5xx -ffixed-r2 -mpowerpc -msoft-float
 
cpu/mpc5xxx/config.mk +1 -1
index b0ce2ee..5e82f67 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC5xxx -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
cpu/mpc8220/config.mk +1 -1
index 5819048..3ce40c0 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC8220 -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
cpu/mpc824x/config.mk +1 -1
index b607fee..940474b 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC824X -ffixed-r2 -mstring -mcpu=603e -msoft-float
 
cpu/mpc8260/config.mk +1 -1
index 2cb0270..39d81ee 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_8260 -DCONFIG_CPM2 -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
cpu/mpc83xx/config.mk +1 -1
index d619426..e80919b 100644
@@ -20,7 +20,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC83xx -DCONFIG_E300 \
 			-ffixed-r2 -msoft-float
cpu/mpc85xx/config.mk +1 -1
index beb3514..aa2c2f1 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -ffixed-r2 -Wa,-me500 -msoft-float -mno-string
 PLATFORM_CPPFLAGS +=$(call cc-option,-mno-spe)
cpu/mpc86xx/config.mk +1 -1
index 13da2cf..ca2f837 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -ffixed-r2 -mstring
 PLATFORM_CPPFLAGS += -maltivec -mabi=altivec -msoft-float
cpu/mpc8xx/config.mk +1 -1
index 2b3d545..5540d65 100644
@@ -21,6 +21,6 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_8xx -ffixed-r2 -mstring -mcpu=860 -msoft-float
cpu/ppc4xx/config.mk +1 -1
index 00ad39b..958e855 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -mstring -msoft-float
 
 cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
Signature · 1 line
1.6.4.4
#4 lore raw

PATCH 4/4 ppc: Update README about the new GOT ptr.

r14 is no longer used as non volatile GOT ptr. Instead the volatile r12 is used so be sure to do GET_GOT in asm code when you need to access global data.

---
 README |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
README +3 -1
index 744f6bf..bfd9498 100644
@@ -3916,7 +3916,9 @@ For PowerPC, the following registers have specific use:
 	R30:	GOT pointer
 	R31:	frame pointer
 
-	(U-Boot also uses R14 as internal GOT pointer.)
+	(U-Boot also uses R12 as internal GOT pointer. r12
+	is a volatile register so r12 needs to be reset when
+	going back and forth between asm and C)
 
     ==> U-Boot will use R2 to hold a pointer to the global data
 
Signature · 1 line
1.6.4.4
#5 lore raw

cover No GOT in IRQ and use r12 as GOT ptr

In reply to Joakim Tjernlund

Has this been forgotten(again)?

Jocke

Quoted 50 lines

This series removes the needs to access the GOT in IRQ handlers, then switches GOT PTR in start.S asm to use r12 instead of r14. This leads up to the removal of -ffixed-r14 gcc option for ppc

This is a resend since the it seems like the series was lost

Joakim Tjernlund (3):
ppc: Loose GOT access in IRQ
ppc: Use r12 instead of r14 as GOT pointer.
ppc: remove -ffixed-r14 gcc option.
ppc: Update README about the new GOT ptr.

 cpu/74xx_7xx/config.mk |    2 +-
 cpu/74xx_7xx/start.S   |   47 +++++++---------------------------------
 cpu/mpc512x/config.mk  |    2 +-
 cpu/mpc512x/start.S    |   46 +++++++--------------------------------
 cpu/mpc5xx/config.mk   |    2 +-
 cpu/mpc5xx/start.S     |   48 +++++++----------------------------------
 cpu/mpc5xxx/config.mk  |    2 +-
 cpu/mpc5xxx/start.S    |   46 +++++++--------------------------------
 cpu/mpc8220/config.mk  |    2 +-
 cpu/mpc8220/start.S    |   46 +++++++--------------------------------
 cpu/mpc824x/config.mk  |    2 +-
 cpu/mpc824x/start.S    |   44 +++++++------------------------------
 cpu/mpc8260/config.mk  |    2 +-
 cpu/mpc8260/start.S    |   50 ++++++++++---------------------------------
 cpu/mpc83xx/config.mk  |    2 +-
 cpu/mpc83xx/start.S    |   45 +++++++-------------------------------
 cpu/mpc85xx/config.mk  |    2 +-
 cpu/mpc85xx/start.S    |   44 +++++++------------------------------
 cpu/mpc86xx/config.mk  |    2 +-
 cpu/mpc86xx/start.S    |   47 +++++++---------------------------------
 cpu/mpc8xx/config.mk   |    2 +-
 cpu/mpc8xx/start.S     |   47 +++++++---------------------------------
 cpu/ppc4xx/config.mk   |    2 +-
 cpu/ppc4xx/start.S     |   44 +++++++------------------------------
 include/ppc_asm.tmpl   |   55 ++++++++++++++++++++++-------------------------
 lib_ppc/Makefile       |    1 +
 lib_ppc/reloc.S        |   49 ++++++++++++++++++++++++++++++++++++++++++
 README                 |    4 +++-
 28 files changed, 202 insertions(+), 485 deletions(-)
 create mode 100644 lib_ppc/reloc.S

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#6 lore raw

cover No GOT in IRQ and use r12 as GOT ptr

Dear Joakim Tjernlund,

Quoted 16 lines · In message <OFDE68EA42.2E6B3C0A-ONC12576A3.0050D905-C12576A3.00510037@transmode…

Has this been forgotten(again)?

Jocke

Quoted 13 lines

This series removes the needs to access the GOT in IRQ handlers, then switches GOT PTR in start.S asm to use r12 instead of r14. This leads up to the removal of -ffixed-r14 gcc option for ppc

This is a resend since the it seems like the series was lost

Joakim Tjernlund (3):
ppc: Loose GOT access in IRQ
ppc: Use r12 instead of r14 as GOT pointer.
ppc: remove -ffixed-r14 gcc option.
ppc: Update README about the new GOT ptr.

Not really forgotten. Actually I was waiting for a resend - I thought these patches were still RFC.

I can't apply them as is, as the Signed-off-by: line is missing in patches 1, 2, and 3.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Gew?hnlich glaubt der Mensch,  wenn er nur Worte h?rt,  es m?sse sich
dabei doch auch was denken lassen.                 -- Goethe, Faust I
#7 lore raw

cover No GOT in IRQ and use r12 as GOT ptr

Wolfgang Denk <[email protected]> wrote on 17/01/2010 20:12:31:

Quoted 22 lines

Dear Joakim Tjernlund,

In message <OFDE68EA42.2E6B3C0A-ONC12576A3.0050D905-C12576A3.

Quoted 16 lines · 00510037 at transmode.se> you wrote:

Has this been forgotten(again)?

Jocke

Quoted 13 lines

This series removes the needs to access the GOT in IRQ handlers, then switches GOT PTR in start.S asm to use r12 instead of r14. This leads up to the removal of -ffixed-r14 gcc option for ppc

This is a resend since the it seems like the series was lost

Joakim Tjernlund (3):
ppc: Loose GOT access in IRQ
ppc: Use r12 instead of r14 as GOT pointer.
ppc: remove -ffixed-r14 gcc option.
ppc: Update README about the new GOT ptr.

Quoted 5 lines

Not really forgotten. Actually I was waiting for a resend - I thought these patches were still RFC.

I can't apply them as is, as the Signed-off-by: line is missing in patches 1, 2, and 3.

Ouch, I will regenerate them next week then. Are you happy with them other the the missing SOB?

#8 lore raw

cover No GOT in IRQ and use r12 as GOT ptr

Dear Joakim Tjernlund,

Quoted 9 lines · In message <OF40260F27.B5C57B54-ONC12576AE.00740CD3-C12576AE.0074294E@transmode…
Quoted 6 lines

Not really forgotten. Actually I was waiting for a resend - I thought these patches were still RFC.

I can't apply them as is, as the Signed-off-by: line is missing in patches 1, 2, and 3.

Ouch, I will regenerate them next week then. Are you happy with them other the the missing SOB?

I have to admit that I didn't find the time for any real testing. I thought that I'll just throw them in so any problems will show up pretty quickly ;-)

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Overflow on /dev/null, please empty the bit bucket.
#9 lore raw

PATCH 1/4 ppc: Loose GOT access in IRQ

Using the GOT in IRQ handlers requires r14 to be -ffixed-r14. Avoid this by relocatate transfer_to_handler too. This will allow to free up r14 later on.

---
 cpu/74xx_7xx/start.S |   36 +++---------------------------------
 cpu/mpc512x/start.S  |   35 +++--------------------------------
 cpu/mpc5xx/start.S   |   37 +++----------------------------------
 cpu/mpc5xxx/start.S  |   35 +++--------------------------------
 cpu/mpc8220/start.S  |   35 +++--------------------------------
 cpu/mpc824x/start.S  |   33 +++------------------------------
 cpu/mpc8260/start.S  |   35 +++--------------------------------
 cpu/mpc83xx/start.S  |   34 +++-------------------------------
 cpu/mpc85xx/start.S  |   33 +++------------------------------
 cpu/mpc86xx/start.S  |   36 +++---------------------------------
 cpu/mpc8xx/start.S   |   36 +++---------------------------------
 cpu/ppc4xx/start.S   |   33 +++------------------------------
 include/ppc_asm.tmpl |   47 ++++++++++++++++++++++-------------------------
 lib_ppc/Makefile     |    1 +
 lib_ppc/reloc.S      |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 108 insertions(+), 407 deletions(-)
 create mode 100644 lib_ppc/reloc.S
cpu/74xx_7xx/start.S +3 -33
index 23381a3..efcd95f 100644
@@ -132,28 +132,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)
 
 	/* No FPU on MPC8xx.  This exception is not supposed to happen.
 	*/
@@ -837,23 +824,6 @@ 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
-
 #ifdef CONFIG_SYS_INIT_RAM_LOCK
 lock_ram_in_cache:
 	/* Allocate Initial RAM in data cache.
cpu/mpc512x/start.S +3 -32
index 4edc8e9..46c5efa 100644
@@ -127,30 +127,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 /* Floating Point Unit unavailable exception */
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
@@ -723,17 +708,3 @@ 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)
-
-	blr
cpu/mpc5xx/start.S +3 -34
index 85ea7a8..be980a1 100644
@@ -217,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.
 	*/
@@ -563,24 +550,6 @@ 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:
cpu/mpc5xxx/start.S +3 -32
index eb42939..075a7dd 100644
@@ -215,30 +215,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -797,17 +782,3 @@ 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)
-
-	blr
cpu/mpc8220/start.S +3 -32
index af9472d..5218c85 100644
@@ -176,30 +176,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 */
-	rlwimi	r20,r23,0,25,25	    /* copy IP 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 */
-	rlwimi	r20,r23,0,25,25	    /* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -762,17 +747,3 @@ 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)
-
-	blr
cpu/mpc824x/start.S +3 -30
index 750457b..7f40648 100644
@@ -227,28 +227,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 */
 	. = EXC_OFF_PROGRAM
 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)
 
 	/* No FPU on MPC8xx. This exception is not supposed to happen.
 	*/
@@ -695,20 +682,6 @@ 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)
-
-	blr
-
 	/* Setup the BAT registers.
 	 */
 setup_bats:
cpu/mpc8260/start.S +3 -32
index edb95e6..7d80af5 100644
@@ -286,30 +286,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -1033,17 +1018,3 @@ 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)
-
-	blr
cpu/mpc83xx/start.S +3 -31
index ee4b862..5a50b09 100644
@@ -338,30 +338,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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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 */
-	rlwimi	r20,r23,0,25,25		/* copy IP 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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -1086,19 +1071,6 @@ 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)
-
-	blr
 #endif /* !CONFIG_NAND_SPL */
 
 #ifdef CONFIG_SYS_INIT_RAM_LOCK
cpu/mpc85xx/start.S +3 -30
index 7e60e67..d73c5c2 100644
@@ -415,28 +415,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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
 
 /* Program check exception */
 	. = 0x0700
 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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
+		MSR_KERNEL, COPY_EE)
 
 	/* No FPU on MPC85xx.  This exception is not supposed to happen.
 	*/
@@ -1089,20 +1076,6 @@ 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)
-
-	blr
-
 .globl unlock_ram_in_cache
 unlock_ram_in_cache:
 	/* invalidate the INIT_RAM section */
cpu/mpc86xx/start.S +3 -33
index e65f1c0..eaa2657 100644
@@ -121,28 +121,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)
 
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
 
@@ -848,23 +835,6 @@ 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
-
 .globl enable_ext_addr
 enable_ext_addr:
 	mfspr	r0, HID0
cpu/mpc8xx/start.S +3 -33
index e84326e..24e9053 100644
@@ -231,28 +231,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)
 
 	/* No FPU on MPC8xx.  This exception is not supposed to happen.
 	*/
@@ -694,20 +681,3 @@ 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
cpu/ppc4xx/start.S +3 -30
index 46f65aa..2eb21fa 100644
@@ -574,28 +574,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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	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 + _START_OFFSET
-	.long	int_return - _start + _START_OFFSET
+	EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
+		MSR_KERNEL, COPY_EE)
 
 #ifdef CONFIG_440
 	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
@@ -1742,20 +1729,6 @@ __440_msr_continue:
 	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)
-
-	blr
-
 #if defined(CONFIG_440)
 /*----------------------------------------------------------------------------+
 | dcbz_area.
include/ppc_asm.tmpl +22 -25

68 lines not on this page · raw message

lib_ppc/Makefile +1 -0
index 60a7625..334e457 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)lib$(ARCH).a
 SOBJS-y	+= ppccache.o
 SOBJS-y	+= ppcstring.o
 SOBJS-y	+= ticks.o
+SOBJS-y	+= reloc.o
 
 COBJS-y	+= bat_rw.o
 COBJS-y	+= board.o
lib_ppc/reloc.S new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#10 lore raw

PATCH 2/4 ppc: Use r12 instead of r14 as GOT pointer.

r14 is not supposed to be clobbered by functions. Switch to r12 and call GET_GOT when needed. This will allow u-boot to loose the -ffixed-r14 gcc option.

---
 cpu/74xx_7xx/start.S |   11 ++++++-----
 cpu/mpc512x/start.S  |   11 ++++++-----
 cpu/mpc5xx/start.S   |   11 ++++++-----
 cpu/mpc5xxx/start.S  |   11 ++++++-----
 cpu/mpc8220/start.S  |   11 ++++++-----
 cpu/mpc824x/start.S  |   11 ++++++-----
 cpu/mpc8260/start.S  |   15 +++++++++------
 cpu/mpc83xx/start.S  |   11 ++++++-----
 cpu/mpc85xx/start.S  |   11 ++++++-----
 cpu/mpc86xx/start.S  |   11 ++++++-----
 cpu/mpc8xx/start.S   |   11 ++++++-----
 cpu/ppc4xx/start.S   |   11 ++++++-----
 include/ppc_asm.tmpl |    8 ++++----
 13 files changed, 79 insertions(+), 65 deletions(-)
cpu/74xx_7xx/start.S +6 -5
index efcd95f..88fdf88 100644
@@ -63,7 +63,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_)
@@ -599,6 +599,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -616,7 +617,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -691,7 +692,7 @@ in_ram:
 	bl	board_init_ecc
 #endif
 	/*
-	 * 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.
@@ -765,6 +766,8 @@ in_ram:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -772,8 +775,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)
cpu/mpc512x/start.S +6 -5
index 46c5efa..d26b617 100644
@@ -65,7 +65,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_)
@@ -486,6 +486,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer */
 	mr	r10, r5		/* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address */
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address */
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -504,7 +505,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -584,7 +585,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.
@@ -648,6 +649,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)
 
@@ -655,8 +658,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)
cpu/mpc5xx/start.S +6 -5
index be980a1..0af879e 100644
@@ -56,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_)
@@ -372,6 +372,7 @@ 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, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -388,7 +389,7 @@ relocate_code:
 	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
 
@@ -433,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.
@@ -497,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)
 
@@ -504,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)
cpu/mpc5xxx/start.S +6 -5
index 075a7dd..d499da5 100644
@@ -56,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_)
@@ -567,6 +567,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -584,7 +585,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -657,7 +658,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.
@@ -722,6 +723,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)
 
@@ -729,8 +732,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)
cpu/mpc8220/start.S +6 -5
index 5218c85..e28999d 100644
@@ -55,7 +55,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_)
@@ -532,6 +532,7 @@ relocate_code:
 	mr	r9,  r4	    /* Save copy of Global Data pointer */
 	mr	r10, r5	    /* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5	    /* Destination Address		*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h	/* Source Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -549,7 +550,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -622,7 +623,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.
@@ -687,6 +688,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)
 
@@ -694,8 +697,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)
cpu/mpc824x/start.S +6 -5
index 7f40648..f3f595a 100644
@@ -63,7 +63,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_)
@@ -462,6 +462,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 #ifdef CONFIG_SYS_RAMBOOT
 	lis	r4, CONFIG_SYS_SDRAM_BASE at h		/* Source      Address	*/
@@ -484,7 +485,7 @@ relocate_code:
 	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
 
@@ -564,7 +565,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.
@@ -629,6 +630,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)
 
@@ -636,8 +639,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)
cpu/mpc8260/start.S +9 -6
index 7d80af5..1fc70bc 100644
@@ -56,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_)
@@ -650,7 +650,9 @@ init_debug:
 	/* RAM should now be operational */
 
 #define VEC_WRD_CNT	((_end_of_vectors - _start + EXC_OFF_SYS_RESET) / 4)
-
+	mflr	r3
+	GET_GOT
+	mtlr	r3
 	lwz	r3, GOT(_end_of_vectors)
 	rlwinm	r4, r3, 0, 18, 31	/* _end_of_vectors & 0x3FFF	*/
 	lis	r5, VEC_WRD_CNT at h
@@ -792,6 +794,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -809,7 +812,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -882,7 +885,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.
@@ -958,6 +961,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)
 
@@ -965,8 +970,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)
cpu/mpc83xx/start.S +6 -5
index 5a50b09..68bb620 100644
@@ -65,7 +65,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_)
@@ -830,6 +830,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer */
 	mr	r10, r5		/* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address */
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address */
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -848,7 +849,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -930,7 +931,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.
@@ -1010,6 +1011,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)
 
@@ -1017,8 +1020,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)
cpu/mpc85xx/start.S +6 -5
index d73c5c2..386fa81 100644
@@ -51,7 +51,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_)
@@ -871,6 +871,7 @@ relocate_code:
 	mr	r9,r4		/* Save copy of Init Data pointer	*/
 	mr	r10,r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,r5				/* Destination Address	*/
 	lis	r4,CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4,r4,CONFIG_SYS_MONITOR_BASE at l
@@ -888,7 +889,7 @@ relocate_code:
 	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
 
@@ -958,7 +959,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.
@@ -1024,6 +1025,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7,GOT(_start_of_vectors)
 	lwz	r8,GOT(_end_of_vectors)
 
@@ -1031,8 +1034,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)
cpu/mpc86xx/start.S +6 -5
index eaa2657..ed1e4ca 100644
@@ -52,7 +52,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_)
@@ -630,6 +630,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -647,7 +648,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -708,7 +709,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.
@@ -775,6 +776,8 @@ in_ram:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -782,8 +785,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)
cpu/mpc8xx/start.S +6 -5
index 24e9053..7cf602f 100644
@@ -63,7 +63,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_)
@@ -482,6 +482,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -499,7 +500,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -564,7 +565,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.
@@ -629,6 +630,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)
 
@@ -636,8 +639,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)
cpu/ppc4xx/start.S +6 -5
index 2eb21fa..927c88c 100644
@@ -228,7 +228,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 #if !defined(CONFIG_NAND_SPL)
 	START_GOT
@@ -1489,6 +1489,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Init Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -1506,7 +1507,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -1571,7 +1572,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.
@@ -1645,6 +1646,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start_of_vectors)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -1652,8 +1655,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)
include/ppc_asm.tmpl +4 -4
index fa5c5f6..84de146 100644
@@ -50,13 +50,13 @@
 	.text	2		;	\
 0:	.long	.LCTOC1-1f	;	\
 	.text			;	\
-1:	mflr	r14		;	\
-	lwz	r0,0b-1b(r14)	;	\
-	add	r14,r0,r14	;
+1:	mflr	r12		;	\
+	lwz	r0,0b-1b(r12)	;	\
+	add	r12,r0,r12	;
 
 #define GOT_ENTRY(NAME)		.L_ ## NAME = . - .LCTOC1 ; .long NAME
 
-#define GOT(NAME)		.L_ ## NAME (r14)
+#define GOT(NAME)		.L_ ## NAME (r12)
 
 
 /***************************************************************************
Signature · 1 line
1.6.4.4
#11 lore raw

PATCH 3/4 ppc: remove -ffixed-r14 gcc option.

This is no loger needed, free up r14 for general usage.

---
 cpu/74xx_7xx/config.mk |    2 +-
 cpu/mpc512x/config.mk  |    2 +-
 cpu/mpc5xx/config.mk   |    2 +-
 cpu/mpc5xxx/config.mk  |    2 +-
 cpu/mpc8220/config.mk  |    2 +-
 cpu/mpc824x/config.mk  |    2 +-
 cpu/mpc8260/config.mk  |    2 +-
 cpu/mpc83xx/config.mk  |    2 +-
 cpu/mpc85xx/config.mk  |    2 +-
 cpu/mpc86xx/config.mk  |    2 +-
 cpu/mpc8xx/config.mk   |    2 +-
 cpu/ppc4xx/config.mk   |    2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)
cpu/74xx_7xx/config.mk +1 -1
index d589210..df1f6ac 100644
@@ -21,6 +21,6 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_74xx_7xx -ffixed-r2 -mstring
cpu/mpc512x/config.mk +1 -1
index 6ab34b1..fb0a563 100644
@@ -19,7 +19,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC512X -DCONFIG_E300 \
 			-ffixed-r2 -msoft-float -mcpu=603e
cpu/mpc5xx/config.mk +1 -1
index 157ddc5..7854924 100644
@@ -28,7 +28,7 @@
 #
 
 
-PLATFORM_RELFLAGS +=	-fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS +=	-fPIC -meabi
 
 PLATFORM_CPPFLAGS +=	-DCONFIG_5xx -ffixed-r2 -mpowerpc -msoft-float
 
cpu/mpc5xxx/config.mk +1 -1
index b0ce2ee..5e82f67 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC5xxx -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
cpu/mpc8220/config.mk +1 -1
index 5819048..3ce40c0 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC8220 -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
cpu/mpc824x/config.mk +1 -1
index b607fee..940474b 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC824X -ffixed-r2 -mstring -mcpu=603e -msoft-float
 
cpu/mpc8260/config.mk +1 -1
index 2cb0270..39d81ee 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_8260 -DCONFIG_CPM2 -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
cpu/mpc83xx/config.mk +1 -1
index d619426..e80919b 100644
@@ -20,7 +20,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC83xx -DCONFIG_E300 \
 			-ffixed-r2 -msoft-float
cpu/mpc85xx/config.mk +1 -1
index 84651b8..408184a 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -ffixed-r2 -Wa,-me500 -msoft-float -mno-string
 
cpu/mpc86xx/config.mk +1 -1
index 13da2cf..ca2f837 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -ffixed-r2 -mstring
 PLATFORM_CPPFLAGS += -maltivec -mabi=altivec -msoft-float
cpu/mpc8xx/config.mk +1 -1
index 2b3d545..5540d65 100644
@@ -21,6 +21,6 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_8xx -ffixed-r2 -mstring -mcpu=860 -msoft-float
cpu/ppc4xx/config.mk +1 -1
index 979004b..c1de1e9 100644
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi
+PLATFORM_RELFLAGS += -fPIC -meabi
 PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -mstring -msoft-float
 
 cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
Signature · 1 line
1.6.4.4
#12 lore raw

PATCH 4/4 ppc: Update README about the new GOT ptr.

r14 is no longer used as non volatile GOT ptr. Instead the volatile r12 is used so be sure to do GET_GOT in asm code when you need to access global data.

---
 README |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
README +3 -1
index 7affe10..263bb05 100644
@@ -3922,7 +3922,9 @@ For PowerPC, the following registers have specific use:
 	R30:	GOT pointer
 	R31:	frame pointer
 
-	(U-Boot also uses R14 as internal GOT pointer.)
+	(U-Boot also uses R12 as internal GOT pointer. r12
+	is a volatile register so r12 needs to be reset when
+	going back and forth between asm and C)
 
     ==> U-Boot will use R2 to hold a pointer to the global data
 
Signature · 1 line
1.6.4.4
#13 lore raw

PATCH 4/4 ppc: Update README about the new GOT ptr.

Dear Joakim Tjernlund,

Quoted 8 lines · In message <[email protected]>…

r14 is no longer used as non volatile GOT ptr. Instead the volatile r12 is used so be sure to do GET_GOT in asm code when you need to access global data.

---
 README |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Applied, thanks!

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The day-to-day travails of the IBM programmer are so amusing to  most
of us who are fortunate enough never to have been one - like watching
Charlie Chaplin trying to cook a shoe.
#14 lore raw

PATCH 3/4 ppc: remove -ffixed-r14 gcc option.

In reply to Joakim Tjernlund

Dear Joakim Tjernlund,

Quoted 17 lines · In message <[email protected]>…

This is no loger needed, free up r14 for general usage.

---
 cpu/74xx_7xx/config.mk |    2 +-
 cpu/mpc512x/config.mk  |    2 +-
 cpu/mpc5xx/config.mk   |    2 +-
 cpu/mpc5xxx/config.mk  |    2 +-
 cpu/mpc8220/config.mk  |    2 +-
 cpu/mpc824x/config.mk  |    2 +-
 cpu/mpc8260/config.mk  |    2 +-
 cpu/mpc83xx/config.mk  |    2 +-
 cpu/mpc85xx/config.mk  |    2 +-
 cpu/mpc86xx/config.mk  |    2 +-
 cpu/mpc8xx/config.mk   |    2 +-
 cpu/ppc4xx/config.mk   |    2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Killing is stupid; useless!
	-- McCoy, "A Private Little War", stardate 4211.8
#15 lore raw

PATCH 1/4 ppc: Loose GOT access in IRQ

In reply to Joakim Tjernlund

Dear Joakim Tjernlund,

Quoted 15 lines · In message <[email protected]>…

Using the GOT in IRQ handlers requires r14 to be -ffixed-r14. Avoid this by relocatate transfer_to_handler too. This will allow to free up r14 later on.

---
 cpu/74xx_7xx/start.S |   36 +++---------------------------------
 cpu/mpc512x/start.S  |   35 +++--------------------------------
 cpu/mpc5xx/start.S   |   37 +++----------------------------------
 cpu/mpc5xxx/start.S  |   35 +++--------------------------------
 cpu/mpc8220/start.S  |   35 +++--------------------------------
 cpu/mpc824x/start.S  |   33 +++------------------------------
 cpu/mpc8260/start.S  |   35 +++--------------------------------
 cpu/mpc83xx/start.S  |   34 +++-------------------------------
 cpu/mpc85xx/start.S  |   33 +++------------------------------
Quoted 8 lines
 cpu/mpc86xx/start.S  |   36 +++---------------------------------
 cpu/mpc8xx/start.S   |   36 +++---------------------------------
 cpu/ppc4xx/start.S   |   33 +++------------------------------
 include/ppc_asm.tmpl |   47 ++++++++++++++++++++++-------------------------
 lib_ppc/Makefile     |    1 +
 lib_ppc/reloc.S      |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 108 insertions(+), 407 deletions(-)
 create mode 100644 lib_ppc/reloc.S

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I'm frequently appalled by the low regard you Earthmen have for life.
	-- Spock, "The Galileo Seven", stardate 2822.3