Module: xenomai-rpm
Branch: queue/vfile
Commit: bebc48ced23c39721190a0ed07ee3832b34ac9fa
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=bebc48ced23c39721190a0ed07ee3832b34ac9fa

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Jun 14 18:24:14 2010 +0200

nios2: enable MAYDAY support

---

 include/asm-nios2/bits/shadow.h |   65 +++++++++++++++++++++++++++++++++++++++
 include/asm-nios2/system.h      |    8 +++++
 2 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/include/asm-nios2/bits/shadow.h b/include/asm-nios2/bits/shadow.h
index 1d1969a..8917045 100644
--- a/include/asm-nios2/bits/shadow.h
+++ b/include/asm-nios2/bits/shadow.h
@@ -24,6 +24,8 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm/cacheflush.h>
+
 static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
                                          struct xnthread *thread,
                                          const char *name)
@@ -63,4 +65,67 @@ 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:
+        *
+        *      00c00334        movhi   r3,#__xn_sys_mayday
+        *      18c08ac4        addi    r3,r3,#__xn_sys_mux
+        *      00800004        movi    r2,0
+        *      02400004        movi    r9,0
+        *      003b683a        trap
+        *      003fff06        br      .
+        */
+       static const struct {
+               u32 movhi_r3h;
+               u32 addi_r3l;
+               u32 movi_r2;
+               u32 movi_r9;
+               u32 syscall;
+               u32 bug;
+       } code = {
+               .movhi_r3h = 0x00c00334,
+               .addi_r3l = 0x18c08ac4,
+               .movi_r2 = 0x00800004,
+               .movi_r9 = 0x02400004,
+               .syscall = 0x003b683a,
+               .bug = 0x003fff06
+       };
+
+       memcpy(page, &code, sizeof(code));
+
+       flush_dcache_range((unsigned long)page,
+                          (unsigned long)page + sizeof(code));
+}
+
+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.ea = regs->ea;
+       tcb->mayday.r2 = regs->r2;
+       tcb->mayday.r3 = regs->r3;
+       tcb->mayday.r9 = regs->r9;
+       regs->ea = tramp;
+}
+
+static inline void xnarch_fixup_mayday(struct xnarchtcb *tcb,
+                                      struct pt_regs *regs)
+{
+       regs->ea = tcb->mayday.ea;
+       regs->r2 = tcb->mayday.r2;
+       regs->r3 = tcb->mayday.r3;
+       regs->r9 = tcb->mayday.r9;
+}
+
+#endif /* XNARCH_HAVE_MAYDAY */
+
 #endif /* !_XENO_ASM_NIOS2_BITS_SHADOW_H */
diff --git a/include/asm-nios2/system.h b/include/asm-nios2/system.h
index 65426d1..a31aadf 100644
--- a/include/asm-nios2/system.h
+++ b/include/asm-nios2/system.h
@@ -48,6 +48,14 @@ typedef struct xnarchtcb {   /* Per-thread arch-dependent 
block */
        struct thread_struct ts;        /* Holds kernel-based thread context. */
        struct task_struct *user_task;  /* Shadowed user-space task */
        struct thread_struct *tsp;      /* Active thread struct */
+#ifdef XNARCH_HAVE_MAYDAY
+       struct {
+               unsigned long ea;
+               unsigned long r2;
+               unsigned long r3;
+               unsigned long r9;
+       } mayday;
+#endif
 
        /* Init block */
        struct xnthread *self;


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

Reply via email to