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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Nov 22 23:07:21 2009 +0100

skins: add per-skin signal handler, and dispatch function.

---

 include/asm-generic/bits/bind.h |   10 ++++++--
 include/asm-generic/syscall.h   |   44 ++++++++++++++++++++++++++++++++------
 src/skins/common/bind.c         |   23 +++++++++++++++++++-
 src/skins/native/init.c         |    2 +-
 src/skins/posix/init.c          |    3 +-
 src/skins/psos+/init.c          |    3 +-
 src/skins/rtai/init.c           |    3 +-
 src/skins/rtdm/init.c           |    3 +-
 src/skins/uitron/init.c         |    3 +-
 src/skins/vrtx/init.c           |    2 +-
 src/skins/vxworks/init.c        |    2 +-
 11 files changed, 78 insertions(+), 20 deletions(-)

diff --git a/include/asm-generic/bits/bind.h b/include/asm-generic/bits/bind.h
index 7da2c43..83b2c7e 100644
--- a/include/asm-generic/bits/bind.h
+++ b/include/asm-generic/bits/bind.h
@@ -5,15 +5,19 @@
 #include <stdlib.h>
 #include <signal.h>
 
+typedef void xnsighandler(union xnsiginfo *si);
+
 void xeno_handle_mlock_alert(int sig);
 
 int 
-xeno_bind_skin_opt(unsigned skin_magic, const char *skin, const char *module);
+xeno_bind_skin_opt(unsigned skin_magic, const char *skin, 
+                  const char *module, xnsighandler *sighandler);
 
 static inline int 
