hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright (C) 2014 Philippe Gerum <rpm@xenomai.org>.
 *
 * Xenomai is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * Xenomai is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Xenomai; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
#ifndef _COBALT_X86_ASM_SYSCALL32_H
#define _COBALT_X86_ASM_SYSCALL32_H
 
#include <asm/unistd.h>
 
#ifdef CONFIG_IA32_EMULATION
 
#define __COBALT_IA32_BASE        256 /* Power of two. */
 
#define __COBALT_SYSNR32emu(__reg)                    \
   ({                                \
       long __nr = __reg;                    \
       if (in_ia32_syscall())                    \
           __nr += __COBALT_IA32_BASE;            \
       __nr;                            \
   })
 
#define __COBALT_COMPAT32emu(__reg)                    \
   (in_ia32_syscall() ? __COBALT_COMPAT_BIT : 0)
 
#if __NR_COBALT_SYSCALLS > __COBALT_IA32_BASE
#error "__NR_COBALT_SYSCALLS > __COBALT_IA32_BASE"
#endif
 
#define __syshand32emu__(__name)    \
   ((cobalt_syshand)(void (*)(void))(CoBaLt32emu_ ## __name))
 
#define __COBALT_CALL32emu_INITHAND(__handler)    \
   [__COBALT_IA32_BASE ... __COBALT_IA32_BASE + __NR_COBALT_SYSCALLS-1] = __handler,
 
#define __COBALT_CALL32emu_INITMODE(__mode)    \
   [__COBALT_IA32_BASE ... __COBALT_IA32_BASE + __NR_COBALT_SYSCALLS-1] = __mode,
 
/* ia32 default entry (no thunk) */
#define __COBALT_CALL32emu_ENTRY(__name, __handler)        \
   [sc_cobalt_ ## __name + __COBALT_IA32_BASE] = __handler,
 
/* ia32 thunk installation */
#define __COBALT_CALL32emu_THUNK(__name)    \
   __COBALT_CALL32emu_ENTRY(__name, __syshand32emu__(__name))
 
/* ia32 thunk implementation. */
#define COBALT_SYSCALL32emu(__name, __mode, __args)    \
   long CoBaLt32emu_ ## __name __args
 
/* ia32 thunk declaration. */
#define COBALT_SYSCALL32emu_DECL(__name, __args)    \
   long CoBaLt32emu_ ## __name __args
 
#else /* !CONFIG_IA32_EMULATION */
 
/* ia32 emulation support disabled. */
 
#define __COBALT_SYSNR32emu(__reg)    (__reg)
 
#define __COBALT_COMPAT32emu(__reg)    0
 
#define __COBALT_CALL32emu_INITHAND(__handler)
 
#define __COBALT_CALL32emu_INITMODE(__mode)
 
#define __COBALT_CALL32emu_ENTRY(__name, __handler)
 
#define __COBALT_CALL32emu_THUNK(__name)
 
#define COBALT_SYSCALL32emu_DECL(__name, __args)
 
#endif /* !CONFIG_IA32_EMULATION */
 
#define __COBALT_CALL32_ENTRY(__name, __handler)    \
   __COBALT_CALL32emu_ENTRY(__name, __handler)
 
#define __COBALT_CALL32_INITHAND(__handler)    \
   __COBALT_CALL32emu_INITHAND(__handler)
 
#define __COBALT_CALL32_INITMODE(__mode)    \
   __COBALT_CALL32emu_INITMODE(__mode)
 
/* Already checked for __COBALT_SYSCALL_BIT */
#define __COBALT_CALL32_SYSNR(__reg)    __COBALT_SYSNR32emu(__reg)
 
#define __COBALT_CALL_COMPAT(__reg)    __COBALT_COMPAT32emu(__reg)
 
#endif /* !_COBALT_X86_ASM_SYSCALL32_H */