mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-12 05:25:11 -04:00
MIPS: start.S: simplify relocation offset calculation
The current code uses four instructions and a temporary register to calculate the relocation offset and to adjust the gp register. The relocation offset can be calculated directly from the CONFIG_SYS_MONITOR_BASE constant and from the destination address. The resulting offset can be used to adjust the gp pointer. This approach makes the code a bit simpler because it needs two instructions only. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
This commit is contained in:
parent
b2fe86f887
commit
248fe03f53
@ -283,19 +283,13 @@ relocate_code:
|
|||||||
move s2, a2 # save destination address in s2
|
move s2, a2 # save destination address in s2
|
||||||
|
|
||||||
li t0, CONFIG_SYS_MONITOR_BASE
|
li t0, CONFIG_SYS_MONITOR_BASE
|
||||||
|
sub s1, s2, t0 # s1 <-- relocation offset
|
||||||
|
|
||||||
la t3, in_ram
|
la t3, in_ram
|
||||||
lw t2, -12(t3) # t2 <-- uboot_end_data
|
lw t2, -12(t3) # t2 <-- uboot_end_data
|
||||||
move t1, a2
|
move t1, a2
|
||||||
|
|
||||||
/*
|
add gp, s1 # adjust gp
|
||||||
* Fix $gp:
|
|
||||||
*
|
|
||||||
* New $gp = (Old $gp - CONFIG_SYS_MONITOR_BASE) + Destination Address
|
|
||||||
*/
|
|
||||||
move t6, gp
|
|
||||||
sub gp, CONFIG_SYS_MONITOR_BASE
|
|
||||||
add gp, a2 # gp now adjusted
|
|
||||||
sub s1, gp, t6 # s1 <-- relocation offset
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* t0 = source address
|
* t0 = source address
|
||||||
|
@ -162,19 +162,13 @@ relocate_code:
|
|||||||
move s2, a2 # save destination address in s2
|
move s2, a2 # save destination address in s2
|
||||||
|
|
||||||
dli t0, CONFIG_SYS_MONITOR_BASE
|
dli t0, CONFIG_SYS_MONITOR_BASE
|
||||||
|
dsub s1, s2, t0 # s1 <-- relocation offset
|
||||||
|
|
||||||
dla t3, in_ram
|
dla t3, in_ram
|
||||||
ld t2, -24(t3) # t2 <-- uboot_end_data
|
ld t2, -24(t3) # t2 <-- uboot_end_data
|
||||||
move t1, a2
|
move t1, a2
|
||||||
|
|
||||||
/*
|
dadd gp, s1 # adjust gp
|
||||||
* Fix $gp:
|
|
||||||
*
|
|
||||||
* New $gp = (Old $gp - CONFIG_SYS_MONITOR_BASE) + Destination Address
|
|
||||||
*/
|
|
||||||
move t8, gp
|
|
||||||
dsub gp, CONFIG_SYS_MONITOR_BASE
|
|
||||||
dadd gp, a2 # gp now adjusted
|
|
||||||
dsub s1, gp, t8 # s1 <-- relocation offset
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* t0 = source address
|
* t0 = source address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user