]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/ppc/munge.s
xnu-1228.tar.gz
[apple/xnu.git] / bsd / dev / ppc / munge.s
CommitLineData
91447636 1/*
5d5c5d0d
A
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
91447636 5 *
2d21ac55
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 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
0c530ab8
A
249 .align 5
250 .globl _munge_wwwlww
251_munge_wwwlww:
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 lwz r11,6*8+4(r3)
260
261 stw r0,0*8+0(r4)
262 stw r5,0*8+4(r4)
263 stw r0,1*8+0(r4)
264 stw r6,1*8+4(r4)
265 stw r0,2*8+0(r4)
266 stw r7,2*8+4(r4)
267 stw r8,3*8+0(r4)
268 stw r9,3*8+4(r4)
269 stw r0,4*8+0(r4)
270 stw r10,4*8+4(r4)
271 stw r0,5*8+0(r4)
272 stw r11,5*8+4(r4)
273
274 blr
275
2d21ac55
A
276
277 .align 5
278 .globl _munge_wwlwww
279_munge_wwlwww:
280 li r0,0
281 lwz r5,0*8+4(r3) // Wwlwww
282 lwz r6,1*8+4(r3) // wWlwww
283 lwz r7,2*8+4(r3) // wwLwww (hi)
284 lwz r8,3*8+4(r3) // wwLwww (lo)
285 lwz r9,4*8+4(r3) // wwlWww
286 lwz r10,5*8+4(r3) // wwlwWw
287 lwz r11,6*8+4(r3) // wwlwwW
288
289 stw r0,0*8+0(r4) // 0wlwww
290 stw r5,0*8+4(r4) // Wwlwww
291 stw r0,1*8+0(r4) // w0lwww
292 stw r6,1*8+4(r4) // wWlwww
293 stw r7,2*8+0(r4) // wwLwww (hi)
294 stw r8,2*8+4(r4) // wwLwww (lo)
295 stw r0,3*8+0(r4) // wwl0ww
296 stw r9,3*8+4(r4) // wwlwww
297 stw r0, 4*8+0(r4) // wwlw0w
298 stw r10,4*8+4(r4) // wwlwWw
299 stw r0, 5*8+0(r4) // wwlww0
300 stw r11,5*8+4(r4) // wwlwwW
301
302 blr
303
304
91447636
A
305 .align 5
306 .globl _munge_wwwwl // 4 'w's and an l
307_munge_wwwwl:
308 li r0,0
309 lwz r5,0*8+4(r3)
310 lwz r6,1*8+4(r3)
311 lwz r7,2*8+4(r3)
312 lwz r8,3*8+4(r3)
313 lwz r9,4*8+4(r3)
314 lwz r10,5*8+4(r3)
315
316 stw r0,0*8+0(r4)
317 stw r5,0*8+4(r4)
318 stw r0,1*8+0(r4)
319 stw r6,1*8+4(r4)
320 stw r0,2*8+0(r4)
321 stw r7,2*8+4(r4)
322 stw r0,3*8+0(r4)
323 stw r8,3*8+4(r4)
324 stw r9,4*8+0(r4)
325 stw r10,4*8+4(r4)
326
327 blr
328
329
330 .align 5
331 .globl _munge_wwwwwl // 5 'w's and an l
332_munge_wwwwwl:
333 li r0,0
334 lwz r5,0*8+4(r3)
335 lwz r6,1*8+4(r3)
336 lwz r7,2*8+4(r3)
337 lwz r8,3*8+4(r3)
338 lwz r9,4*8+4(r3)
339 lwz r10,5*8+4(r3)
340 lwz r11,6*8+4(r3)
341
342 stw r0,0*8+0(r4)
343 stw r5,0*8+4(r4)
344 stw r0,1*8+0(r4)
345 stw r6,1*8+4(r4)
346 stw r0,2*8+0(r4)
347 stw r7,2*8+4(r4)
348 stw r0,3*8+0(r4)
349 stw r8,3*8+4(r4)
350 stw r0,4*8+0(r4)
351 stw r9,4*8+4(r4)
352 stw r10,5*8+0(r4)
353 stw r11,5*8+4(r4)
354
355 blr
356
357
358 .align 5
359 .globl _munge_wsw
360_munge_wsw:
361 li r0,0
362 lwz r5,0*8+4(r3)
363 lwz r6,1*8+4(r3)
364 lwz r7,2*8+4(r3)
365
366 stw r0,0*8+0(r4)
367 srawi r2,r6,31
368 stw r5,0*8+4(r4)
369 stw r2,1*8+0(r4)
370 stw r6,1*8+4(r4)
371 stw r0,2*8+0(r4)
372 stw r7,2*8+4(r4)
373
374 blr
375
376
377 .align 5
378 .globl _munge_wws
379_munge_wws:
380 li r0,0
381 lwz r5,0*8+4(r3)
382 lwz r6,1*8+4(r3)
383 lwz r7,2*8+4(r3)
384
385 stw r0,0*8+0(r4)
386 stw r5,0*8+4(r4)
387 stw r0,1*8+0(r4)
388 srawi r2,r7,31
389 stw r6,1*8+4(r4)
390 stw r2,2*8+0(r4)
391 stw r7,2*8+4(r4)
392
393 blr
394
395
396 .align 5
397 .globl _munge_wwwsw
398_munge_wwwsw:
399 li r0,0
400 lwz r5,0*8+4(r3)
401 lwz r6,1*8+4(r3)
402 lwz r7,2*8+4(r3)
403 lwz r8,3*8+4(r3)
404 lwz r9,4*8+4(r3)
405
406 stw r0,0*8+0(r4)
407 stw r5,0*8+4(r4)
408 stw r0,1*8+0(r4)
409 stw r6,1*8+4(r4)
410 srawi r2,r8,31
411 stw r0,2*8+0(r4)
412 stw r7,2*8+4(r4)
413 stw r2,3*8+0(r4)
414 stw r8,3*8+4(r4)
415 stw r0,4*8+0(r4)
416 stw r9,4*8+4(r4)
417
418 blr