Module: xenomai-3
Branch: stable-3.0.x
Commit: 4edf3d2d26ae3c161114e7445dc79b7d664ac835
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4edf3d2d26ae3c161114e7445dc79b7d664ac835

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Nov 17 16:32:43 2017 +0100

cobalt/arm: add syscall decoding helper

---

 kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h
index d80df77..92afe8d 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h
@@ -38,11 +38,24 @@
 #ifdef CONFIG_OABI_COMPAT
 #define __xn_syscall_p(__regs) (((__regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
                                 ((__regs)->ARM_r7 == __ARM_NR_ipipe))
+#define __xn_abi_decode(__regs) ((__regs)->ARM_r7 - __NR_OABI_SYSCALL_BASE)
 #else /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall_p(__regs) ((__regs)->ARM_r7 == __ARM_NR_ipipe)
+#define __xn_abi_decode(__regs) ((__regs)->ARM_r7)
 #endif /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 
+/*
+ * Returns the syscall number depending on the handling core. Cobalt
+ * syscall numbers can be fetched from ARM_ORIG_r0 with ARM_r7
+ * containing the Xenomai syscall marker, Linux syscalls directly from
+ * ARM_r7 (may require the OABI tweak).
+ */
+static inline long __xn_get_syscall_nr(struct pt_regs *regs)
+{
+       return __xn_syscall_p(regs) ? __xn_reg_sys(regs) : 
__xn_abi_decode(regs);
+}
+
 #define __xn_reg_rval(__regs)  ((__regs)->ARM_r0)
 #define __xn_reg_arg1(__regs)  ((__regs)->ARM_r1)
 #define __xn_reg_arg2(__regs)  ((__regs)->ARM_r2)


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

Reply via email to