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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Sep  3 14:25:26 2014 +0200

cobalt: introduce new common syscall tag

The legacy Cobalt tag sitting on the LSB part of the syscall code did
not cope well with the requirement for extending the numbering range,
for supporting the 32->64bit ABI models.

We fix this by reserving bit #28 as a marker for all Cobalt syscalls
(__COBALT_SYSCALL_BIT), which is still compatible with the I-pipe's
current syscall routing rules (i.e. call nr >= NR_syscalls being sent
unconditionally to the head domain).

For all archs, we now have:

nr = syscall_register & ~__COBALT_SYSCALL_BIT.

NOTE: when received, a Cobalt syscall has NOT been cleaned up from any
ABI mode tag bit which might belong to the host kernel,
e.g. __X32_SYSCALL_BIT may be present in syscall_register(orig_ax)
when received for handling an x32 call by a x86_64 host kernel.  Which
means that in the x32 case, we would have to filter out this extra bit
as well:

nr = syscall_register & ~(__X32_SYSCALL_BIT|__COBALT_SYSCALL_BIT).

---

 include/cobalt/uapi/asm-generic/syscall.h          |    2 +-
 .../cobalt/arch/arm/include/asm/xenomai/syscall.h  |   34 ++++++++++----------
 .../arch/arm/include/asm/xenomai/uapi/syscall.h    |    2 +-
 .../arch/blackfin/include/asm/xenomai/syscall.h    |   22 ++++++-------
 .../blackfin/include/asm/xenomai/uapi/syscall.h    |    7 +---
 .../arch/nios2/include/asm/xenomai/syscall.h       |   24 +++++++-------
 .../arch/nios2/include/asm/xenomai/uapi/syscall.h  |    4 +--
 .../arch/powerpc/include/asm/xenomai/syscall.h     |   24 +++++++-------
 .../powerpc/include/asm/xenomai/uapi/syscall.h     |    2 +-
 .../cobalt/arch/sh/include/asm/xenomai/syscall.h   |   22 ++++++-------
 .../arch/sh/include/asm/xenomai/uapi/syscall.h     |    2 +-
 11 files changed, 66 insertions(+), 79 deletions(-)

diff --git a/include/cobalt/uapi/asm-generic/syscall.h 
b/include/cobalt/uapi/asm-generic/syscall.h
index 8af6c04..0cdb032 100644
--- a/include/cobalt/uapi/asm-generic/syscall.h
+++ b/include/cobalt/uapi/asm-generic/syscall.h
@@ -22,7 +22,7 @@
 #include <asm/xenomai/uapi/features.h>
 #include <asm/xenomai/uapi/syscall.h>
 
-#define cobalt_syscall_tag     555     /* Must fit within 15bit */
+#define __COBALT_SYSCALL_BIT   0x10000000
 
 struct cobalt_bindreq {
        /** Features userland requires. */
diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h
index 292d1e5..a8022d2 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h
@@ -28,29 +28,29 @@
 #include <asm/ptrace.h>
 #include <asm-generic/xenomai/syscall.h>
 
-#define __xn_reg_sys(regs)      ((regs)->ARM_ORIG_r0)
-#define __xn_reg_rval(regs)     ((regs)->ARM_r0)
-#define __xn_reg_arg1(regs)     ((regs)->ARM_r1)
-#define __xn_reg_arg2(regs)     ((regs)->ARM_r2)
-#define __xn_reg_arg3(regs)     ((regs)->ARM_r3)
-#define __xn_reg_arg4(regs)     ((regs)->ARM_r4)
-#define __xn_reg_arg5(regs)     ((regs)->ARM_r5)
-#define __xn_reg_pc(regs)       ((regs)->ARM_ip)
-#define __xn_reg_sp(regs)       ((regs)->ARM_sp)
+#ifndef __ARM_NR_ipipe
+/* Legacy pipelines do not define this. */
+#define __ARM_NR_ipipe (__NR_SYSCALL_BASE + XENO_ARM_SYSCALL)
+#endif
 
+#define __xn_reg_sys(__regs)   ((__regs)->ARM_ORIG_r0)
 /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
 #ifdef CONFIG_OABI_COMPAT
-#define __xn_syscall_p(regs)    ( ((regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
-                                 ((regs)->ARM_r7 == __NR_SYSCALL_BASE + 
XENO_ARM_SYSCALL) )
-#define __xn_syslinux_p(regs, nr) \
-                               ( ((regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + 
(nr)) || \
-                                 ((regs)->ARM_r7 == __NR_SYSCALL_BASE + (nr)) )
+#define __xn_syscall_p(__regs) (((__regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
+                                ((__regs)->ARM_r7 == __ARM_NR_ipipe))
 #else /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall_p(regs)      ((regs)->ARM_r7 == __NR_SYSCALL_BASE + 