-xeno_bind_skin(unsigned skin_magic, const char *skin, const char *module)
+xeno_bind_skin(unsigned skin_magic, const char *skin, 
+              const char *module, xnsighandler *sighandler)
 {
-       int muxid = xeno_bind_skin_opt(skin_magic, skin, module);
+       int muxid = xeno_bind_skin_opt(skin_magic, skin, module, sighandler);
        struct sigaction sa;
 
        if (muxid == -1) {
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
index 09c9128..3db3e09 100644
--- a/include/asm-generic/syscall.h
+++ b/include/asm-generic/syscall.h
@@ -20,6 +20,17 @@
 #ifndef _XENO_ASM_GENERIC_SYSCALL_H
 #define _XENO_ASM_GENERIC_SYSCALL_H
 
+#ifdef __KERNEL__
+#include <asm/uaccess.h>
+#include <asm/xenomai/wrappers.h>
+#include <asm/xenomai/hal.h>
+#include <linux/types.h>
+#include <linux/signal.h>
+#else /* !__KERNEL__ */
+#include <sys/types.h>
+#include <signal.h>
+#endif /* !__KERNEL__ */
+
 #include <asm/xenomai/features.h>
 
 /* Xenomai multiplexer syscall. */
@@ -51,12 +62,20 @@ typedef struct xnsysinfo {
 #define sigshadow_arg(code) (((code) >> 8) & 0xff)
 #define sigshadow_int(action, arg) ((action) | ((arg) << 8))
 
-#ifdef __KERNEL__
+union xnsiginfo {
+       struct siginfo pse51_si;
+};
 
-#include <linux/types.h>
-#include <asm/uaccess.h>
-#include <asm/xenomai/wrappers.h>
-#include <asm/xenomai/hal.h>
+struct xnsig {
+       unsigned nsigs;
+       unsigned remaining;
+       struct {
+               unsigned muxid;
+               union xnsiginfo si;
+       } pending[16];
+};
+
+#ifdef __KERNEL__
 
 struct task_struct;
 struct pt_regs;
@@ -137,8 +156,19 @@ static inline int __xn_safe_strncpy_from_user(char *dst,
 }
 
 #else /* !__KERNEL__ */
-#include <sys/types.h>
-#endif /* __KERNEL__ */
+
+int __xnsig_dispatch(struct xnsig *sigs, int cumulated_error, int last_error);
+
+static inline int xnsig_dispatch(struct xnsig *sigs, int cumulated, int last)
+{
+       if (sigs->nsigs)
+               cumulated = __xnsig_dispatch(sigs, cumulated, last);
+       else
+               cumulated = last;
+       return cumulated;
+}
+
+#endif /* !__KERNEL__ */
 
 typedef struct xncompletion {
        long syncflag;          /* Semaphore variable. */
diff --git a/src/skins/common/bind.c b/src/skins/common/bind.c
index e8bb454..64c31e2 100644
--- a/src/skins/common/bind.c
+++ b/src/skins/common/bind.c
@@ -8,6 +8,8 @@
 #include <asm-generic/xenomai/bits/bind.h>
 #include "sem_heap.h"
 
+static xnsighandler *xnsig_handlers[32];
+
 void __attribute__((weak)) xeno_sigill_handler(int sig)
 {
        fprintf(stderr, "Xenomai or CONFIG_XENO_OPT_PERVASIVE disabled.\n"
@@ -17,8 +19,25 @@ void __attribute__((weak)) xeno_sigill_handler(int sig)
 
 struct xnfeatinfo xeno_featinfo;
 
+int __xnsig_dispatch(struct xnsig *sigs, int cumulated_error, int last_error)
+{
+       unsigned i;
+
+       for (i = 0; i < sigs->nsigs; i++) {
+               xnsighandler *handler;
+               
+               handler = xnsig_handlers[sigs->pending[i].muxid];
+               if (handler)
+                       handler(&sigs->pending[i].si);
+       }
+       if (cumulated_error == -ERESTART)
+               cumulated_error = last_error;
+       return cumulated_error;
+}
+
 int 
-xeno_bind_skin_opt(unsigned skin_magic, const char *skin, const char *module)
+xeno_bind_skin_opt(unsigned skin_magic, const char *skin, 
+                  const char *module, xnsighandler *handler)
 {
        sighandler_t old_sigill_handler;
        xnfeatinfo_t finfo;
@@ -63,6 +82,8 @@ xeno_bind_skin_opt(unsigned skin_magic, const char *skin, 
const char *module)
                exit(EXIT_FAILURE);
        }
 
+       xnsig_handlers[muxid] = handler;
+
 #ifdef xeno_arch_features_check
        xeno_arch_features_check();
 #endif /* xeno_arch_features_check */
diff --git a/src/skins/native/init.c b/src/skins/native/init.c
index 215acc1..197f3ce 100644
--- a/src/skins/native/init.c
+++ b/src/skins/native/init.c
@@ -55,7 +55,7 @@ static __attribute__ ((constructor))
 void __init_xeno_interface(void)
 {
        __native_muxid =
-           xeno_bind_skin(XENO_SKIN_MAGIC, "native", "xeno_native");
+               xeno_bind_skin(XENO_SKIN_MAGIC, "native", "xeno_native", NULL);
 
        native_timer_init(__native_muxid);
        
diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c
index 415997f..6028dd9 100644
--- a/src/skins/posix/init.c
+++ b/src/skins/posix/init.c
@@ -53,8 +53,7 @@ void __init_posix_interface(void)
 #endif /* !CONFIG_XENO_LIBS_DLOPEN */
        int muxid, err;
 
-       muxid =
-           xeno_bind_skin(PSE51_SKIN_MAGIC, "POSIX", "xeno_posix");
+       muxid = xeno_bind_skin(PSE51_SKIN_MAGIC, "POSIX", "xeno_posix", NULL);
 
 #ifdef XNARCH_HAVE_NONPRIV_TSC
        pse51_clock_init(muxid);
diff --git a/src/skins/psos+/init.c b/src/skins/psos+/init.c
index 6f744e9..42a0e1d 100644
--- a/src/skins/psos+/init.c
+++ b/src/skins/psos+/init.c
@@ -32,7 +32,8 @@ void __init_xeno_interface(void)
 {
        u_long err, tid;
 
-       __psos_muxid = xeno_bind_skin(PSOS_SKIN_MAGIC, "psos", "xeno_psos");
+       __psos_muxid = xeno_bind_skin(PSOS_SKIN_MAGIC, 
+                                     "psos", "xeno_psos", NULL);
 
        err = XENOMAI_SYSCALL2(__xn_sys_info, __psos_muxid, &__psos_sysinfo);
 
diff --git a/src/skins/rtai/init.c b/src/skins/rtai/init.c
index 6922883..0939ecf 100644
--- a/src/skins/rtai/init.c
+++ b/src/skins/rtai/init.c
@@ -28,6 +28,7 @@ int __rtai_muxid = -1;
 static __attribute__ ((constructor))
 void __init_rtai_interface(void)
 {
-       __rtai_muxid = xeno_bind_skin(RTAI_SKIN_MAGIC, "RTAI", "xeno_rtai");
+       __rtai_muxid = xeno_bind_skin(RTAI_SKIN_MAGIC, 
+                                     "RTAI", "xeno_rtai", NULL);
        __rtai_muxid = __xn_mux_shifted_id(__rtai_muxid);
 }
diff --git a/src/skins/rtdm/init.c b/src/skins/rtdm/init.c
index c4ae949..f079550 100644
--- a/src/skins/rtdm/init.c
+++ b/src/skins/rtdm/init.c
@@ -33,7 +33,8 @@ void __init_rtdm_interface(void)
           device or socket. */
 
        __rtdm_muxid =
-               xeno_bind_skin_opt(RTDM_SKIN_MAGIC, "rtdm", "xeno_rtdm");
+               xeno_bind_skin_opt(RTDM_SKIN_MAGIC, 
+                                  "rtdm", "xeno_rtdm", NULL);
        __rtdm_muxid = __xn_mux_shifted_id(__rtdm_muxid);
 
 }
diff --git a/src/skins/uitron/init.c b/src/skins/uitron/init.c
index 6c23c46..7dcdcef 100644
--- a/src/skins/uitron/init.c
+++ b/src/skins/uitron/init.c
@@ -31,7 +31,8 @@ void __init_xeno_interface(void)
        T_CTSK pk_ctsk;
        ER err;
 
-       __uitron_muxid = xeno_bind_skin(uITRON_SKIN_MAGIC, "uitron", 
"xeno_uitron");
+       __uitron_muxid = xeno_bind_skin(uITRON_SKIN_MAGIC, 
+                                       "uitron", "xeno_uitron", NULL);
 
        __uitron_muxid = __xn_mux_shifted_id(__uitron_muxid);
 
diff --git a/src/skins/vrtx/init.c b/src/skins/vrtx/init.c
index 96b2599..f14cd20 100644
--- a/src/skins/vrtx/init.c
+++ b/src/skins/vrtx/init.c
@@ -53,6 +53,6 @@ static __attribute__ ((constructor))
 void __init_xeno_interface(void)
 {
        __vrtx_muxid =
-           xeno_bind_skin(VRTX_SKIN_MAGIC, "vrtx", "xeno_vrtx");
+               xeno_bind_skin(VRTX_SKIN_MAGIC, "vrtx", "xeno_vrtx", NULL);
        __vrtx_muxid = __xn_mux_shifted_id(__vrtx_muxid);
 }
diff --git a/src/skins/vxworks/init.c b/src/skins/vxworks/init.c
index 6a123a2..c61b4d9 100644
--- a/src/skins/vxworks/init.c
+++ b/src/skins/vxworks/init.c
@@ -53,6 +53,6 @@ static __attribute__ ((constructor))
 void __init_xeno_interface(void)
 {
        __vxworks_muxid = xeno_bind_skin(VXWORKS_SKIN_MAGIC,
-                                        "vxworks", "xeno_vxworks");
+                                        "vxworks", "xeno_vxworks", NULL);
        __vxworks_muxid = __xn_mux_shifted_id(__vxworks_muxid);
 }


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

Reply via email to