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