XENO_ARM_SYSCALL)
-#define __xn_syslinux_p(regs, nr) ((regs)->ARM_r7 == __NR_SYSCALL_BASE + (nr))
+#define __xn_syscall_p(__regs) ((__regs)->ARM_r7 == __ARM_NR_ipipe)
 #endif /* !CONFIG_OABI_COMPAT */
+#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 
-#define __xn_syscall(regs)       ((__xn_reg_sys(regs) >> 24) & 0xff)
+#define __xn_reg_rval(__regs)  ((__regs)->ARM_r0)
+#define __xn_reg_arg1(__regs)  ((__regs)->ARM_r1)
+#define __xn_reg_arg2(__regs)  ((__regs)->ARM_r2)
+#define __xn_reg_arg3(__regs)  ((__regs)->ARM_r3)
+#define __xn_reg_arg4(__regs)  ((__regs)->ARM_r4)
+#define __xn_reg_arg5(__regs)  ((__regs)->ARM_r5)
+#define __xn_reg_pc(__regs)    ((__regs)->ARM_ip)
+#define __xn_reg_sp(__regs)    ((__regs)->ARM_sp)
 
 static inline void __xn_success_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/syscall.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/syscall.h
index 3b11b32..c4e3593 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/syscall.h
@@ -21,7 +21,7 @@
 #ifndef _COBALT_ARM_ASM_UAPI_SYSCALL_H
 #define _COBALT_ARM_ASM_UAPI_SYSCALL_H
 
-#define __xn_syscode(op)       ((op << 24)|(cobalt_syscall_tag & 0xffff))
+#define __xn_syscode(__nr)     (__COBALT_SYSCALL_BIT | (__nr))
 
 #define XENO_ARM_SYSCALL        0x000F0042     /* carefully chosen... */
 
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h
index 691edf2..61e0ba3 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h
@@ -23,18 +23,16 @@
 #include <asm/ptrace.h>
 #include <asm-generic/xenomai/syscall.h>
 
-#define __xn_reg_sys(regs)    ((regs)->orig_p0)
-#define __xn_reg_rval(regs)   ((regs)->r0)
-#define __xn_reg_arg1(regs)   ((regs)->r0)
-#define __xn_reg_arg2(regs)   ((regs)->r1)
-#define __xn_reg_arg3(regs)   ((regs)->r2)
-#define __xn_reg_arg4(regs)   ((regs)->r3)
-#define __xn_reg_arg5(regs)   ((regs)->r4)
-
-#define __xn_syscall_p(regs)        ((__xn_reg_sys(regs) & 0xffff) == 
cobalt_syscall_tag)
-#define __xn_syscall(regs)           ((__xn_reg_sys(regs) >> 16) & 0xff)
-
-#define __xn_syslinux_p(regs, nr)  (__xn_reg_sys(regs) == (nr))
+#define __xn_reg_sys(__regs)   ((__regs)->orig_p0)
+#define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT)
+#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
+
+#define __xn_reg_rval(__regs)  ((__regs)->r0)
+#define __xn_reg_arg1(__regs)  ((__regs)->r0)
+#define __xn_reg_arg2(__regs)  ((__regs)->r1)
+#define __xn_reg_arg3(__regs)  ((__regs)->r2)
+#define __xn_reg_arg4(__regs)  ((__regs)->r3)
+#define __xn_reg_arg5(__regs)  ((__regs)->r4)
 
 static inline void __xn_success_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/syscall.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/syscall.h
index 777660c..299c59e 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/syscall.h
@@ -18,12 +18,7 @@
 #ifndef _COBALT_BLACKFIN_ASM_UAPI_SYSCALL_H
 #define _COBALT_BLACKFIN_ASM_UAPI_SYSCALL_H
 
