Request for Review: improving Ubldr syscall linkage.

Tim Kientzle tim at kientzle.com
Tue May 1 05:43:08 UTC 2012


Any comments on the following before I commit?

Basically, this just:
  * Removes some redundant loads
  * Uses blx for the subroutine call
  * Uses bx for the subroutine return

The only odd point:  The ARM reference I have lists blx
only for ARMv6 and ARMv7 instruction sets … or am I
misreading that somehow?

It seems to work, but my only ARM board is ARMv7 and
I don't want to screw up anything for older CPUs.

Index: sys/boot/arm/uboot/start.S
===================================================================
--- sys/boot/arm/uboot/start.S	(revision 234747)
+++ sys/boot/arm/uboot/start.S	(working copy)
@@ -49,30 +49,22 @@
  * syscall()
  */
 ENTRY(syscall)
-	/* Save caller's lr */
+	/* Save caller's lr and r8 */
 	ldr	ip, =saved_regs
 	str	lr, [ip, #4]
-	/* Save loader's r8 */
-	ldr	ip, =saved_regs
 	str	r8, [ip, #8]
-
 	/* Restore U-Boot's r8 */
-	ldr	ip, =saved_regs
 	ldr	r8, [ip, #0]
 	/* Call into U-Boot */
-	ldr	lr, =return_from_syscall
 	ldr	ip, =syscall_ptr
-	ldr	pc, [ip]
-
-return_from_syscall:
-	/* Restore loader's r8 */
+	ldr	ip, [ip, #0]
+	blx	ip
+	/* Restore loader's r8 and lr */
 	ldr	ip, =saved_regs
 	ldr	r8, [ip, #8]
-	/* Restore caller's lr */
-	ldr	ip, =saved_regs
 	ldr	lr, [ip, #4]
 	/* Return to caller */
-	mov	pc, lr
+	bx	lr
 
 /*
  * Data section



More information about the freebsd-arm mailing list