Module: xenomai-gch
Branch: for-head
Commit: ee967a81fdfdc4e57eb0e11c7206bd49e90e4181
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=ee967a81fdfdc4e57eb0e11c7206bd49e90e4181

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Dec  1 23:47:02 2009 +0100

nios: implement signals handling

---

 include/asm-nios2/syscall.h |   73 +++++++++++++++++++++++++++++++-----------
 1 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/include/asm-nios2/syscall.h b/include/asm-nios2/syscall.h
index 7a63e71..08d56c7 100644
--- a/include/asm-nios2/syscall.h
+++ b/include/asm-nios2/syscall.h
@@ -42,6 +42,7 @@
 #define __xn_reg_arg3(regs)   ((regs)->r6)
 #define __xn_reg_arg4(regs)   ((regs)->r7)
 #define __xn_reg_arg5(regs)   ((regs)->r8)
+#define __xn_reg_sigp(regs)   ((regs)->r9)
 
 #define __xn_reg_mux_p(regs)        ((__xn_reg_mux(regs) & 0xffff) == 
__xn_sys_mux)
 #define __xn_mux_id(regs)           ((__xn_reg_mux(regs) >> 24) & 0xff)
@@ -73,6 +74,8 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
 
 #else /* !__KERNEL__ */
 
+#include <errno.h>
+
 /*
  * The following code defines an inline syscall mechanism used by
  * Xenomai's real-time interfaces to invoke the skin module
@@ -81,24 +84,26 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
 
 #include <asm/traps.h>
 
-#define __emit_syscall0(muxcode)                               \
+#define __emit_syscall0(muxcode, sigp)                         \
        ({                                                      \
                long __ret;                                     \
                                                                \
                __asm__ __volatile__ (                          \
                        "movi r2, %2\n\t"                       \
                        "mov r3, %1\n\t"                        \
+                       "mov r9, %3\n\t"                        \
                        "trap\n\t"                              \
                        "mov %0, r2\n\t"                        \
                        : "=r"(__ret)                           \
                        : "r"(muxcode),                         \
-                         "i"(TRAP_ID_SYSCALL)                  \
-                       : "r2", "r3"                            \
+                         "i"(TRAP_ID_SYSCALL),                 \
+                         "r"((long)sigp)                       \
+                       : "r2", "r3", "r9"                      \
                );                                              \
                __ret;                                          \
        })
 
-#define __emit_syscall1(muxcode,a1)                            \
+#define __emit_syscall1(muxcode, sigp, a1)                     \
        ({                                                      \
                long __ret;                                     \
                                                                \
@@ -106,18 +111,20 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                        "movi r2, %2\n\t"                       \
                        "mov r3, %1\n\t"                        \
                        "mov r4, %3\n\t"                        \
+                       "mov r9, %4\n\t"                        \
                        "trap\n\t"                              \
                        "mov %0, r2\n\t"                        \
                        : "=r"(__ret)                           \
                        : "r"(muxcode),                         \
                          "i"(TRAP_ID_SYSCALL),                 \
-                         "r" ((long)a1)                        \
-                       : "r2", "r3", "r4"                      \
+                         "r" ((long)a1),                       \
+                         "r" ((long)sigp)                      \
+                       : "r2", "r3", "r4", "r9"                \
                );                                              \
                __ret;                                          \
        })
 
-#define __emit_syscall2(muxcode,a1,a2)                         \
+#define __emit_syscall2(muxcode, sigp, a1, a2)                 \
        ({                                                      \
                long __ret;                                     \
                                                                \
@@ -126,19 +133,21 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                        "mov r3, %1\n\t"                        \
                        "mov r4, %3\n\t"                        \
                        "mov r5, %4\n\t"                        \
+                       "mov r9, %5\n\t"                        \
                        "trap\n\t"                              \
                        "mov %0, r2\n\t"                        \
                        : "=r"(__ret)                           \
                        : "r"(muxcode),                         \
                          "i"(TRAP_ID_SYSCALL),                 \
                          "r" ((long)a1),                       \
-                         "r" ((long)a2)                        \
-                       : "r2", "r3", "r4", "r5"                \
+                         "r" ((long)a2),                       \
+                         "r" ((long)sigp)                      \
+                       : "r2", "r3", "r4", "r5", "r9"          \
                );                                              \
                __ret;                                          \
        })
 
-#define __emit_syscall3(muxcode,a1,a2,a3)                      \
+#define __emit_syscall3(muxcode, sigp, a1, a2, a3)             \
        ({                                                      \
                long __ret;                                     \
                                                                \
@@ -148,6 +157,7 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                        "mov r4, %3\n\t"                        \
                        "mov r5, %4\n\t"                        \
                        "mov r6, %5\n\t"                        \
+                       "mov r9, %6\n\t"                        \
                        "trap\n\t"                              \
                        "mov %0, r2\n\t"                        \
                        : "=r"(__ret)                           \
@@ -155,13 +165,14 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                          "i"(TRAP_ID_SYSCALL),                 \
                          "r" ((long)a1),                       \
                          "r" ((long)a2),                       \
-                         "r" ((long)a3)                        \
-                       : "r2", "r3", "r4", "r5", "r6"          \
+                         "r" ((long)a3),                       \
+                         "r" ((long)sigp)                      \
+                       : "r2", "r3", "r4", "r5", "r6", "r9"    \
                );                                              \
                __ret;                                          \
        })
 
-#define __emit_syscall4(muxcode,a1,a2,a3,a4)                   \
+#define __emit_syscall4(muxcode, sigp, a1, a2, a3, a4)         \
        ({                                                      \
                long __ret;                                     \
                                                                \
@@ -172,6 +183,7 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                        "mov r5, %4\n\t"                        \
                        "mov r6, %5\n\t"                        \
                        "mov r7, %6\n\t"                        \
+                       "mov r9, %7\n\t"                        \
                        "trap\n\t"                              \
                        "mov %0, r2\n\t"                        \
                        : "=r"(__ret)                           \
@@ -180,13 +192,14 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                          "r" ((long)a1),                       \
                          "r" ((long)a2),                       \
                          "r" ((long)a3),                       \
-                         "r" ((long)a4)                        \
-                       : "r2", "r3", "r4", "r5", "r6", "r7"    \
+                         "r" ((long)a4),                       \
+                         "r" ((long)sigp)                      \
+                       : "r2", "r3", "r4", "r5", "r6", "r7", "r9"      \
                );                                              \
                __ret;                                          \
        })
 
-#define __emit_syscall5(muxcode,a1,a2,a3,a4,a5)                        \
+#define __emit_syscall5(muxcode, sigp, a1, a2, a3, a4, a5)     \
        ({                                                      \
                long __ret;                                     \
                                                                \
@@ -198,6 +211,7 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                        "mov r6, %5\n\t"                        \
                        "mov r7, %6\n\t"                        \
                        "mov r8, %7\n\t"                        \
+                       "mov r9, %8\n\t"                        \
                        "trap\n\t"                              \
                        "mov %0, r2\n\t"                        \
                        : "=r"(__ret)                           \
@@ -207,15 +221,36 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
                          "r" ((long)a2),                       \
                          "r" ((long)a3),                       \
                          "r" ((long)a4),                       \
-                         "r" ((long)a5)                        \
-                       : "r2", "r3", "r4", "r5", "r6", "r7", "r8"      \
+                         "r" ((long)a5),                       \
+                         "r" ((long)sigp)                      \
+                       : "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
                );                                              \
                __ret;                                          \
        })
 
-#define XENOMAI_DO_SYSCALL(nr, shifted_id, op, args...) \
+#define XENOMAI_DO_SYSCALL_INNER(nr, shifted_id, op, args...) \
     __emit_syscall##nr(__xn_mux_code(shifted_id,op), ##args)
 
+#define XENOMAI_DO_SYSCALL(nr, shifted_id, op, args...)                        
\
+       ({                                                              \
+               int __err__, __res__ = -ERESTART;                       \
+               struct xnsig __sigs__;                                  \
+                                                                       \
+               do {                                                    \
+                       __sigs__.nsigs = 0;                             \
+                       __err__ = XENOMAI_DO_SYSCALL_INNER(nr, shifted_id,      
\
+                                                      op, &__sigs__, ##args);  
\
+                       __res__ = xnsig_dispatch(&__sigs__, __res__, __err__);  
\
+                       while (__sigs__.nsigs && __sigs__.remaining) {  \
+                               __sigs__.nsigs = 0;                     \
+                               __err__ = XENOMAI_DO_SYSCALL_INNER      \
+                                       (0, 0, __xn_sys_get_next_sigs, 
&__sigs__);      \
+                               __res__ = xnsig_dispatch(&__sigs__, __res__, 
__err__);  \
+                       }                                               \
+               } while (__res__ == -ERESTART);                         \
+               __res__;                                                \
+       })
+
 #define XENOMAI_SYSCALL0(op)                XENOMAI_DO_SYSCALL(0,0,op)
 #define XENOMAI_SYSCALL1(op,a1)             XENOMAI_DO_SYSCALL(1,0,op,a1)
 #define XENOMAI_SYSCALL2(op,a1,a2)          XENOMAI_DO_SYSCALL(2,0,op,a1,a2)


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

Reply via email to