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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Jun 13 17:26:05 2010 +0200

blackfin: enable MAYDAY support

---

 include/asm-blackfin/bits/shadow.h |   78 ++++++++++++++++++++++++++++++++++++
 include/asm-blackfin/system.h      |    7 +++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/include/asm-blackfin/bits/shadow.h 
b/include/asm-blackfin/bits/shadow.h
index f44d25d..1a77fe4 100644
--- a/include/asm-blackfin/bits/shadow.h
+++ b/include/asm-blackfin/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)
@@ -66,4 +68,80 @@ 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:
+        *
+        * 45 e1 0c 00    R5.H = 0xc
+        * 05 e1 2b 02    R5.L = 0x22b
+        * 05 32          P0 = R5
+        * 05 60          R5 = 0x0 (X)
+        * a0 00          EXCPT 0x0
+        * cd ef          <bug opcode>
+        *
+        * We don't mess with ASTAT here, so no need to save/restore
+        * it in handle/fixup code.
+        */
+       static const struct {
+               struct __attribute__ ((__packed__)) {
+                       u16 op;
+                       u16 imm;
+               } load_r5h;
+               struct __attribute__ ((__packed__)) {
+                       u16 op;
+                       u16 imm;
+               } load_r5l;
+               u16 mov_p0;
+               u16 clear_r5;
+               u16 syscall;
+               u16 bug;
+       } code = {
+               .load_r5h = {
+                       .op = 0xe145,
+                       .imm = __xn_mux_code(0, __xn_sys_mayday) >> 16
+               },
+               .load_r5l = {
+                       .op = 0xe105,
+                       .imm = __xn_mux_code(0, __xn_sys_mayday) & 0xffff
+               },
+               .mov_p0 = 0x3205,
+               .clear_r5 = 0x6005,
+               .syscall = 0x00a0,
+               .bug = BFIN_BUG_OPCODE,
+       };
+
+       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.pc = regs->pc;
+       tcb->mayday.p0 = regs->p0;
+       tcb->mayday.r5 = regs->r5;
+       regs->pc = tramp;       /* i.e. RETI */
+}
+
+static inline void xnarch_fixup_mayday(struct xnarchtcb *tcb,
+                                      struct pt_regs *regs)
+{
+       regs->pc = tcb->mayday.pc;
+       regs->p0 = tcb->mayday.p0;
+       regs->r5 = tcb->mayday.r5;
+}
+
+#endif /* XNARCH_HAVE_MAYDAY */
+
 #endif /* !_XENO_ASM_BLACKFIN_BITS_SHADOW_H */
diff --git a/include/asm-blackfin/system.h b/include/asm-blackfin/system.h
index f7a46b2..b4be882 100644
--- a/include/asm-blackfin/system.h
+++ b/include/asm-blackfin/system.h
@@ -53,6 +53,13 @@ typedef struct xnarchtcb {   /* Per-thread arch-dependent 
block */
     struct task_struct *active_task;    /* Active user-space task */
 #endif
     struct thread_struct *tsp; /* Pointer to the active thread struct (&ts or 
&user->thread). */
+#ifdef XNARCH_HAVE_MAYDAY
+       struct {
+               unsigned long pc;
+               unsigned long p0;
+               unsigned long r5;
+       } 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