[OpenBIOS] [PATCHv2 1/4] ppc: move call_elf() to separate switch.S file

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Mon May 2 13:50:15 CEST 2016


Separate out the context switch code into a separate file, similar as to how
is already done with the other architectures.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/arch/ppc/build.xml     |    1 +
 openbios-devel/arch/ppc/qemu/start.S  |   47 ++---------------------------
 openbios-devel/arch/ppc/qemu/switch.S |   52 +++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 44 deletions(-)
 create mode 100644 openbios-devel/arch/ppc/qemu/switch.S

diff --git a/openbios-devel/arch/ppc/build.xml b/openbios-devel/arch/ppc/build.xml
index 29f6601..b40c81c 100644
--- a/openbios-devel/arch/ppc/build.xml
+++ b/openbios-devel/arch/ppc/build.xml
@@ -182,6 +182,7 @@
 	$(call quiet-command,$(NM) $@.nostrip | sort > $(ODIR)/openbios-qemu.syms,"  GEN   $(TARGET_DIR)$@.syms")
 	$(call quiet-command,$(STRIP) $@.nostrip -o $@,"  STRIP $(TARGET_DIR)$@")</rule>
   <object source="qemu/start.S"/>
+  <object source="qemu/switch.S"/>
   <object source="timebase.S"/>
   <external-object source="libqemu.a"/>
   <external-object source="libbootstrap.a"/>
diff --git a/openbios-devel/arch/ppc/qemu/start.S b/openbios-devel/arch/ppc/qemu/start.S
index ae2fd53..483c498 100644
--- a/openbios-devel/arch/ppc/qemu/start.S
+++ b/openbios-devel/arch/ppc/qemu/start.S
@@ -486,52 +486,11 @@ real_entry:
 1:	nop
 	b	1b
 
-
-	/* According to IEEE 1275, PPC bindings:
-	 *
-	 * 	MSR = FP, ME + (DR|IR)
-	 *	r1 = stack (32 K + 32 bytes link area above)
-	 *	r5 = client interface handler
-	 *	r6 = address of client program arguments (unused)
-	 *	r7 = length of client program arguments (unused)
-         *
-         *      Yaboot and Linux use r3 and r4 for initrd address and size
-	 */
         .data
-saved_stack:
-    DATA_LONG(0)
+_GLOBAL(saved_stack):
+        DATA_LONG(0)
+        
         .previous
-	/* void call_elf( arg1, arg2, entry ) */
-_GLOBAL(call_elf):
-	mflr	r0
-	PPC_STLU r1, -STACKFRAME_MINSIZE(r1)
-	PPC_STL  r0, (STACKFRAME_MINSIZE + PPC_LR_STKOFF)(r1)
-	mtlr	r5
-	LOAD_REG_IMMEDIATE(r8, saved_stack)		// save our stack pointer
-	PPC_STL r1,0(r8)
-	mfsdr1	r1
-	addi	r1, r1, -32768		/* - 32 KiB exception stack */
-	addis	r1, r1, -1			/* - 64 KiB stack */
-	LOAD_REG_IMMEDIATE(r5, of_client_callback)	// r5 = callback
-	li	r6,0			// r6 = address of client program arguments (unused)
-	li	r7,0			// r7 = length of client program arguments (unused)
-	li	r0,MSR_FP | MSR_ME | MSR_DR | MSR_IR
-	MTMSRD(r0)
-	blrl
-
-#ifdef CONFIG_PPC64
-    /* Restore SF bit */
-    LOAD_REG_IMMEDIATE(r0, MSR_SF | MSR_FP | MSR_ME | MSR_DR | MSR_IR)
-    MTMSRD(r0)
-#endif
-	LOAD_REG_IMMEDIATE(r8, saved_stack)		// restore stack pointer
-	mr	r1,r8
-	PPC_LL r0, (STACKFRAME_MINSIZE + PPC_LR_STKOFF)(r1)
-	mtlr	r0
-	addi	r1, r1, STACKFRAME_MINSIZE
-	// XXX: should restore r12-r31 etc..
-	// we should not really come here though
-	blr
 
 #ifdef __powerpc64__
 #define STKOFF STACKFRAME_MINSIZE
diff --git a/openbios-devel/arch/ppc/qemu/switch.S b/openbios-devel/arch/ppc/qemu/switch.S
new file mode 100644
index 0000000..eabd6d0
--- /dev/null
+++ b/openbios-devel/arch/ppc/qemu/switch.S
@@ -0,0 +1,52 @@
+#include "autoconf.h"
+#include "asm/asmdefs.h"
+#include "asm/processor.h"
+
+#ifdef CONFIG_PPC_64BITSUPPORT
+	#define STACKFRAME_MINSIZE 48
+#else /* !CONFIG_PPC_64BITSUPPORT */
+	#define STACKFRAME_MINSIZE 16
+#endif
+
+	/* According to IEEE 1275, PPC bindings:
+	 *
+	 * 	MSR = FP, ME + (DR|IR)
+	 *	r1 = stack (32 K + 32 bytes link area above)
+	 *	r5 = client interface handler
+	 *	r6 = address of client program arguments (unused)
+	 *	r7 = length of client program arguments (unused)
+         *
+         *      Yaboot and Linux use r3 and r4 for initrd address and size
+	 */
+
+	/* void call_elf( arg1, arg2, entry ) */
+_GLOBAL(call_elf):
+	mflr	r0
+	PPC_STLU r1, -STACKFRAME_MINSIZE(r1)
+	PPC_STL  r0, (STACKFRAME_MINSIZE + PPC_LR_STKOFF)(r1)
+	mtlr	r5
+	LOAD_REG_IMMEDIATE(r8, saved_stack)		// save our stack pointer
+	PPC_STL r1,0(r8)
+	mfsdr1	r1
+	addi	r1, r1, -32768		/* - 32 KiB exception stack */
+	addis	r1, r1, -1			/* - 64 KiB stack */
+	LOAD_REG_IMMEDIATE(r5, of_client_callback)	// r5 = callback
+	li	r6,0			// r6 = address of client program arguments (unused)
+	li	r7,0			// r7 = length of client program arguments (unused)
+	li	r0,MSR_FP | MSR_ME | MSR_DR | MSR_IR
+	MTMSRD(r0)
+	blrl
+
+#ifdef CONFIG_PPC64
+    /* Restore SF bit */
+    LOAD_REG_IMMEDIATE(r0, MSR_SF | MSR_FP | MSR_ME | MSR_DR | MSR_IR)
+    MTMSRD(r0)
+#endif
+	LOAD_REG_IMMEDIATE(r8, saved_stack)		// restore stack pointer
+	mr	r1,r8
+	PPC_LL r0, (STACKFRAME_MINSIZE + PPC_LR_STKOFF)(r1)
+	mtlr	r0
+	addi	r1, r1, STACKFRAME_MINSIZE
+	// XXX: should restore r12-r31 etc..
+	// we should not really come here though
+	blrl
-- 
1.7.10.4




More information about the OpenBIOS mailing list