]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/munge.s
9759b04addc19f479946484a06997bfa4220dbb0
[apple/xnu.git] / bsd / dev / ppc / munge.s
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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_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
276 .align 5
277 .globl _munge_wwwwl // 4 'w's and an l
278 _munge_wwwwl:
279 li r0,0
280 lwz r5,0*8+4(r3)
281 lwz r6,1*8+4(r3)
282 lwz r7,2*8+4(r3)
283 lwz r8,3*8+4(r3)
284 lwz r9,4*8+4(r3)
285 lwz r10,5*8+4(r3)
286
287 stw r0,0*8+0(r4)
288 stw r5,0*8+4(r4)
289 stw r0,1*8+0(r4)
290 stw r6,1*8+4(r4)
291 stw r0,2*8+0(r4)
292 stw r7,2*8+4(r4)
293 stw r0,3*8+0(r4)
294 stw r8,3*8+4(r4)
295 stw r9,4*8+0(r4)
296 stw r10,4*8+4(r4)
297
298 blr
299
300
301 .align 5
302 .globl _munge_wwwwwl // 5 'w's and an l
303 _munge_wwwwwl:
304 li r0,0
305 lwz r5,0*8+4(r3)
306 lwz r6,1*8+4(r3)
307 lwz r7,2*8+4(r3)
308 lwz r8,3*8+4(r3)
309 lwz r9,4*8+4(r3)
310 lwz r10,5*8+4(r3)
311 lwz r11,6*8+4(r3)
312
313 stw r0,0*8+0(r4)
314 stw r5,0*8+4(r4)
315 stw r0,1*8+0(r4)
316 stw r6,1*8+4(r4)
317 stw r0,2*8+0(r4)
318 stw r7,2*8+4(r4)
319 stw r0,3*8+0(r4)
320 stw r8,3*8+4(r4)
321 stw r0,4*8+0(r4)
322 stw r9,4*8+4(r4)
323 stw r10,5*8+0(r4)
324 stw r11,5*8+4(r4)
325
326 blr
327
328
329 .align 5
330 .globl _munge_wsw
331 _munge_wsw:
332 li r0,0
333 lwz r5,0*8+4(r3)
334 lwz r6,1*8+4(r3)
335 lwz r7,2*8+4(r3)
336
337 stw r0,0*8+0(r4)
338 srawi r2,r6,31
339 stw r5,0*8+4(r4)
340 stw r2,1*8+0(r4)
341 stw r6,1*8+4(r4)
342 stw r0,2*8+0(r4)
343 stw r7,2*8+4(r4)
344
345 blr
346
347
348 .align 5
349 .globl _munge_wws
350 _munge_wws:
351 li r0,0
352 lwz r5,0*8+4(r3)
353 lwz r6,1*8+4(r3)
354 lwz r7,2*8+4(r3)
355
356 stw r0,0*8+0(r4)
357 stw r5,0*8+4(r4)
358 stw r0,1*8+0(r4)
359 srawi r2,r7,31
360 stw r6,1*8+4(r4)
361 stw r2,2*8+0(r4)
362 stw r7,2*8+4(r4)
363
364 blr
365
366
367 .align 5
368 .globl _munge_wwwsw
369 _munge_wwwsw:
370 li r0,0
371 lwz r5,0*8+4(r3)
372 lwz r6,1*8+4(r3)
373 lwz r7,2*8+4(r3)
374 lwz r8,3*8+4(r3)
375 lwz r9,4*8+4(r3)
376
377 stw r0,0*8+0(r4)
378 stw r5,0*8+4(r4)
379 stw r0,1*8+0(r4)
380 stw r6,1*8+4(r4)
381 srawi r2,r8,31
382 stw r0,2*8+0(r4)
383 stw r7,2*8+4(r4)
384 stw r2,3*8+0(r4)
385 stw r8,3*8+4(r4)
386 stw r0,4*8+0(r4)
387 stw r9,4*8+4(r4)
388
389 blr