bfin: remove inline keyword
[xenomai-head.git] / include / asm-blackfin / syscall.h
blobb5728b553ac67b300754ee45da43283ebc21fbf0
1 /*
2 * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
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.
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.
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.
20 #ifndef _XENO_ASM_BLACKFIN_SYSCALL_H
21 #define _XENO_ASM_BLACKFIN_SYSCALL_H
23 #include <asm-generic/xenomai/syscall.h>
24 #include <asm/xenomai/tsc.h>
26 /* The way we mangle Xenomai syscalls with our multiplexer
27 marker. Note: watch out for the p0 sign convention used by Linux
28 (i.e. negative syscall number in orig_p0 meaning "non-syscall
29 entry"). */
30 #define __xn_mux_code(shifted_id,op) (shifted_id|((op << 16) & 0xff0000)|(__xn_sys_mux & 0xffff))
31 #define __xn_mux_shifted_id(id) (id << 24)
33 /* Local syscalls -- the braindamage thing about this arch is the
34 absence of atomic ops usable from user-space; so we export what
35 we need as syscalls implementing those ops from kernel space. Sigh... */
36 #define __xn_lsys_xchg 0
38 #ifdef __KERNEL__
40 #include <linux/errno.h>
41 #include <asm/uaccess.h>
42 #include <asm/ptrace.h>
44 /* Register mapping for accessing syscall args. */
46 #define __xn_reg_mux(regs) ((regs)->orig_p0)
47 #define __xn_reg_rval(regs) ((regs)->r0)
48 #define __xn_reg_arg1(regs) ((regs)->r0)
49 #define __xn_reg_arg2(regs) ((regs)->r1)
50 #define __xn_reg_arg3(regs) ((regs)->r2)
51 #define __xn_reg_arg4(regs) ((regs)->r3)
52 #define __xn_reg_arg5(regs) ((regs)->r4)
54 #define __xn_reg_mux_p(regs) ((__xn_reg_mux(regs) & 0xffff) == __xn_sys_mux)
55 #define __xn_mux_id(regs) ((__xn_reg_mux(regs) >> 24) & 0xff)
56 #define __xn_mux_op(regs) ((__xn_reg_mux(regs) >> 16) & 0xff)
58 #define __xn_linux_mux_p(regs, nr) (__xn_reg_mux(regs) == (nr))
60 /* Purposedly used inlines and not macros for the following routines
61 so that we don't risk spurious side-effects on the value arg. */
63 static inline void __xn_success_return(struct pt_regs *regs, int v)
65 __xn_reg_rval(regs) = v;
68 static inline void __xn_error_return(struct pt_regs *regs, int v)
70 __xn_reg_rval(regs) = v;
73 static inline void __xn_status_return(struct pt_regs *regs, int v)
75 __xn_reg_rval(regs) = v;
78 static inline int __xn_interrupted_p(struct pt_regs *regs)
80 return __xn_reg_rval(regs) == -EINTR;
83 #else /* !__KERNEL__ */
85 #include <errno.h>
86 #include <time.h>
89 * The following code defines an inline syscall mechanism used by
90 * Xenomai's real-time interfaces to invoke the skin module
91 * services in kernel space.
94 #define __emit_syscall0(muxcode, ...) \
95 ({ \
96 long __res; \
97 __asm__ __volatile__ ( \
98 "excpt 0;\n\t" \
99 : "=q0" (__res) \
100 : "qA" (muxcode), \
101 ##__VA_ARGS__ \
102 : "CC", "memory"); \
103 __res; \
105 #define __emit_syscall1(muxcode, a1, ...) \
106 __emit_syscall0(muxcode, "q0"(a1), ##__VA_ARGS__)
107 #define __emit_syscall2(muxcode, a1, a2, ...) \
108 __emit_syscall1(muxcode, a1, "q1"(a2), ##__VA_ARGS__)
109 #define __emit_syscall3(muxcode, a1, a2, a3, ...) \
110 __emit_syscall2(muxcode, a1, a2, "q2"(a3), ##__VA_ARGS__)
111 #define __emit_syscall4(muxcode, a1, a2, a3, a4, ...) \
112 __emit_syscall3(muxcode, a1, a2, a3, "q3"(a4), ##__VA_ARGS__)
113 #define __emit_syscall5(muxcode, a1, a2, a3, a4, a5, ...) \
114 __emit_syscall4(muxcode, a1, a2, a3, a4, "q4"(a5), ##__VA_ARGS__)
116 #define XENOMAI_DO_SYSCALL(nr, shifted_id, op, args...) \
117 __emit_syscall##nr(__xn_mux_code(shifted_id,op), ##args)
119 #define XENOMAI_SYSCALL0(op) XENOMAI_DO_SYSCALL(0,0,op)
120 #define XENOMAI_SYSCALL1(op,a1) XENOMAI_DO_SYSCALL(1,0,op,a1)
121 #define XENOMAI_SYSCALL2(op,a1,a2) XENOMAI_DO_SYSCALL(2,0,op,a1,a2)
122 #define XENOMAI_SYSCALL3(op,a1,a2,a3) XENOMAI_DO_SYSCALL(3,0,op,a1,a2,a3)
123 #define XENOMAI_SYSCALL4(op,a1,a2,a3,a4) XENOMAI_DO_SYSCALL(4,0,op,a1,a2,a3,a4)
124 #define XENOMAI_SYSCALL5(op,a1,a2,a3,a4,a5) XENOMAI_DO_SYSCALL(5,0,op,a1,a2,a3,a4,a5)
125 #define XENOMAI_SYSBIND(a1,a2,a3,a4) XENOMAI_DO_SYSCALL(4,0,__xn_sys_bind,a1,a2,a3,a4)
127 #define XENOMAI_SKINCALL0(id,op) XENOMAI_DO_SYSCALL(0,id,op)
128 #define XENOMAI_SKINCALL1(id,op,a1) XENOMAI_DO_SYSCALL(1,id,op,a1)
129 #define XENOMAI_SKINCALL2(id,op,a1,a2) XENOMAI_DO_SYSCALL(2,id,op,a1,a2)
130 #define XENOMAI_SKINCALL3(id,op,a1,a2,a3) XENOMAI_DO_SYSCALL(3,id,op,a1,a2,a3)
131 #define XENOMAI_SKINCALL4(id,op,a1,a2,a3,a4) XENOMAI_DO_SYSCALL(4,id,op,a1,a2,a3,a4)
132 #define XENOMAI_SKINCALL5(id,op,a1,a2,a3,a4,a5) XENOMAI_DO_SYSCALL(5,id,op,a1,a2,a3,a4,a5)
134 /* uClibc does not provide pthread_atfork() for this arch; provide it
135 here.
137 __attribute__((weak)) int pthread_atfork(void (*prepare)(void),
138 void (*parent)(void),
139 void (*child)(void))
141 return 0;
144 #include <errno.h>
146 __attribute__((weak)) int shm_open(const char *name,
147 int oflag,
148 mode_t mode)
150 errno = ENOSYS;
151 return -1;
154 __attribute__((weak)) int shm_unlink(const char *name)
156 errno = ENOSYS;
157 return -1;
160 int clock_nanosleep(clockid_t __clock_id, int __flags,
161 const struct timespec *__req,
162 struct timespec *__rem);
164 #endif /* __KERNEL__ */
166 #endif /* !_XENO_ASM_BLACKFIN_SYSCALL_H */