Xenomai  3.0.8
syscall.h
1 /*
2  * Copyright (C) 2001-2014 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * Xenomai is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _COBALT_X86_ASM_SYSCALL_H
20 #define _COBALT_X86_ASM_SYSCALL_H
21 
22 #include <linux/errno.h>
23 #include <asm/ptrace.h>
24 #include <asm-generic/xenomai/syscall.h>
25 
26 #define __xn_reg_sys(regs) ((regs)->orig_ax)
27 #define __xn_reg_rval(regs) ((regs)->ax)
28 #ifdef __i386__
29 #define __xn_reg_arg1(regs) ((regs)->bx)
30 #define __xn_reg_arg2(regs) ((regs)->cx)
31 #define __xn_reg_arg3(regs) ((regs)->dx)
32 #define __xn_reg_arg4(regs) ((regs)->si)
33 #define __xn_reg_arg5(regs) ((regs)->di)
34 #else /* x86_64 */
35 #define __xn_reg_arg1(regs) ((regs)->di)
36 #define __xn_reg_arg2(regs) ((regs)->si)
37 #define __xn_reg_arg3(regs) ((regs)->dx)
38 #define __xn_reg_arg4(regs) ((regs)->r10)
39 #define __xn_reg_arg5(regs) ((regs)->r8)
40 #endif /* x86_64 */
41 #define __xn_reg_pc(regs) ((regs)->ip)
42 #define __xn_reg_sp(regs) ((regs)->sp)
43 
44 #define __xn_syscall_p(regs) (__xn_reg_sys(regs) & __COBALT_SYSCALL_BIT)
45 #ifdef CONFIG_XENO_ARCH_SYS3264
46 #define __xn_syscall(regs) __COBALT_CALL32_SYSNR(__xn_reg_sys(regs) \
47  & ~__COBALT_SYSCALL_BIT)
48 #else
49 #define __xn_syscall(regs) (__xn_reg_sys(regs) & ~__COBALT_SYSCALL_BIT)
50 #endif
51 
52 /*
53  * Returns the syscall number depending on the handling core. Cobalt
54  * and Linux syscall numbers can be fetched from ORIG_AX, masking out
55  * the __COBALT_SYSCALL_BIT marker. Make sure to offset the number by
56  * __COBALT_X32_BASE for Cobalt 32-bit compat syscalls only.
57  */
58 #define __xn_get_syscall_nr(__regs) \
59  ({ \
60  __xn_syscall_p(__regs) ? __xn_syscall(__regs) : \
61  (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT); \
62  })
63 
64 static inline void __xn_error_return(struct pt_regs *regs, int v)
65 {
66  __xn_reg_rval(regs) = v;
67 }
68 
69 static inline void __xn_status_return(struct pt_regs *regs, long v)
70 {
71  __xn_reg_rval(regs) = v;
72 }
73 
74 static inline int __xn_interrupted_p(struct pt_regs *regs)
75 {
76  return __xn_reg_rval(regs) == -EINTR;
77 }
78 
79 static inline
80 int xnarch_local_syscall(unsigned long a1, unsigned long a2,
81  unsigned long a3, unsigned long a4,
82  unsigned long a5)
83 {
84  return -ENOSYS;
85 }
86 
87 #endif /* !_COBALT_X86_ASM_SYSCALL_H */