Xenomai 3.3.2
Loading...
Searching...
No Matches
syscall32.h
1/*
2 * Copyright (C) 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_ASM_GENERIC_SYSCALL32_H
20#define _COBALT_ASM_GENERIC_SYSCALL32_H
21
22#ifdef CONFIG_XENO_ARCH_SYS3264
23
24#define __COBALT_COMPAT32_BASE 256 /* Power of two. */
25
26#define __COBALT_SYSNR32emu(__reg) \
27 ({ \
28 long __nr = __reg; \
29 if (in_compat_syscall()) \
30 __nr += __COBALT_COMPAT32_BASE; \
31 __nr; \
32 })
33
34#define __COBALT_COMPAT32emu(__reg) \
35 (in_compat_syscall() ? __COBALT_COMPAT_BIT : 0)
36
37#if __NR_COBALT_SYSCALLS > __COBALT_COMPAT32_BASE
38#error "__NR_COBALT_SYSCALLS > __COBALT_COMPAT32_BASE"
39#endif
40
41#define __syshand32emu__(__name) \
42 ((cobalt_syshand)(void (*)(void))(CoBaLt32emu_ ## __name))
43
44#define __COBALT_CALL32emu_INITHAND(__handler) \
45 [__COBALT_COMPAT32_BASE ... __COBALT_COMPAT32_BASE + __NR_COBALT_SYSCALLS-1] = __handler,
46
47#define __COBALT_CALL32emu_INITMODE(__mode) \
48 [__COBALT_COMPAT32_BASE ... __COBALT_COMPAT32_BASE + __NR_COBALT_SYSCALLS-1] = __mode,
49
50/* compat default entry (no thunk) */
51#define __COBALT_CALL32emu_ENTRY(__name, __handler) \
52 [sc_cobalt_ ## __name + __COBALT_COMPAT32_BASE] = __handler,
53
54/* compat thunk installation */
55#define __COBALT_CALL32emu_THUNK(__name) \
56 __COBALT_CALL32emu_ENTRY(__name, __syshand32emu__(__name))
57
58/* compat thunk implementation. */
59#define COBALT_SYSCALL32emu(__name, __mode, __args) \
60 long CoBaLt32emu_ ## __name __args
61
62/* compat thunk declaration. */
63#define COBALT_SYSCALL32emu_DECL(__name, __args) \
64 long CoBaLt32emu_ ## __name __args
65
66#else /* !CONFIG_XENO_ARCH_SYS3264 */
67
68/* compat support disabled. */
69
70#define __COBALT_SYSNR32emu(__reg) (__reg)
71
72#define __COBALT_COMPAT32emu(__reg) 0
73
74#define __COBALT_CALL32emu_INITHAND(__handler)
75
76#define __COBALT_CALL32emu_INITMODE(__mode)
77
78#define __COBALT_CALL32emu_ENTRY(__name, __handler)
79
80#define __COBALT_CALL32emu_THUNK(__name)
81
82#define COBALT_SYSCALL32emu_DECL(__name, __args)
83
84#endif /* !CONFIG_XENO_ARCH_SYS3264 */
85
86#define __COBALT_CALL32_ENTRY(__name, __handler) \
87 __COBALT_CALL32emu_ENTRY(__name, __handler)
88
89#define __COBALT_CALL32_INITHAND(__handler) \
90 __COBALT_CALL32emu_INITHAND(__handler)
91
92#define __COBALT_CALL32_INITMODE(__mode) \
93 __COBALT_CALL32emu_INITMODE(__mode)
94
95/* Already checked for __COBALT_SYSCALL_BIT */
96#define __COBALT_CALL32_SYSNR(__reg) __COBALT_SYSNR32emu(__reg)
97
98#define __COBALT_CALL_COMPAT(__reg) __COBALT_COMPAT32emu(__reg)
99
100#endif /* !_COBALT_ASM_GENERIC_SYSCALL32_H */