Xenomai  3.0.5
syscall.h
1 /*
2  * Copyright (C) 2001,2002,2003,2004,2005 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_ASM_GENERIC_SYSCALL_H
20 #define _COBALT_ASM_GENERIC_SYSCALL_H
21 
22 #include <linux/types.h>
23 #include <asm/uaccess.h>
24 #include <asm/xenomai/features.h>
25 #include <asm/xenomai/wrappers.h>
26 #include <asm/xenomai/machine.h>
27 #include <cobalt/uapi/asm-generic/syscall.h>
28 
29 #define access_rok(addr, size) access_ok(VERIFY_READ, (addr), (size))
30 #define access_wok(addr, size) access_ok(VERIFY_WRITE, (addr), (size))
31 
32 #define __xn_reg_arglist(regs) \
33  __xn_reg_arg1(regs), \
34  __xn_reg_arg2(regs), \
35  __xn_reg_arg3(regs), \
36  __xn_reg_arg4(regs), \
37  __xn_reg_arg5(regs)
38 
39 #define __xn_copy_from_user(dstP, srcP, n) __copy_from_user_inatomic(dstP, srcP, n)
40 #define __xn_copy_to_user(dstP, srcP, n) __copy_to_user_inatomic(dstP, srcP, n)
41 #define __xn_put_user(src, dstP) __put_user_inatomic(src, dstP)
42 #define __xn_get_user(dst, srcP) __get_user_inatomic(dst, srcP)
43 #define __xn_strncpy_from_user(dstP, srcP, n) strncpy_from_user(dstP, srcP, n)
44 
45 static inline int cobalt_copy_from_user(void *dst, const void __user *src,
46  size_t size)
47 {
48  return (!access_rok(src, size) ||
49  __xn_copy_from_user(dst, src, size)) ? -EFAULT : 0;
50 }
51 
52 static inline int cobalt_copy_to_user(void __user *dst, const void *src,
53  size_t size)
54 {
55  return (!access_wok(dst, size) ||
56  __xn_copy_to_user(dst, src, size)) ? -EFAULT : 0;
57 }
58 
59 static inline int cobalt_strncpy_from_user(char *dst, const char __user *src,
60  size_t count)
61 {
62  if (unlikely(!access_rok(src, 1)))
63  return -EFAULT;
64 
65  return __xn_strncpy_from_user(dst, src, count);
66 }
67 
68 /* 32bit syscall emulation */
69 #define __COBALT_COMPAT_BIT 0x1
70 /* 32bit syscall emulation - extended form */
71 #define __COBALT_COMPATX_BIT 0x2
72 
73 #endif /* !_COBALT_ASM_GENERIC_SYSCALL_H */