Skip to content

Commit

Permalink
ppc: Use r12 instead of r14 as GOT pointer.
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Joakim Tjernlund <[email protected]>
  • Loading branch information
joakim-tjernlund authored and wdenx committed Jan 26, 2010
1 parent fc4e188 commit 0f8aa15
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 65 deletions.
11 changes: 6 additions & 5 deletions cpu/74xx_7xx/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h /* Source Address */
ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -765,15 +766,15 @@ in_ram:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector always at 0x100 */

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)
Expand Down
11 changes: 6 additions & 5 deletions cpu/mpc512x/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h /* Source Address */
ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -648,15 +649,15 @@ clear_bss:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector at 0x100 */

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)
Expand Down
11 changes: 6 additions & 5 deletions cpu/mpc5xx/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h /* Source Address */
ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -497,15 +498,15 @@ clear_bss:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector always at 0x100 */

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)
Expand Down
11 changes: 6 additions & 5 deletions cpu/mpc5xxx/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h /* Source Address */
ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -722,15 +723,15 @@ clear_bss:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector always at 0x100 */

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)
Expand Down
11 changes: 6 additions & 5 deletions cpu/mpc8220/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h /* Source Address */
ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -687,15 +688,15 @@ clear_bss:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector always at 0x100 */

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)
Expand Down
11 changes: 6 additions & 5 deletions cpu/mpc824x/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h /* Source Address */
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -629,15 +630,15 @@ clear_bss:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector always at 0x100 */

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)
Expand Down
15 changes: 9 additions & 6 deletions cpu/mpc8260/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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@h
Expand Down Expand Up @@ -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@h /* Source Address */
ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -958,15 +961,15 @@ clear_bss:
*/
.globl trap_init
trap_init:
mflr r4 /* save link register */
GET_GOT
lwz r7, GOT(_start)
lwz r8, GOT(_end_of_vectors)

li r9, 0x100 /* reset vector always at 0x100 */

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)
Expand Down
Loading

0 comments on commit 0f8aa15

Please sign in to comment.