-/*
- * NOTE: watch out for the p0 sign convention used by Linux
- * (i.e. negative syscall number in orig_p0 meaning "non-syscall
- * entry").
- */
-#define __xn_syscode(op)               (((op << 16) & 
0xff0000)|(cobalt_syscall_tag & 0xffff))
+#define __xn_syscode(__nr)     (__COBALT_SYSCALL_BIT | (__nr))
 
 /*
  * No atomic xchg available from user-space. We implement this as a
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/syscall.h
index 1af7d2e..cef7b4b 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/syscall.h
@@ -24,20 +24,18 @@
 #include <asm/ptrace.h>
 #include <asm-generic/xenomai/syscall.h>
 
-#define __xn_reg_sys(regs)    ((regs)->r2)
-#define __xn_reg_rval(regs)   ((regs)->r2)
-#define __xn_reg_arg1(regs)   ((regs)->r4)
-#define __xn_reg_arg2(regs)   ((regs)->r5)
-#define __xn_reg_arg3(regs)   ((regs)->r6)
-#define __xn_reg_arg4(regs)   ((regs)->r7)
-#define __xn_reg_arg5(regs)   ((regs)->r8)
-#define __xn_reg_pc(regs)     ((regs)->ea)
-#define __xn_reg_sp(regs)     ((regs)->sp)
+#define __xn_reg_sys(__regs)   ((__regs)->r2)
+#define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT)
+#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 
-#define __xn_syscall_p(regs)        ((__xn_reg_sys(regs) & 0xffff) == 
cobalt_syscall_tag)
-#define __xn_syscall(regs)           ((__xn_reg_sys(regs) >> 16) & 0xff)
-
-#define __xn_syslinux_p(regs, nr)  (__xn_reg_sys(regs) == (nr))
+#define __xn_reg_rval(__regs)  ((__regs)->r2)
+#define __xn_reg_arg1(__regs)  ((__regs)->r4)
+#define __xn_reg_arg2(__regs)  ((__regs)->r5)
+#define __xn_reg_arg3(__regs)  ((__regs)->r6)
+#define __xn_reg_arg4(__regs)  ((__regs)->r7)
+#define __xn_reg_arg5(__regs)  ((__regs)->r8)
+#define __xn_reg_pc(__regs)    ((__regs)->ea)
+#define __xn_reg_sp(__regs)    ((__regs)->sp)
 
 static inline void __xn_success_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/syscall.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/syscall.h
index 03d8cf3..b9ab61d 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/syscall.h
@@ -18,8 +18,8 @@
 #ifndef _COBALT_NIOS2_ASM_UAPI_SYSCALL_H
 #define _COBALT_NIOS2_ASM_UAPI_SYSCALL_H
 
-#define __xn_syscode(op)       (((op << 16) & 0xff0000)|(cobalt_syscall_tag & 
0xffff))
+#define __xn_syscode(__nr)     (__COBALT_SYSCALL_BIT | (__nr))
 
-#define __xn_lsys_xchg   0
+#define __xn_lsys_xchg 0
 
 #endif /* !_COBALT_NIOS2_ASM_UAPI_SYSCALL_H */
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/syscall.h
index 9a08092..b00cd12 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/syscall.h
@@ -26,20 +26,18 @@
 #include <asm/ptrace.h>
 #include <asm-generic/xenomai/syscall.h>
 
