Module: xenomai-rpm
Branch: for-upstream
Commit: 7c11867db1368aa0a280c4d6d4bf7f682ee51ce3
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=7c11867db1368aa0a280c4d6d4bf7f682ee51ce3

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Jun  5 11:57:40 2010 +0200

powerpc: enable MAYDAY support

---

 include/asm-powerpc/bits/shadow.h |   61 +++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/system.h      |    8 ++++-
 2 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/include/asm-powerpc/bits/shadow.h 
b/include/asm-powerpc/bits/shadow.h
index 47b65a2..7f3554e 100644
--- a/include/asm-powerpc/bits/shadow.h
+++ b/include/asm-powerpc/bits/shadow.h
@@ -27,6 +27,12 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#include <asm/cache.h>
+#else
+#include <asm/cacheflush.h>
+#endif
+
 static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
                                          struct xnthread *thread,
                                          const char *name)
@@ -59,4 +65,59 @@ static inline int xnarch_local_syscall(struct pt_regs *regs)
 
 #define xnarch_schedule_tail(prev) do { } while(0)
 
+#ifdef XNARCH_HAVE_MAYDAY
+
+static inline void xnarch_setup_mayday_page(void *page)
+{
+       /*
+        * We want this code to appear at the top of the MAYDAY page:
+        *
+        * 3c 00 0b 00  lis     r0,mux_c...@h
+        * 60 00 02 2b  ori     r0,r0,mux_c...@l
+        * 39 00 00 00  li      r8,0
+        * 44 00 00 02  sc
+        * 00 b0 0b 00  .long   0x00b00b00 <illegal insn>
+        *
+        * We don't mess with CCR here, so no need to save/restore it
+        * in handle/fixup code.
+        */
+       u32 mux, insn[5];
+
+       mux = __xn_mux_code(0, __xn_sys_mayday);
+       insn[0] = 0x3c000000 | (mux >> 16);
+       insn[1] = 0x60000000 | (mux & 0xffff);
+       insn[2] = 0x39000000;
+       insn[3] = 0x44000002;
+       insn[4] = 0x00b00b00;
+       memcpy(page, insn, sizeof(insn));
+
+       flush_dcache_range((unsigned long)page,
+                          (unsigned long)page + sizeof(insn));
+}
+
+static inline void xnarch_call_mayday(void)
+{
+       rthal_return_intercept(current);
+}
+
+static inline void xnarch_handle_mayday(struct xnarchtcb *tcb,
+                                       struct pt_regs *regs,
+                                       unsigned long tramp)
+{
+       tcb->mayday.nip = regs->nip;
+       tcb->mayday.r0 = regs->gpr[0];
+       tcb->mayday.r8 = regs->gpr[8];
+       regs->nip = tramp;
+}
+
+static inline void xnarch_fixup_mayday(struct xnarchtcb *tcb,
+                                      struct pt_regs *regs)
+{
+       regs->nip = tcb->mayday.nip;
+       regs->gpr[0] = tcb->mayday.r0;
+       regs->gpr[8] = tcb->mayday.r8;
+}
+
+#endif /* XNARCH_HAVE_MAYDAY */
+
 #endif /* !_XENO_ASM_POWERPC_BITS_SHADOW_H */
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 0e1072a..4044f43 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -51,7 +51,13 @@ typedef struct xnarchtcb {   /* Per-thread arch-dependent 
block */
        struct thread_struct *tsp;      /* Pointer to the active thread struct 
(&ts or &user->thread). */
        struct mm_struct *mm;
        struct mm_struct *active_mm;
-
+#ifdef XNARCH_HAVE_MAYDAY
+       struct {
+               unsigned long nip;
+               unsigned long r0;
+               unsigned long r8;
+       } mayday;
+#endif
        /* Kernel mode side */
        struct thread_struct ts;        /* Holds kernel-based thread context. */
 #ifdef CONFIG_XENO_HW_UNLOCKED_SWITCH


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to