Xenomai  3.0.5
syscall.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _LIB_COBALT_BLACKFIN_SYSCALL_H
19 #define _LIB_COBALT_BLACKFIN_SYSCALL_H
20 
21 #include <cobalt/uapi/syscall.h>
22 #include <fcntl.h>
23 #include <errno.h>
24 
25 #define __emit_syscall0(syscode, ...) \
26 ({ \
27  long __res; \
28  __asm__ __volatile__ ( \
29  "excpt 0;\n\t" \
30  : "=q0" (__res) \
31  : "qA" (syscode), \
32  ##__VA_ARGS__ \
33  : "CC", "memory"); \
34  __res; \
35 })
36 #define __emit_syscall1(syscode, a1, ...) \
37  __emit_syscall0(syscode, "q0"(a1), ##__VA_ARGS__)
38 #define __emit_syscall2(syscode, a1, a2, ...) \
39  __emit_syscall1(syscode, a1, "q1"(a2), ##__VA_ARGS__)
40 #define __emit_syscall3(syscode, a1, a2, a3, ...) \
41  __emit_syscall2(syscode, a1, a2, "q2"(a3), ##__VA_ARGS__)
42 #define __emit_syscall4(syscode, a1, a2, a3, a4, ...) \
43  __emit_syscall3(syscode, a1, a2, a3, "q3"(a4), ##__VA_ARGS__)
44 #define __emit_syscall5(syscode, a1, a2, a3, a4, a5, ...) \
45  __emit_syscall4(syscode, a1, a2, a3, a4, "q4"(a5), ##__VA_ARGS__)
46 
47 #define XENOMAI_DO_SYSCALL(nr, op, args...) \
48  __emit_syscall##nr(__xn_syscode(op), ##args)
49 
50 #define XENOMAI_SYSCALL0(op) XENOMAI_DO_SYSCALL(0,op)
51 #define XENOMAI_SYSCALL1(op,a1) XENOMAI_DO_SYSCALL(1,op,a1)
52 #define XENOMAI_SYSCALL2(op,a1,a2) XENOMAI_DO_SYSCALL(2,op,a1,a2)
53 #define XENOMAI_SYSCALL3(op,a1,a2,a3) XENOMAI_DO_SYSCALL(3,op,a1,a2,a3)
54 #define XENOMAI_SYSCALL4(op,a1,a2,a3,a4) XENOMAI_DO_SYSCALL(4,op,a1,a2,a3,a4)
55 #define XENOMAI_SYSCALL5(op,a1,a2,a3,a4,a5) XENOMAI_DO_SYSCALL(5,op,a1,a2,a3,a4,a5)
56 #define XENOMAI_SYSBIND(breq) XENOMAI_DO_SYSCALL(1,sc_cobalt_bind,breq)
57 
58 #endif /* !_LIB_COBALT_BLACKFIN_SYSCALL_H */