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