]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_EN | |
21 | */ | |
22 | ||
23 | /* | |
24 | * Syscall argument mungers. | |
25 | * | |
26 | * Passed a pointer to the users register array in the savearea, we copy args into | |
27 | * the uu_arg[] array, padding etc as appropriate. The issue is that parameters | |
28 | * passed in registers from a 32-bit address space do not map directly into the uu_args. | |
29 | * For example, a 32-bit long-long comes in two registers, but we need to combine | |
30 | * them into one 64-bit long-long in the uu_args. | |
31 | * | |
32 | * There are several functions in this file. Each takes two parameters: | |
33 | * | |
34 | * void munge_XXXX( const void *regs, void *uu_args); | |
35 | * | |
36 | * The name of the function encodes the number and type of the parameters, as follows: | |
37 | * | |
38 | * w = a 32-bit value such as an int or a 32-bit ptr, that does not require | |
39 | * sign extension. These are handled by skipping a word in the input, | |
40 | * zeroing a word of output, and copying a word from input to output. | |
41 | * | |
42 | * s = a 32-bit value such as a long, which must be sign-extended to a 64-bit | |
43 | * long-long in the uu_args. These are handled by skipping a word of | |
44 | * input, loading a word of input and sign extending it to a double, | |
45 | * and storing two words of output. | |
46 | * | |
47 | * l = a 64-bit long-long, passed in two registers. These are handled by skipping | |
48 | * a word of input, copying a word, skipping another word of input, and | |
49 | * copying another word. | |
50 | * | |
51 | * d = a 32-bit int or a 64-bit ptr or long, passed in via a 64-bit GPR | |
52 | * from a 64-bit process. We copy two words from input to output. | |
53 | * | |
54 | * For example, "munge_wls" takes a word, a long-long, and a word. This takes | |
55 | * four registers: the first word is in one, the long-long takes two, and the | |
56 | * final word is in the fourth. We store six words: a 0, the low words of the | |
57 | * first three registers, and the two words resulting from sign-extending the | |
58 | * low word of the fourth register. | |
59 | * | |
60 | * As you can see, we save a lot of code by collapsing mungers that are prefixes | |
61 | * of each other, into the more general routine. This ends up copying a few extra | |
62 | * bytes of parameters, but big deal. The old kernel copied all eight words for | |
63 | * every system call. | |
64 | * | |
65 | * These routines assume explicit pad words in the uu_arg structures, that fill out | |
66 | * int parameters to 64 bits. Having pad words makes munging args for 64-bit | |
67 | * processes the equivalent of a simple bcopy(), though it does introduce an | |
68 | * endian dependency. | |
69 | */ | |
70 | ||
71 | .align 5 | |
72 | .globl _munge_dddddddd // that is 8 'd's | |
73 | _munge_dddddddd: | |
74 | .globl _munge_ddddddd | |
75 | _munge_ddddddd: | |
76 | .globl _munge_dddddd | |
77 | _munge_dddddd: | |
78 | .globl _munge_ddddd | |
79 | _munge_ddddd: | |
80 | ld r5,0*8+0(r3) | |
81 | ld r6,1*8+0(r3) | |
82 | ld r7,2*8+0(r3) | |
83 | ld r8,3*8+0(r3) | |
84 | ld r9,4*8+0(r3) | |
85 | ld r10,5*8+0(r3) | |
86 | ld r11,6*8+0(r3) | |
87 | ld r12,7*8+0(r3) | |
88 | ||
89 | std r5,0*8+0(r4) | |
90 | std r6,1*8+0(r4) | |
91 | std r7,2*8+0(r4) | |
92 | std r8,3*8+0(r4) | |
93 | std r9,4*8+0(r4) | |
94 | std r10,5*8+0(r4) | |
95 | std r11,6*8+0(r4) | |
96 | std r12,7*8+0(r4) | |
97 | ||
98 | blr | |
99 | ||
100 | ||
101 | .align 5 | |
102 | .globl _munge_dddd | |
103 | _munge_dddd: | |
104 | .globl _munge_ddd | |
105 | _munge_ddd: | |
106 | .globl _munge_dd | |
107 | _munge_dd: | |
108 | .globl _munge_d | |
109 | _munge_d: | |
110 | ld r5,0*8+0(r3) | |
111 | ld r6,1*8+0(r3) | |
112 | ld r7,2*8+0(r3) | |
113 | ld r8,3*8+0(r3) | |
114 | ||
115 | std r5,0*8+0(r4) | |
116 | std r6,1*8+0(r4) | |
117 | std r7,2*8+0(r4) | |
118 | std r8,3*8+0(r4) | |
119 | ||
120 | blr | |
121 | ||
122 | ||
123 | .align 5 | |
124 | .globl _munge_wwwwwwww // that is 8 'w's | |
125 | _munge_wwwwwwww: | |
126 | .globl _munge_wwwwwww | |
127 | _munge_wwwwwww: | |
128 | .globl _munge_wwwwww | |
129 | _munge_wwwwww: | |
130 | .globl _munge_wwwww | |
131 | _munge_wwwww: | |
132 | li r0,0 | |
133 | lwz r5,0*8+4(r3) | |
134 | lwz r6,1*8+4(r3) | |
135 | lwz r7,2*8+4(r3) | |
136 | lwz r8,3*8+4(r3) | |
137 | lwz r9,4*8+4(r3) | |
138 | lwz r10,5*8+4(r3) | |
139 | lwz r11,6*8+4(r3) | |
140 | lwz r12,7*8+4(r3) | |
141 | ||
142 | stw r0,0*8+0(r4) | |
143 | stw r5,0*8+4(r4) | |
144 | stw r0,1*8+0(r4) | |
145 | stw r6,1*8+4(r4) | |
146 | stw r0,2*8+0(r4) | |
147 | stw r7,2*8+4(r4) | |
148 | stw r0,3*8+0(r4) | |
149 | stw r8,3*8+4(r4) | |
150 | stw r0,4*8+0(r4) | |
151 | stw r9,4*8+4(r4) | |
152 | stw r0,5*8+0(r4) | |
153 | stw r10,5*8+4(r4) | |
154 | stw r0,6*8+0(r4) | |
155 | stw r11,6*8+4(r4) | |
156 | stw r0,7*8+0(r4) | |
157 | stw r12,7*8+4(r4) | |
158 | ||
159 | blr | |
160 | ||
161 | ||
162 | .align 5 | |
163 | .globl _munge_wwww | |
164 | _munge_wwww: | |
165 | .globl _munge_www | |
166 | _munge_www: | |
167 | .globl _munge_ww | |
168 | _munge_ww: | |
169 | .globl _munge_w | |
170 | _munge_w: | |
171 | li r0,0 | |
172 | lwz r5,0*8+4(r3) | |
173 | lwz r6,1*8+4(r3) | |
174 | lwz r7,2*8+4(r3) | |
175 | lwz r8,3*8+4(r3) | |
176 | ||
177 | stw r0,0*8+0(r4) | |
178 | stw r5,0*8+4(r4) | |
179 | stw r0,1*8+0(r4) | |
180 | stw r6,1*8+4(r4) | |
181 | stw r0,2*8+0(r4) | |
182 | stw r7,2*8+4(r4) | |
183 | stw r0,3*8+0(r4) | |
184 | stw r8,3*8+4(r4) | |
185 | ||
186 | blr | |
187 | ||
188 | .align 5 | |
189 | .globl _munge_l | |
190 | _munge_l: | |
191 | li r0,0 | |
192 | lwz r5,0*8+4(r3) | |
193 | lwz r6,1*8+4(r3) | |
194 | ||
195 | stw r5,0*8+0(r4) | |
196 | stw r6,0*8+4(r4) | |
197 | ||
198 | blr | |
199 | ||
200 | .align 5 | |
201 | .globl _munge_wlw | |
202 | _munge_wlw: | |
203 | .globl _munge_wl | |
204 | _munge_wl: | |
205 | li r0,0 | |
206 | lwz r5,0*8+4(r3) | |
207 | lwz r6,1*8+4(r3) | |
208 | lwz r7,2*8+4(r3) | |
209 | lwz r8,3*8+4(r3) | |
210 | ||
211 | stw r0,0*8+0(r4) | |
212 | stw r5,0*8+4(r4) | |
213 | stw r6,1*8+0(r4) | |
214 | stw r7,1*8+4(r4) | |
215 | stw r0,2*8+0(r4) | |
216 | stw r8,2*8+4(r4) | |
217 | ||
218 | blr | |
219 | ||
220 | ||
221 | .align 5 | |
222 | .globl _munge_wwwl | |
223 | _munge_wwwl: | |
224 | li r0,0 | |
225 | lwz r5,0*8+4(r3) | |
226 | lwz r6,1*8+4(r3) | |
227 | lwz r7,2*8+4(r3) | |
228 | lwz r8,3*8+4(r3) | |
229 | lwz r9,4*8+4(r3) | |
230 | ||
231 | stw r0,0*8+0(r4) | |
232 | stw r5,0*8+4(r4) | |
233 | stw r0,1*8+0(r4) | |
234 | stw r6,1*8+4(r4) | |
235 | stw r0,2*8+0(r4) | |
236 | stw r7,2*8+4(r4) | |
237 | stw r8,3*8+0(r4) | |
238 | stw r9,3*8+4(r4) | |
239 | ||
240 | blr | |
241 | ||
242 | ||
243 | .align 5 | |
244 | .globl _munge_wwwwl // 4 'w's and an l | |
245 | _munge_wwwwl: | |
246 | li r0,0 | |
247 | lwz r5,0*8+4(r3) | |
248 | lwz r6,1*8+4(r3) | |
249 | lwz r7,2*8+4(r3) | |
250 | lwz r8,3*8+4(r3) | |
251 | lwz r9,4*8+4(r3) | |
252 | lwz r10,5*8+4(r3) | |
253 | ||
254 | stw r0,0*8+0(r4) | |
255 | stw r5,0*8+4(r4) | |
256 | stw r0,1*8+0(r4) | |
257 | stw r6,1*8+4(r4) | |
258 | stw r0,2*8+0(r4) | |
259 | stw r7,2*8+4(r4) | |
260 | stw r0,3*8+0(r4) | |
261 | stw r8,3*8+4(r4) | |
262 | stw r9,4*8+0(r4) | |
263 | stw r10,4*8+4(r4) | |
264 | ||
265 | blr | |
266 | ||
267 | ||
268 | .align 5 | |
269 | .globl _munge_wwwwwl // 5 'w's and an l | |
270 | _munge_wwwwwl: | |
271 | li r0,0 | |
272 | lwz r5,0*8+4(r3) | |
273 | lwz r6,1*8+4(r3) | |
274 | lwz r7,2*8+4(r3) | |
275 | lwz r8,3*8+4(r3) | |
276 | lwz r9,4*8+4(r3) | |
277 | lwz r10,5*8+4(r3) | |
278 | lwz r11,6*8+4(r3) | |
279 | ||
280 | stw r0,0*8+0(r4) | |
281 | stw r5,0*8+4(r4) | |
282 | stw r0,1*8+0(r4) | |
283 | stw r6,1*8+4(r4) | |
284 | stw r0,2*8+0(r4) | |
285 | stw r7,2*8+4(r4) | |
286 | stw r0,3*8+0(r4) | |
287 | stw r8,3*8+4(r4) | |
288 | stw r0,4*8+0(r4) | |
289 | stw r9,4*8+4(r4) | |
290 | stw r10,5*8+0(r4) | |
291 | stw r11,5*8+4(r4) | |
292 | ||
293 | blr | |
294 | ||
295 | ||
296 | .align 5 | |
297 | .globl _munge_wsw | |
298 | _munge_wsw: | |
299 | li r0,0 | |
300 | lwz r5,0*8+4(r3) | |
301 | lwz r6,1*8+4(r3) | |
302 | lwz r7,2*8+4(r3) | |
303 | ||
304 | stw r0,0*8+0(r4) | |
305 | srawi r2,r6,31 | |
306 | stw r5,0*8+4(r4) | |
307 | stw r2,1*8+0(r4) | |
308 | stw r6,1*8+4(r4) | |
309 | stw r0,2*8+0(r4) | |
310 | stw r7,2*8+4(r4) | |
311 | ||
312 | blr | |
313 | ||
314 | ||
315 | .align 5 | |
316 | .globl _munge_wws | |
317 | _munge_wws: | |
318 | li r0,0 | |
319 | lwz r5,0*8+4(r3) | |
320 | lwz r6,1*8+4(r3) | |
321 | lwz r7,2*8+4(r3) | |
322 | ||
323 | stw r0,0*8+0(r4) | |
324 | stw r5,0*8+4(r4) | |
325 | stw r0,1*8+0(r4) | |
326 | srawi r2,r7,31 | |
327 | stw r6,1*8+4(r4) | |
328 | stw r2,2*8+0(r4) | |
329 | stw r7,2*8+4(r4) | |
330 | ||
331 | blr | |
332 | ||
333 | ||
334 | .align 5 | |
335 | .globl _munge_wwwsw | |
336 | _munge_wwwsw: | |
337 | li r0,0 | |
338 | lwz r5,0*8+4(r3) | |
339 | lwz r6,1*8+4(r3) | |
340 | lwz r7,2*8+4(r3) | |
341 | lwz r8,3*8+4(r3) | |
342 | lwz r9,4*8+4(r3) | |
343 | ||
344 | stw r0,0*8+0(r4) | |
345 | stw r5,0*8+4(r4) | |
346 | stw r0,1*8+0(r4) | |
347 | stw r6,1*8+4(r4) | |
348 | srawi r2,r8,31 | |
349 | stw r0,2*8+0(r4) | |
350 | stw r7,2*8+4(r4) | |
351 | stw r2,3*8+0(r4) | |
352 | stw r8,3*8+4(r4) | |
353 | stw r0,4*8+0(r4) | |
354 | stw r9,4*8+4(r4) | |
355 | ||
356 | blr |