[OpenBIOS] [PATCHv2 3/4] ppc: use separate context to call client images

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


Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/arch/ppc/qemu/context.c |   15 +++++++++++++++
 openbios-devel/arch/ppc/qemu/init.c    |    4 +++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/openbios-devel/arch/ppc/qemu/context.c b/openbios-devel/arch/ppc/qemu/context.c
index 93b6175..78205a2 100644
--- a/openbios-devel/arch/ppc/qemu/context.c
+++ b/openbios-devel/arch/ppc/qemu/context.c
@@ -32,6 +32,7 @@ void __exit_context(void); /* assembly routine */
 
 unsigned int start_elf(unsigned long entry_point, unsigned long param);
 void entry(void);
+void of_client_callback(void);
 
 /*
  * Main context structure
@@ -116,8 +117,22 @@ unsigned int start_elf(unsigned long entry_point, unsigned long param)
 {
     struct context *ctx;
 
+    /* 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
+     */
+    
     ctx = init_context(image_stack, sizeof image_stack, 1);
     ctx->pc = entry_point;
+    ctx->regs[REG_R5] = (unsigned long)of_client_callback;
+    ctx->regs[REG_R6] = 0;
+    ctx->regs[REG_R7] = 0;
     ctx->param[0] = param;
    
     ctx = switch_to(ctx);
diff --git a/openbios-devel/arch/ppc/qemu/init.c b/openbios-devel/arch/ppc/qemu/init.c
index b76c570..8f264f4 100644
--- a/openbios-devel/arch/ppc/qemu/init.c
+++ b/openbios-devel/arch/ppc/qemu/init.c
@@ -35,6 +35,7 @@
 #define NO_QEMU_PROTOS
 #include "arch/common/fw_cfg.h"
 #include "arch/ppc/processor.h"
+#include "context.h"
 
 #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
 
@@ -595,6 +596,7 @@ id_cpu(void)
 }
 
 static void go(void);
+unsigned int start_elf(unsigned long entry_point, unsigned long param);
 
 static void
 go(void)
@@ -609,7 +611,7 @@ go(void)
     feval("saved-program-state >sps.entry @");
     addr = POP();
 
-    call_elf(0, 0, addr);
+    start_elf((unsigned long)addr, 0);
 }
 
 static void kvm_of_init(void)
-- 
1.7.10.4




More information about the OpenBIOS mailing list