[Skiboot] [PATCH] external/opal-prd: Use "official" switch-endian syscall

Jeremy Kerr jk at ozlabs.org
Thu Mar 26 18:07:58 AEDT 2015


The "fast endian switch" syscall was never fully supported - this change
moves to the official switch-endian syscall, using __NR_switch_endian

We also form the little-endian instructions using this prepreocessor
define.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

---
stewart: this change is pending Michael's work on the kernel side

---
 external/opal-prd/thunk.S |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/external/opal-prd/thunk.S b/external/opal-prd/thunk.S
index 9d97183..773df26 100644
--- a/external/opal-prd/thunk.S
+++ b/external/opal-prd/thunk.S
@@ -1,4 +1,12 @@
 #include <endian.h>
+#include <asm/unistd.h>
+
+#ifndef __NR_switch_endian
+#define __NR_switch_endian 363
+#endif
+
+/* a constant to use in the SI field of a little-endian D-form instruction */
+#define le_si16(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8))
 
 	.text
 
@@ -10,8 +18,6 @@
 
 call_be:
 
-#define __NR_fast_endian_switch		0x1ebe
-
 	/* Before we switch, we need to perform some ABI
 	 * conversion. We are currently running LE with the
 	 * new ABI v2. The GPR content is the same, we do
@@ -45,14 +51,15 @@ call_be:
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 	/* Switch to the "other endian" */
-	li %r0,__NR_fast_endian_switch
+	li %r0,__NR_switch_endian
 	sc
 
 	/* Branch to CTR */
 	.long 0x2104804e /* (byteswapped bctrl) */
 
 	/* Switch endian back */
-	.long 0xbe1e0038 /* byteswapped li %r0,__NR_fast_endian_switch */
+	.long 0x00000038 | le_si16(__NR_switch_endian)
+			/* byteswapped li %r0,__NR_switch_endian */
 	.long 0x02000044 /* byteswapped sc */
 #else
 	bctrl
@@ -110,7 +117,7 @@ call_le:
 	mtlr %r0
 
 	/* Switch endian back to BE */
-	li %r0,__NR_fast_endian_switch
+	li %r0,__NR_switch_endian
 	sc
 
 	/* Return to BE */
@@ -125,7 +132,8 @@ call_le:
 	.pushsection ".text","ax" 						;\
 	.globl	name##_thunk							;\
 name##_thunk:									;\
-	.long 0xbe1e0038 /* byteswapped li %r0,__NR_fast_endian_switch */       ;\
+	.long 0x00000038 | le_si16(__NR_switch_endian)				;\
+			/* byteswapped li %r0,__NR_switch_endian */		;\
 	.long 0x02000044 /* byteswapped sc */					;\
 	ld %r11,name at got(%r2)							;\
 	b call_le								;\


More information about the Skiboot mailing list