-#define __xn_reg_sys(regs)    ((regs)->gpr[0])
-#define __xn_reg_rval(regs)   ((regs)->gpr[3])
-#define __xn_reg_arg1(regs)   ((regs)->gpr[3])
-#define __xn_reg_arg2(regs)   ((regs)->gpr[4])
-#define __xn_reg_arg3(regs)   ((regs)->gpr[5])
-#define __xn_reg_arg4(regs)   ((regs)->gpr[6])
-#define __xn_reg_arg5(regs)   ((regs)->gpr[7])
-#define __xn_reg_pc(regs)     ((regs)->nip)
-#define __xn_reg_sp(regs)     ((regs)->gpr[1])
+#define __xn_reg_sys(__regs)   ((__regs)->gpr[0])
+#define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT)
+#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 
-#define __xn_syscall_p(regs)        ((__xn_reg_sys(regs) & 0xffff) == 
cobalt_syscall_tag)
-#define __xn_syscall(regs)           ((__xn_reg_sys(regs) >> 24) & 0xff)
-
-#define __xn_syslinux_p(regs, nr)  (__xn_reg_sys(regs) == (nr))
+#define __xn_reg_rval(__regs)  ((__regs)->gpr[3])
+#define __xn_reg_arg1(__regs)  ((__regs)->gpr[3])
+#define __xn_reg_arg2(__regs)  ((__regs)->gpr[4])
+#define __xn_reg_arg3(__regs)  ((__regs)->gpr[5])
+#define __xn_reg_arg4(__regs)  ((__regs)->gpr[6])
+#define __xn_reg_arg5(__regs)  ((__regs)->gpr[7])
+#define __xn_reg_pc(__regs)    ((__regs)->nip)
+#define __xn_reg_sp(__regs)    ((__regs)->gpr[1])
 
 static inline void __xn_success_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/syscall.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/syscall.h
index b44c407..243aeab 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/syscall.h
@@ -18,6 +18,6 @@
 #ifndef _COBALT_POWERPC_ASM_UAPI_SYSCALL_H
 #define _COBALT_POWERPC_ASM_UAPI_SYSCALL_H
 
-#define __xn_syscode(op)       ((op << 24)|(cobalt_syscall_tag & 0xffff))
+#define __xn_syscode(__nr)     (__COBALT_SYSCALL_BIT | (__nr))
 
 #endif /* !_COBALT_POWERPC_ASM_UAPI_SYSCALL_H */
diff --git a/kernel/cobalt/arch/sh/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/sh/include/asm/xenomai/syscall.h
index 22def9d..88c267f 100644
--- a/kernel/cobalt/arch/sh/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/sh/include/asm/xenomai/syscall.h
@@ -23,18 +23,16 @@
 #include <asm/ptrace.h>
 #include <asm-generic/xenomai/syscall.h>
 
-#define __xn_reg_sys(regs)    ((regs)->regs[3])
-#define __xn_reg_rval(regs)   ((regs)->regs[0])
-#define __xn_reg_arg1(regs)   ((regs)->regs[4])
-#define __xn_reg_arg2(regs)   ((regs)->regs[5])
-#define __xn_reg_arg3(regs)   ((regs)->regs[6])
-#define __xn_reg_arg4(regs)   ((regs)->regs[7])
-#define __xn_reg_arg5(regs)   ((regs)->regs[0])
-
-#define __xn_syscall_p(regs)        ((__xn_reg_sys(regs) & 0xffff) == 
cobalt_syscall_tag)
-#define __xn_syscall(regs)           ((__xn_reg_sys(regs) >> 16) & 0xff)
-
-#define __xn_syslinux_p(regs, nr)  (__xn_reg_sys(regs) == (nr))
+#define __xn_reg_sys(__regs)    ((__regs)->regs[3])
+#define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT)
+#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
+
+#define __xn_reg_rval(__regs)   ((__regs)->regs[0])
+#define __xn_reg_arg1(__regs)   ((__regs)->regs[4])
+#define __xn_reg_arg2(__regs)   ((__regs)->regs[5])
+#define __xn_reg_arg3(__regs)   ((__regs)->regs[6])
+#define __xn_reg_arg4(__regs)   ((__regs)->regs[7])
+#define __xn_reg_arg5(__regs)   ((__regs)->regs[0])
 
 static inline void __xn_success_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/syscall.h 
b/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/syscall.h
index 8300e19..ecf39bc 100644
--- a/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/syscall.h
@@ -18,6 +18,6 @@
 #ifndef _COBALT_SH_ASM_UAPI_SYSCALL_H
 #define _COBALT_SH_ASM_UAPI_SYSCALL_H
 
-#define __xn_syscode(op)       (((op << 16) & 0xff0000)|(cobalt_syscall_tag & 
0xffff))
+#define __xn_syscode(__nr)     (__COBALT_SYSCALL_BIT | (__nr))
 
 #endif /* !_COBALT_SH_ASM_UAPI_SYSCALL_H */


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

Reply via email to