[Skiboot] [PATCH v2 4/7] test/hello_world: Call OPAL_CEC_POWER_DOWN at end

Michael Neuling mikey at neuling.org
Mon May 2 15:26:18 AEST 2016


Call OPAL_CEC_POWER_DOWN at end rather than using a raw attn
instruction. We are doing this since attn should be disabled in the
host kernel otherwise userspace may crash the machine by calling it.

We are now doing two opal calls so need to save some registers which
are volatile over opal calls.

This bloats the code from 10 instructions up to 16. May god have mercy
on my soul.

Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 test/hello_world/hello_kernel/hello_kernel.S | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/test/hello_world/hello_kernel/hello_kernel.S b/test/hello_world/hello_kernel/hello_kernel.S
index cd1d744..6cc6409 100644
--- a/test/hello_world/hello_kernel/hello_kernel.S
+++ b/test/hello_world/hello_kernel/hello_kernel.S
@@ -26,7 +26,14 @@
 	. = 0x0
 	.globl _start
 _start:
-	mr	%r2, %r8 /* r8 is the OPAL base passed in by skiboot */
+/*
+ * Save some values passed in from skiboot into registers that are
+ * non-volatile over OPAL calls.
+ *   r8 is the OPAL base
+ *   r9 is the OPAL entry point point
+ */
+	mr	%r13, %r8
+	mr	%r14, %r9
 
 	bl	here
 here:	mflr	%r8 /* work out where we are running */
@@ -35,10 +42,17 @@ here:	mflr	%r8 /* work out where we are running */
 	li	%r3, 0 /* terminal 0 */
 	addi	%r4, %r8, len - here /* ptr to length of string */
 	addi	%r5, %r8, str - here /* ptr to string start */
+	mr	%r2, %r13
+	mtctr	%r14
+	bctrl
 
-	mtctr	%r9 /* R9 is the OPAL entry point passed in by skiboot */
+	li	%r0, 5 /* OPAL_CEC_POWER_DOWN */
+	mr	%r2, %r13
+	mtctr	%r14
 	bctrl
-	attn
+
+	/* We shouldn't get here but if we do, just wait here */
+	b	.
 
 len:
 	.long 0x00
-- 
2.7.4



More information about the Skiboot mailing list