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