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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
diff -NurpP util-vserver-0.30.210/lib/syscall-alternative.h util-vserver-0.30.210-shiny10/lib/syscall-alternative.h
--- util-vserver-0.30.210/lib/syscall-alternative.h 2005-10-28 18:33:50.000000000 +0200
+++ util-vserver-0.30.210-shiny10/lib/syscall-alternative.h 2006-04-02 21:07:52.000000000 +0200
@@ -1,9 +1,7 @@
- // from http://vserver.13thfloor.at/Experimental/SYSCALL/syscall_shiny7.h
-
#ifndef __SYSCALL_NEW_H
#define __SYSCALL_NEW_H
-/* Copyright (C) 2005 Herbert P�tzl
+/* Copyright (C) 2005-2006 Herbert P�tzl
global config options
@@ -39,12 +37,13 @@
__sysc_rcon(n) ... syscall register constraint
__sysc_regs ... list of input regs for clobber
__sysc_type ... register type
+ __sysc_aout ... asm code output constraint
if all else fails
__sc_asmload(n,N,...) ... asm code to prepare arguments
__sc_asmsysc(n,N) ... asm code to execute syscall
- __sc_asmsave(n,r,e) ... asm code to store results
+ __sc_asmsave(n) ... asm code to store results
*/
@@ -243,7 +242,8 @@
sret: r0(r28)
serr: (sret >= (unsigned)-EMAXERRNO)
call: ble 0x100(%%sr2, %%r0)
- clob: r1, r2, r4, r20, r29, r31, memory
+ clob: r1, r2, (r4), r20, r29, r31, memory
+ picr: pr(r19)
*/
#define __sysc_max_err 4095
@@ -253,13 +253,21 @@
("r26", "r25", "r24", "r23", "r22", "r21")
#define __sysc_cmd_sys "ble 0x100(%%sr2,%%r0)"
-#define __sysc_cmd_fin "ldi %0,%%r20"
-#define __sysc_clobber __sysc_regs, \
- "r1", "r2", "r4", "r20", "r29", "r31", "memory"
+#define __sysc_pre(n) \
+ __pasm(n,1,1, "copy %%r19, %%r4" , )
-#warning syscall arch hppa not tested yet
+#define __sysc_fin(n) \
+ __casm(n,1,1, "ldi %0,%%r20" , )\
+ __pasm(n,1,1, "copy %%r4, %%r19" , )
+#ifndef __PIC__
+#define __sysc_clobber __sysc_regs, \
+ "r1", "r2", "r20", "r29", "r31", "memory"
+#else
+#define __sysc_clobber __sysc_regs, \
+ "r1", "r2", "r4", "r20", "r29", "r31", "memory"
+#endif
/* *****************************************
@@ -277,6 +285,7 @@
sret: r0(eax)
serr: (sret >= (unsigned)-EMAXERRNO)
call: int 0x80
+ picr: pr(ebx)
clob: memory
*/
@@ -301,15 +310,18 @@
__casm(n,6,1, "pushl %%ebp" , )\
""::__sc_iregs(n,__VA_ARGS__):__sysc_clobber)
+#define __sc_asmsave(n)
+
#define __sysc_pre(n) \
__casm(n,6,1, "movl %%eax,%%ebp" , )\
- __casm(n,0,1, "movl %0,%%eax" , )\
+ __casm(n,0,1, "movl %1,%%eax" , )\
#define __sysc_fin(n) \
__casm(n,6,1, "popl %%ebp" , )\
__pasm(n,1,1, "popl %%ebx" , )\
-#define __sysc_clobber __sysc_regs, "eax", "memory"
+#define __sysc_aout "=a"(__res)
+#define __sysc_clobber __sysc_regs, "memory"
/* *****************************************
@@ -399,8 +411,43 @@
#elif defined(__mips__)
-#error syscall arch mips not implemented yet
+/* The ABIO32 calling convention uses a0-a3 to pass the first
+ four arguments, the rest is passed on the userspace stack. The 5th arg
+ starts at 16($sp).
+
+ ABIN32 and ABI64 pass 6 args in a0-a3, t0-t1.
+
+ scnr: id(v0)
+ args: a1(a0), a2(a1), a3(a2), a4(a3), a5(16($sp)), a6(20($sp))
+ sret: r0(v0)
+ serr: e0(a3)
+ call: syscall
+ clob: at, v0, t0-t7, t8-t9
+*/
+
+#define __sysc_reg_cid "v0"
+#define __sysc_reg_ret "v0"
+#define __sysc_reg_err "a3"
+#define __sysc_cmd_sys "syscall"
+
+#define __sysc_reg(n) __arg_##n\
+ ("a0","a1","a2","a3", "t0", "t1")
+#define __sysc_clobber "$1", "$3", "$8", "$9", "$10", "$11", "$12", \
+ "$13", "$14", "$15", "$24", "$25", "memory"
+
+#if _MIPS_SIM == _ABIO32
+#define __sysc_pre(n) \
+ __casm(n,5,1,"addiu $sp,$sp,-32",) \
+ __casm(n,6,1,"sw $9,20($sp)",) \
+ __casm(n,5,1,"sw $8, 16($sp)",)
+#define __sysc_fin(n) \
+ __casm(n,5,1,"addiu $sp,$sp,32",)
+#elif (_MIPS_SIM == _ABIN32) || (_MIPS_SIM == _ABI64)
+#warning syscall arch mips with ABI N32 and 64 not tested yet
+#else
+#error unknown mips ABI version
+#endif
/* *****************************************
@@ -651,6 +698,7 @@
#define __sysc_clobber __sysc_regs, \
"cc", "r11", "rcx", "memory"
+#define __sysc_aout "=a"(__res)
#else
#error unknown kernel arch
@@ -834,7 +882,7 @@
#define __sc_inp_def(n,value)
#endif
-#ifndef __sysc_save
+#if !defined(__sysc_save) && !defined(__sysc_aout)
#define __sc_res_def(n,r) __sc_asm_reg(n, r);
#else
#define __sc_res_def(n,r) __sc_reg(n);
@@ -865,7 +913,6 @@
#endif
-
#ifdef __sc_complex /* complex result */
#ifndef __sysc_errc
@@ -918,6 +965,7 @@
return (type)(res)
#endif
+
#define __sc_results \
__sc_res_def(__res, __sysc_reg_res)
@@ -939,8 +987,13 @@
__casm(n,3,0,"%3 ",) __casm(n,4,0,"%4 ",) __casm(n,5,0,"%5 ",) \
__casm(n,6,0,"%6 ",) "*/"
+#ifdef __sysc_aout
+#define __sc_dummy_save(n)
+#define __sc_asmsave(n)
+#else
#define __sc_dummy_save(n) "/* gcc dummy save " \
__casm(n,0,0,"%0 ",) __casm(n,1,0,"%1 ",) "*/"
+#endif
#define __comment(name) "\t/* kernel sys_" \
#name "[" __stringify(__sc_id(name)) "] */"
@@ -1006,10 +1059,14 @@
#endif
#endif
+#ifndef __sysc_aout
+#define __sysc_aout
+#endif
+
#ifndef __sc_asmsysc
#define __sc_asmsysc(n,N) __sc_asm_vol( \
__casm(n,0,0, __sc_cmds(n,N) , )\
- ::"i"(__sc_id(N)) : __sysc_clobber)
+ :__sysc_aout:"i"(__sc_id(N)) : __sysc_clobber)
#endif
#ifndef __sc_asmsave
@@ -1031,33 +1088,33 @@
-#define _syscall0(type, name) \
+#define _syscall0(type, name) \
type name(void) \
__sc_body(0, type, name, *)
-#define _syscall1(type, name, type1, arg1) \
+#define _syscall1(type, name, type1, arg1) \
type name(type1 arg1) \
__sc_body(1, type, name, arg1)
-#define _syscall2(type, name, type1, arg1, type2, arg2) \
+#define _syscall2(type, name, type1, arg1, type2, arg2) \
type name(type1 arg1, type2 arg2) \
__sc_body(2, type, name, arg1, arg2)
-#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
+#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
type name(type1 arg1, type2 arg2, type3 arg3) \
__sc_body(3, type, name, arg1, arg2, arg3)
-#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
+#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
type4, arg4) \
type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
__sc_body(4, type, name, arg1, arg2, arg3, arg4)
-#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5) \
+#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
+ type4, arg4, type5, arg5) \
type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
__sc_body(5, type, name, arg1, arg2, arg3, arg4, arg5)
-#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
+#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
type4, arg4, type5, arg5, type6, arg6) \
type name(type1 arg1, type2 arg2, type3 arg3, \
type4 arg4, type5 arg5, type6 arg6) \
|