Xenomai  3.1
syscall.h
1 /*
2  * Copyright (C) 2001,2002,2003,2004 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * ARM port
5  * Copyright (C) 2005 Stelian Pop
6  *
7  * Xenomai is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11  *
12  * Xenomai is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Xenomai; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20  * 02111-1307, USA.
21  */
22 #ifndef _COBALT_ARM_ASM_SYSCALL_H
23 #define _COBALT_ARM_ASM_SYSCALL_H
24 
25 #include <linux/errno.h>
26 #include <linux/uaccess.h>
27 #include <asm/unistd.h>
28 #include <asm/ptrace.h>
29 #include <asm-generic/xenomai/syscall.h>
30 
31 #ifndef __ARM_NR_ipipe
32 /* Legacy pipelines do not define this. */
33 #define __ARM_NR_ipipe (__NR_SYSCALL_BASE + XENO_ARM_SYSCALL)
34 #endif
35 
36 /*
37  * Cobalt syscall numbers can be fetched from ARM_ORIG_r0 with ARM_r7
38  * containing the Xenomai syscall marker, Linux syscalls directly from
39  * ARM_r7 (may require the OABI tweak).
40  */
41 #define __xn_reg_sys(__regs) ((__regs)->ARM_ORIG_r0)
42 /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
43 #ifdef CONFIG_OABI_COMPAT
44 #define __xn_syscall_p(__regs) (((__regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + XENO_ARM_SYSCALL) || \
45  ((__regs)->ARM_r7 == __ARM_NR_ipipe))
46 #define __xn_abi_decode(__regs) ((__regs)->ARM_r7 - __NR_OABI_SYSCALL_BASE)
47 #else /* !CONFIG_OABI_COMPAT */
48 #define __xn_syscall_p(__regs) ((__regs)->ARM_r7 == __ARM_NR_ipipe)
49 #define __xn_abi_decode(__regs) ((__regs)->ARM_r7)
50 #endif /* !CONFIG_OABI_COMPAT */
51 #define __xn_syscall(__regs) (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
52 
53 /*
54  * Root syscall number with predicate (valid only if
55  * !__xn_syscall_p(__regs)).
56  */
57 #define __xn_rootcall_p(__regs, __code) \
58  ({ \
59  *(__code) = __xn_abi_decode(__regs); \
60  *(__code) < NR_syscalls || *(__code) >= __ARM_NR_BASE; \
61  })
62 
63 #define __xn_reg_rval(__regs) ((__regs)->ARM_r0)
64 #define __xn_reg_arg1(__regs) ((__regs)->ARM_r1)
65 #define __xn_reg_arg2(__regs) ((__regs)->ARM_r2)
66 #define __xn_reg_arg3(__regs) ((__regs)->ARM_r3)
67 #define __xn_reg_arg4(__regs) ((__regs)->ARM_r4)
68 #define __xn_reg_arg5(__regs) ((__regs)->ARM_r5)
69 #define __xn_reg_pc(__regs) ((__regs)->ARM_ip)
70 #define __xn_reg_sp(__regs) ((__regs)->ARM_sp)
71 
72 static inline void __xn_error_return(struct pt_regs *regs, int v)
73 {
74  __xn_reg_rval(regs) = v;
75 }
76 
77 static inline void __xn_status_return(struct pt_regs *regs, long v)
78 {
79  __xn_reg_rval(regs) = v;
80 }
81 
82 static inline int __xn_interrupted_p(struct pt_regs *regs)
83 {
84  return __xn_reg_rval(regs) == -EINTR;
85 }
86 
87 int xnarch_local_syscall(unsigned long a1, unsigned long a2,
88  unsigned long a3, unsigned long a4,
89  unsigned long a5);
90 
91 #endif /* !_COBALT_ARM_ASM_SYSCALL_H */