Module: xenomai-3
Branch: next
Commit: 8876746e82af2d46af91eb93504f498b4d1f4b39
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8876746e82af2d46af91eb93504f498b4d1f4b39

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Oct 29 15:41:33 2014 +0100

cobalt/x86: enable support for x32 ABI model

---

 .../arch/x86/include/asm/xenomai/syscall32-table.h |   16 +++++++++
 .../arch/x86/include/asm/xenomai/syscall32.h       |    7 +++-
 kernel/cobalt/posix/syscall32.c                    |   34 ++++++++++++++++++++
 kernel/cobalt/posix/syscall32.h                    |    6 ++++
 4 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
index 9f2f000..1dce4e7 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
@@ -28,6 +28,7 @@ __COBALT_CALL32emu_THUNK(thread_create)
 __COBALT_CALL32emu_THUNK(thread_setschedparam_ex)
 __COBALT_CALL32emu_THUNK(thread_getschedparam_ex)
 __COBALT_CALL32emu_THUNK(sem_open)
+__COBALT_CALL32x_THUNK(sem_open)
 __COBALT_CALL32emu_THUNK(sem_timedwait)
 __COBALT_CALL32emu_THUNK(clock_getres)
 __COBALT_CALL32emu_THUNK(clock_gettime)
@@ -36,29 +37,44 @@ __COBALT_CALL32emu_THUNK(clock_nanosleep)
 __COBALT_CALL32emu_THUNK(mutex_timedlock)
 __COBALT_CALL32emu_THUNK(cond_wait_prologue)
 __COBALT_CALL32emu_THUNK(mq_open)
+__COBALT_CALL32x_THUNK(mq_open)
 __COBALT_CALL32emu_THUNK(mq_getattr)
+__COBALT_CALL32x_THUNK(mq_getattr)
 __COBALT_CALL32emu_THUNK(mq_timedsend)
 __COBALT_CALL32emu_THUNK(mq_timedreceive)
+__COBALT_CALL32x_pure_THUNK(mq_timedreceive)
 __COBALT_CALL32emu_THUNK(mq_notify)
+__COBALT_CALL32x_THUNK(mq_notify)
 __COBALT_CALL32emu_THUNK(sched_weightprio)
 __COBALT_CALL32emu_THUNK(sched_setconfig_np)
 __COBALT_CALL32emu_THUNK(sched_getconfig_np)
 __COBALT_CALL32emu_THUNK(timer_create)
+__COBALT_CALL32x_THUNK(timer_create)
 __COBALT_CALL32emu_THUNK(timer_settime)
 __COBALT_CALL32emu_THUNK(timer_gettime)
 __COBALT_CALL32emu_THUNK(timerfd_settime)
 __COBALT_CALL32emu_THUNK(timerfd_gettime)
 __COBALT_CALL32emu_THUNK(sigwait)
+__COBALT_CALL32x_THUNK(sigwait)
 __COBALT_CALL32emu_THUNK(sigtimedwait)
+__COBALT_CALL32x_THUNK(sigtimedwait)
 __COBALT_CALL32emu_THUNK(sigwaitinfo)
+__COBALT_CALL32x_THUNK(sigwaitinfo)
 __COBALT_CALL32emu_THUNK(sigpending)
+__COBALT_CALL32x_THUNK(sigpending)
 __COBALT_CALL32emu_THUNK(sigqueue)
+__COBALT_CALL32x_THUNK(sigqueue)
 __COBALT_CALL32emu_THUNK(monitor_wait)
 __COBALT_CALL32emu_THUNK(event_wait)
 __COBALT_CALL32emu_THUNK(select)
+__COBALT_CALL32x_THUNK(select)
 __COBALT_CALL32emu_THUNK(recvmsg)
+__COBALT_CALL32x_THUNK(recvmsg)
 __COBALT_CALL32emu_THUNK(sendmsg)
