xref: /haiku/src/system/libroot/os/arch/x86/syscalls.inc (revision 5af32e752606778be5dd7379f319fe43cb3f6b8c)
1/*
2** Copyright 2001, Travis Geiselbrecht. All rights reserved.
3** Distributed under the terms of the NewOS License.
4*/
5
6/*
7** syscall interface works as such:
8** eax has syscall #
9** ecx has number of args (0-16)
10** edx has pointer to buffer containing args from first to last
11** each is verified to make sure someone doesnt try to clobber it
12*/
13
14#define SYSCALL0(name, n) \
15.globl name; \
16.type name,@function; \
17.align 8; \
18name: \
19	movl	$n,%eax; \
20	jmp		syscall0
21
22#define SYSCALL1(name, n) \
23.globl name; \
24.type name,@function; \
25.align 8; \
26name: \
27	movl	$n,%eax; \
28	jmp		syscall1
29
30#define SYSCALL2(name, n) \
31.globl name; \
32.type name,@function; \
33.align 8; \
34name: \
35	movl	$n,%eax; \
36	jmp		syscall2
37
38#define SYSCALL3(name, n) \
39.globl name; \
40.type name,@function; \
41.align 8; \
42name: \
43	movl	$n,%eax; \
44	jmp		syscall3
45
46#define SYSCALL4(name, n) \
47.globl name; \
48.type name,@function; \
49.align 8; \
50name: \
51	movl	$n,%eax; \
52	jmp		syscall4
53
54#define SYSCALL5(name, n) \
55.globl name; \
56.type name,@function; \
57.align 8; \
58name: \
59	movl	$n,%eax; \
60	jmp		syscall5
61
62#define SYSCALL6(name, n) \
63.globl name; \
64.type name,@function; \
65.align 8; \
66name: \
67	movl	$n,%eax; \
68	jmp		syscall6
69
70
71#define SYSCALL7(name, n) \
72.globl name; \
73.type name,@function; \
74.align 8; \
75name: \
76	movl	$n,%eax; \
77	jmp		syscall7
78
79#define SYSCALL8(name, n) \
80.globl name; \
81.type name,@function; \
82.align 8; \
83name: \
84	movl	$n,%eax; \
85	jmp		syscall8
86
87#define SYSCALL9(name, n) \
88.globl name; \
89.type name,@function; \
90.align 8; \
91name: \
92	movl	$n,%eax; \
93	jmp		syscall9
94
95#define SYSCALL10(name, n) \
96.globl name; \
97.type name,@function; \
98.align 8; \
99name: \
100	movl	$n,%eax; \
101	jmp		syscall10
102
103#define SYSCALL11(name, n) \
104.globl name; \
105.type name,@function; \
106.align 8; \
107name: \
108	movl	$n,%eax; \
109	jmp		syscall11
110
111#define SYSCALL12(name, n) \
112.globl name; \
113.type name,@function; \
114.align 8; \
115name: \
116	movl	$n,%eax; \
117	jmp		syscall12
118
119#define SYSCALL13(name, n) \
120.globl name; \
121.type name,@function; \
122.align 8; \
123name: \
124	movl	$n,%eax; \
125	jmp		syscall13
126
127#define SYSCALL14(name, n) \
128.globl name; \
129.type name,@function; \
130.align 8; \
131name: \
132	movl	$n,%eax; \
133	jmp		syscall14
134
135#define SYSCALL15(name, n) \
136.globl name; \
137.type name,@function; \
138.align 8; \
139name: \
140	movl	$n,%eax; \
141	jmp		syscall15
142
143#define SYSCALL16(name, n) \
144.globl name; \
145.type name,@function; \
146.align 8; \
147name: \
148	movl	$n,%eax; \
149	jmp		syscall16
150
151
152
153/* we will optimize by just passing a ptr to the place where the caller
154** would have dumped the args */
155
156syscall0:
157	movl	$0, %ecx
158	lea		4(%esp), %edx
159	int		$99
160	ret
161
162syscall1:
163	movl	$1, %ecx
164	lea		4(%esp), %edx
165	int		$99
166	ret
167
168syscall2:
169	movl	$2, %ecx
170	lea		4(%esp), %edx
171	int		$99
172	ret
173
174syscall3:
175	movl	$3, %ecx
176	lea		4(%esp), %edx
177	int		$99
178	ret
179
180syscall4:
181	movl	$4, %ecx
182	lea		4(%esp), %edx
183	int		$99
184	ret
185
186syscall5:
187	movl	$5, %ecx
188	lea		4(%esp), %edx
189	int		$99
190	ret
191
192syscall6:
193	movl	$6, %ecx
194	lea		4(%esp), %edx
195	int		$99
196	ret
197
198syscall7:
199	movl	$7, %ecx
200	lea		4(%esp), %edx
201	int		$99
202	ret
203
204syscall8:
205	movl	$8, %ecx
206	lea		4(%esp), %edx
207	int		$99
208	ret
209
210syscall9:
211	movl	$9, %ecx
212	lea		4(%esp), %edx
213	int		$99
214	ret
215
216syscall10:
217	movl	$10, %ecx
218	lea		4(%esp), %edx
219	int		$99
220	ret
221
222syscall11:
223	movl	$11, %ecx
224	lea		4(%esp), %edx
225	int		$99
226	ret
227
228syscall12:
229	movl	$12, %ecx
230	lea		4(%esp), %edx
231	int		$99
232	ret
233
234syscall13:
235	movl	$13, %ecx
236	lea		4(%esp), %edx
237	int		$99
238	ret
239
240syscall14:
241	movl	$14, %ecx
242	lea		4(%esp), %edx
243	int		$99
244	ret
245
246syscall15:
247	movl	$15, %ecx
248	lea		4(%esp), %edx
249	int		$99
250	ret
251
252syscall16:
253	movl	$16, %ecx
254	lea		4(%esp), %edx
255	int		$99
256	ret
257
258