Skip to contentSkip to conversation

MIPS: xburst: simplify relocation offset calculation

PATCH New Gabor Juhos 2 participants 2 messages Jan 30, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: xburst: 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.

Cc Daniel Schwierzeck <[email protected]>
Cc Xiangfu Liu <[email protected]>
---
 arch/mips/cpu/xburst/start.S |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
arch/mips/cpu/xburst/start.S +3 -9
index 194d745..35728eb 100644
@@ -64,19 +64,13 @@ relocate_code:
 	move	sp, a0			# set new stack pointer
 
 	li	t0, CONFIG_SYS_MONITOR_BASE
+	sub	t6, a2, t0		# t6 <-- relocation offset
+
 	la	t3, in_ram
 	lw	t2, -12(t3)		# t2 <-- uboot_end_data
 	move	t1, a2
 
-	/*
-	 * 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	t6, gp, t6		# t6 <-- relocation offset
+	add	gp, t6			# adjust gp
 
 	/*
 	 * t0 = source address
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/1 MIPS: xburst: simplify relocation offset calculation

2013/1/30 Gabor Juhos <[email protected]>:

Quoted 12 lines

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.

Quoted 6 lines
Cc Daniel Schwierzeck <[email protected]>
Cc Xiangfu Liu <[email protected]>
---
 arch/mips/cpu/xburst/start.S |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

applied to u-boot-mips/master, thanks

Signature · 2 lines
Best regards,
Daniel