+__COBALT_CALL32x_THUNK(sendmsg)
 __COBALT_CALL32emu_THUNK(mmap)
+__COBALT_CALL32x_THUNK(mmap)
 __COBALT_CALL32emu_THUNK(backtrace)
+__COBALT_CALL32x_THUNK(backtrace)
 
 #endif /* !_COBALT_X86_ASM_SYSCALL32_TABLE_H */
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
index e4890a6..5604580 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
@@ -55,9 +55,12 @@
        , [sc_cobalt_ ## __name + __COBALT_X32_BASE] = __handler
 
 /* x32 thunk installation */
-#define __COBALT_CALL32x_THUNK(__name) \
+#define __COBALT_CALL32x_pure_THUNK(__name)    \
        __COBALT_CALL32x_ENTRY(__name, __syshand32x__(__name))
 
+#define __COBALT_CALL32x_THUNK(__name) \
+       __COBALT_CALL32x_ENTRY(__name, __syshand32emu__(__name))
+
 /* x32 thunk implementation. */
 #define COBALT_SYSCALL32x(__name, __mode, __type, __args)      \
        __typeof__(__type) cobalt32x_ ## __name __args
@@ -80,6 +83,8 @@
 
 #define __COBALT_CALL32x_ENTRY(__name, __handler)
 
+#define __COBALT_CALL32x_pure_THUNK(__name)
+
 #define __COBALT_CALL32x_THUNK(__name)
 
 #define COBALT_SYSCALL32x_DECL(__name, __type, __args)
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 61c619f..17066bc 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -261,6 +261,14 @@ COBALT_SYSCALL32emu(mq_timedreceive, primary,
        return ret ?: __xn_safe_copy_to_user(u_len, &clen, sizeof(*u_len));
 }
 
+static inline int mq_fetch_timeout(struct timespec *ts,
+                                  const void __user *u_ts)
+{
+       return u_ts == NULL ? -EFAULT :
+               __xn_safe_copy_from_user(ts, u_ts, sizeof(*ts));
+
+}
+
 COBALT_SYSCALL32emu(mq_notify, primary,
                    int, (mqd_t fd, const struct compat_sigevent *__user u_cev))
 {
@@ -799,3 +807,29 @@ COBALT_SYSCALL32emu(backtrace, current,
 
        return 0;
 }
+
+#ifdef COBALT_SYSCALL32x
+
+COBALT_SYSCALL32x(mq_timedreceive, primary,
+                 int, (mqd_t uqd, void __user *u_buf,
+                       compat_ssize_t __user *u_len,
+                       unsigned int __user *u_prio,
+                       const struct timespec __user *u_ts))
+{
+       compat_ssize_t clen;
+       ssize_t len;
+       int ret;
+
+       ret = __xn_safe_copy_from_user(&clen, u_len, sizeof(*u_len));
+       if (ret)
+               return ret;
+
+       len = clen;
+       ret = __cobalt_mq_timedreceive(uqd, u_buf, &len, u_prio,
+                                      u_ts, u_ts ? mq_fetch_timeout : NULL);
+       clen = len;
+
+       return ret ?: __xn_safe_copy_to_user(u_len, &clen, sizeof(*u_len));
+}
+
+#endif /* COBALT_SYSCALL32x */
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index 7c2be00..1918024 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -91,6 +91,12 @@ COBALT_SYSCALL32emu_DECL(mq_timedreceive,
                               unsigned int __user *u_prio,
                               const struct compat_timespec __user *u_ts));
 
+COBALT_SYSCALL32x_DECL(mq_timedreceive,
+                      int, (mqd_t uqd, void __user *u_buf,
+                            compat_ssize_t __user *u_len,
+                            unsigned int __user *u_prio,
+                            const struct timespec __user *u_ts));
+
 COBALT_SYSCALL32emu_DECL(mq_notify,
                         int, (mqd_t fd, const struct compat_sigevent *__user 
u_cev));
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to