]>
Commit | Line | Data |
---|---|---|
39236c6e A |
1 | /* |
2 | * Coyright (c) 2005-2006 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 | #include <sys/cdefs.h> | |
30 | #include <sys/types.h> | |
31 | #include <sys/munge.h> | |
32 | #include <stdint.h> | |
33 | ||
39236c6e A |
34 | /* |
35 | * Refer to comments in bsd/sys/munge.h | |
36 | */ | |
fe8ab488 A |
37 | |
38 | static inline __attribute__((always_inline)) void | |
39 | munge_32_to_64_unsigned(volatile uint64_t *dest, volatile uint32_t *src, int count); | |
40 | ||
39236c6e | 41 | void |
fe8ab488 | 42 | munge_w(void *args) |
39236c6e A |
43 | { |
44 | munge_32_to_64_unsigned(args, args, 1); | |
45 | } | |
46 | ||
47 | void | |
fe8ab488 | 48 | munge_ww(void *args) |
39236c6e A |
49 | { |
50 | munge_32_to_64_unsigned(args, args, 2); | |
51 | } | |
52 | ||
53 | void | |
fe8ab488 | 54 | munge_www(void *args) |
39236c6e A |
55 | { |
56 | munge_32_to_64_unsigned(args, args, 3); | |
57 | } | |
58 | ||
59 | void | |
fe8ab488 | 60 | munge_wwww(void *args) |
39236c6e A |
61 | { |
62 | munge_32_to_64_unsigned(args, args, 4); | |
63 | } | |
64 | ||
65 | void | |
fe8ab488 | 66 | munge_wwwww(void *args) |
39236c6e A |
67 | { |
68 | munge_32_to_64_unsigned(args, args, 5); | |
69 | } | |
70 | ||
71 | void | |
fe8ab488 | 72 | munge_wwwwww(void *args) |
39236c6e A |
73 | { |
74 | munge_32_to_64_unsigned(args, args, 6); | |
75 | } | |
76 | ||
77 | void | |
fe8ab488 | 78 | munge_wwwwwww(void *args) |
39236c6e A |
79 | { |
80 | munge_32_to_64_unsigned(args, args, 7); | |
81 | } | |
82 | ||
83 | void | |
fe8ab488 | 84 | munge_wwwwwwww(void *args) |
39236c6e A |
85 | { |
86 | munge_32_to_64_unsigned(args, args, 8); | |
87 | } | |
88 | ||
89 | void | |
fe8ab488 | 90 | munge_wl(void *args) |
39236c6e A |
91 | { |
92 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
93 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
94 | ||
95 | out_args[1] = *(uint64_t*)&in_args[1]; | |
96 | out_args[0] = in_args[0]; | |
97 | } | |
98 | ||
99 | void | |
fe8ab488 | 100 | munge_wwl(void *args) |
39236c6e A |
101 | { |
102 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
103 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
104 | ||
105 | out_args[2] = *(uint64_t*)&in_args[2]; | |
106 | out_args[1] = in_args[1]; | |
107 | out_args[0] = in_args[0]; | |
108 | } | |
109 | ||
110 | void | |
fe8ab488 | 111 | munge_wwlw(void *args) |
39236c6e A |
112 | { |
113 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
114 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
115 | ||
116 | out_args[3] = in_args[4]; | |
117 | out_args[2] = *(uint64_t*)&in_args[2]; | |
118 | out_args[1] = in_args[1]; | |
119 | out_args[0] = in_args[0]; | |
120 | } | |
121 | void | |
fe8ab488 | 122 | munge_wwlll(void *args) |
39236c6e A |
123 | { |
124 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
125 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
126 | ||
127 | out_args[4] = *(uint64_t*)&in_args[6]; | |
128 | out_args[3] = *(uint64_t*)&in_args[4]; | |
129 | out_args[2] = *(uint64_t*)&in_args[2]; | |
130 | out_args[1] = in_args[1]; | |
131 | out_args[0] = in_args[0]; | |
132 | } | |
133 | ||
134 | void | |
fe8ab488 | 135 | munge_wwllww(void *args) |
39236c6e A |
136 | { |
137 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
138 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
139 | ||
140 | out_args[5] = in_args[7]; | |
141 | out_args[4] = in_args[6]; | |
142 | out_args[3] = *(uint64_t*)&in_args[4]; | |
143 | out_args[2] = *(uint64_t*)&in_args[2]; | |
144 | out_args[1] = in_args[1]; | |
145 | out_args[0] = in_args[0]; | |
146 | } | |
147 | ||
148 | void | |
fe8ab488 | 149 | munge_wlw(void *args) |
39236c6e A |
150 | { |
151 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
152 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
153 | ||
154 | out_args[2] = in_args[3]; | |
155 | out_args[1] = *(uint64_t*)&in_args[1]; | |
156 | out_args[0] = in_args[0]; | |
157 | } | |
158 | ||
159 | void | |
fe8ab488 | 160 | munge_wlwwwll(void *args) |
39236c6e A |
161 | { |
162 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
163 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
164 | ||
165 | out_args[6] = *(uint64_t*)&in_args[8]; | |
166 | out_args[5] = *(uint64_t*)&in_args[6]; | |
167 | out_args[4] = in_args[5]; | |
168 | out_args[3] = in_args[4]; | |
169 | out_args[2] = in_args[3]; | |
170 | out_args[1] = *(uint64_t*)&in_args[1]; | |
171 | out_args[0] = in_args[0]; | |
172 | } | |
173 | ||
174 | void | |
fe8ab488 | 175 | munge_wlwwwllw(void *args) |
39236c6e A |
176 | { |
177 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
178 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
179 | ||
180 | out_args[7] = in_args[10]; | |
fe8ab488 | 181 | munge_wlwwwll(args); |
39236c6e A |
182 | } |
183 | ||
184 | void | |
fe8ab488 | 185 | munge_wlwwlwlw(void *args) |
39236c6e A |
186 | { |
187 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
188 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
189 | ||
190 | out_args[7] = in_args[10]; | |
191 | out_args[6] = *(uint64_t*)&in_args[8]; | |
192 | out_args[5] = in_args[7]; | |
193 | out_args[4] = *(uint64_t*)&in_args[5]; | |
194 | out_args[3] = in_args[4]; | |
195 | out_args[2] = in_args[3]; | |
196 | out_args[1] = *(uint64_t*)&in_args[1]; | |
197 | out_args[0] = in_args[0]; | |
198 | } | |
199 | ||
200 | void | |
fe8ab488 | 201 | munge_wll(void *args) |
39236c6e A |
202 | { |
203 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
204 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
205 | ||
206 | out_args[2] = *(uint64_t*)&in_args[3]; | |
207 | out_args[1] = *(uint64_t*)&in_args[1]; | |
208 | out_args[0] = in_args[0]; | |
209 | } | |
210 | ||
211 | void | |
fe8ab488 | 212 | munge_wlll(void *args) |
39236c6e A |
213 | { |
214 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
215 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
216 | ||
217 | out_args[3] = *(uint64_t*)&in_args[5]; | |
218 | out_args[2] = *(uint64_t*)&in_args[3]; | |
219 | out_args[1] = *(uint64_t*)&in_args[1]; | |
a1c7dba1 A |
220 | out_args[0] = in_args[0]; |
221 | } | |
222 | ||
223 | void | |
224 | munge_wllll(void *args) | |
225 | { | |
226 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
227 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
228 | ||
229 | out_args[4] = *(uint64_t*)&in_args[7]; | |
230 | out_args[3] = *(uint64_t*)&in_args[5]; | |
231 | out_args[2] = *(uint64_t*)&in_args[3]; | |
232 | out_args[1] = *(uint64_t*)&in_args[1]; | |
39236c6e A |
233 | out_args[0] = in_args[0]; |
234 | } | |
235 | ||
236 | void | |
fe8ab488 | 237 | munge_wllww(void *args) |
39236c6e A |
238 | { |
239 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
240 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
241 | ||
242 | out_args[4] = in_args[6]; | |
243 | out_args[3] = in_args[5]; | |
244 | out_args[2] = *(uint64_t*)&in_args[3]; | |
245 | out_args[1] = *(uint64_t*)&in_args[1]; | |
246 | out_args[0] = in_args[0]; | |
247 | } | |
248 | ||
249 | void | |
fe8ab488 | 250 | munge_wllwwll(void *args) |
39236c6e A |
251 | { |
252 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
253 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
254 | ||
255 | out_args[6] = *(uint64_t*)&in_args[9]; | |
256 | out_args[5] = *(uint64_t*)&in_args[7]; | |
257 | out_args[4] = in_args[6]; | |
258 | out_args[3] = in_args[5]; | |
259 | out_args[2] = *(uint64_t*)&in_args[3]; | |
260 | out_args[1] = *(uint64_t*)&in_args[1]; | |
261 | out_args[0] = in_args[0]; | |
262 | } | |
263 | ||
264 | void | |
fe8ab488 | 265 | munge_wwwlw(void *args) |
39236c6e A |
266 | { |
267 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
268 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
269 | ||
270 | out_args[4] = in_args[5]; | |
271 | out_args[3] = *(uint64_t*)&in_args[3]; | |
272 | out_args[2] = in_args[2]; | |
273 | out_args[1] = in_args[1]; | |
274 | out_args[0] = in_args[0]; | |
275 | } | |
276 | ||
277 | void | |
fe8ab488 | 278 | munge_wwwlww(void *args) |
39236c6e A |
279 | { |
280 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
281 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
282 | ||
283 | out_args[5] = in_args[6]; | |
284 | out_args[4] = in_args[5]; | |
285 | out_args[3] = *(uint64_t*)&in_args[3]; | |
286 | out_args[2] = in_args[2]; | |
287 | out_args[1] = in_args[1]; | |
288 | out_args[0] = in_args[0]; | |
289 | } | |
290 | ||
291 | void | |
fe8ab488 | 292 | munge_wwwl(void *args) |
39236c6e A |
293 | { |
294 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
295 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
296 | ||
297 | out_args[3] = *(uint64_t*)&in_args[3]; | |
298 | out_args[2] = in_args[2]; | |
299 | out_args[1] = in_args[1]; | |
300 | out_args[0] = in_args[0]; | |
301 | } | |
302 | ||
303 | void | |
fe8ab488 | 304 | munge_wwwwlw(void *args) |
39236c6e A |
305 | { |
306 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
307 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
308 | ||
309 | out_args[5] = in_args[6]; | |
310 | out_args[4] = *(uint64_t*)&in_args[4]; | |
311 | out_args[3] = in_args[3]; | |
312 | out_args[2] = in_args[2]; | |
313 | out_args[1] = in_args[1]; | |
314 | out_args[0] = in_args[0]; | |
315 | } | |
316 | ||
317 | void | |
fe8ab488 | 318 | munge_wwwwl(void *args) |
39236c6e A |
319 | { |
320 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
321 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
322 | ||
323 | out_args[4] = *(uint64_t*)&in_args[4]; | |
324 | out_args[3] = in_args[3]; | |
325 | out_args[2] = in_args[2]; | |
326 | out_args[1] = in_args[1]; | |
327 | out_args[0] = in_args[0]; | |
328 | } | |
329 | ||
330 | void | |
fe8ab488 | 331 | munge_wwwwwl(void *args) |
39236c6e A |
332 | { |
333 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
334 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
335 | ||
336 | out_args[5] = *(uint64_t*)&in_args[5]; | |
337 | out_args[4] = in_args[4]; | |
338 | out_args[3] = in_args[3]; | |
339 | out_args[2] = in_args[2]; | |
340 | out_args[1] = in_args[1]; | |
341 | out_args[0] = in_args[0]; | |
342 | } | |
343 | ||
344 | void | |
fe8ab488 | 345 | munge_wwwwwlww(void *args) |
39236c6e A |
346 | { |
347 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
348 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
349 | ||
350 | out_args[7] = in_args[8]; | |
351 | out_args[6] = in_args[7]; | |
352 | out_args[5] = *(uint64_t*)&in_args[5]; | |
353 | out_args[4] = in_args[4]; | |
354 | out_args[3] = in_args[3]; | |
355 | out_args[2] = in_args[2]; | |
356 | out_args[1] = in_args[1]; | |
357 | out_args[0] = in_args[0]; | |
358 | } | |
359 | ||
360 | void | |
fe8ab488 | 361 | munge_wwwwwllw(void *args) |
39236c6e A |
362 | { |
363 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
364 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
365 | ||
366 | out_args[7] = in_args[9]; | |
367 | out_args[6] = *(uint64_t*)&in_args[7]; | |
368 | out_args[5] = *(uint64_t*)&in_args[5]; | |
369 | out_args[4] = in_args[4]; | |
370 | out_args[3] = in_args[3]; | |
371 | out_args[2] = in_args[2]; | |
372 | out_args[1] = in_args[1]; | |
373 | out_args[0] = in_args[0]; | |
374 | } | |
375 | ||
376 | void | |
fe8ab488 | 377 | munge_wwwwwlll(void *args) |
39236c6e A |
378 | { |
379 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
380 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
381 | ||
382 | out_args[7] = *(uint64_t*)&in_args[9]; | |
383 | out_args[6] = *(uint64_t*)&in_args[7]; | |
384 | out_args[5] = *(uint64_t*)&in_args[5]; | |
385 | out_args[4] = in_args[4]; | |
386 | out_args[3] = in_args[3]; | |
387 | out_args[2] = in_args[2]; | |
388 | out_args[1] = in_args[1]; | |
389 | out_args[0] = in_args[0]; | |
390 | } | |
391 | ||
392 | void | |
fe8ab488 | 393 | munge_wwwwwwl(void *args) |
39236c6e A |
394 | { |
395 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
396 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
397 | ||
398 | out_args[6] = *(uint64_t*)&in_args[6]; | |
399 | out_args[5] = in_args[5]; | |
400 | out_args[4] = in_args[4]; | |
401 | out_args[3] = in_args[3]; | |
402 | out_args[2] = in_args[2]; | |
403 | out_args[1] = in_args[1]; | |
404 | out_args[0] = in_args[0]; | |
405 | } | |
406 | ||
407 | void | |
fe8ab488 | 408 | munge_wwwwwwlw(void *args) |
39236c6e A |
409 | { |
410 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
411 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
412 | ||
413 | out_args[7] = in_args[8]; | |
414 | out_args[6] = *(uint64_t*)&in_args[6]; | |
415 | out_args[5] = in_args[5]; | |
416 | out_args[4] = in_args[4]; | |
417 | out_args[3] = in_args[3]; | |
418 | out_args[2] = in_args[2]; | |
419 | out_args[1] = in_args[1]; | |
420 | out_args[0] = in_args[0]; | |
421 | } | |
422 | ||
423 | void | |
fe8ab488 | 424 | munge_wwwwwwll(void *args) |
39236c6e A |
425 | { |
426 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
427 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
428 | ||
429 | out_args[7] = *(uint64_t*)&in_args[8]; | |
430 | out_args[6] = *(uint64_t*)&in_args[6]; | |
431 | out_args[5] = in_args[5]; | |
432 | out_args[4] = in_args[4]; | |
433 | out_args[3] = in_args[3]; | |
434 | out_args[2] = in_args[2]; | |
435 | out_args[1] = in_args[1]; | |
436 | out_args[0] = in_args[0]; | |
437 | } | |
438 | ||
439 | void | |
fe8ab488 | 440 | munge_wsw(void *args) |
39236c6e A |
441 | { |
442 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
443 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
444 | ||
445 | out_args[2] = in_args[2]; | |
446 | out_args[1] = (int64_t)(int)in_args[1]; /* Sign-extend */ | |
447 | out_args[0] = in_args[0]; | |
448 | } | |
449 | ||
450 | void | |
fe8ab488 | 451 | munge_wws(void *args) |
39236c6e A |
452 | { |
453 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
454 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
455 | ||
456 | out_args[2] = (int64_t)(int)in_args[2]; /* Sign-extend */ | |
457 | out_args[1] = in_args[1]; | |
458 | out_args[0] = in_args[0]; | |
459 | } | |
460 | ||
461 | void | |
fe8ab488 | 462 | munge_wwwsw(void *args) |
39236c6e A |
463 | { |
464 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
465 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
466 | ||
467 | out_args[4] = in_args[4]; | |
468 | out_args[3] = (int64_t)(int)in_args[3]; /* Sign-extend */ | |
469 | out_args[2] = in_args[2]; | |
470 | out_args[1] = in_args[1]; | |
471 | out_args[0] = in_args[0]; | |
472 | } | |
473 | ||
474 | void | |
fe8ab488 | 475 | munge_llllll(void *args __unused) |
39236c6e A |
476 | { |
477 | /* Nothing to do, already all 64-bit */ | |
478 | } | |
479 | ||
480 | void | |
fe8ab488 | 481 | munge_ll(void *args __unused) |
39236c6e A |
482 | { |
483 | /* Nothing to do, already all 64-bit */ | |
484 | } | |
485 | ||
486 | void | |
fe8ab488 | 487 | munge_l(void *args __unused) |
39236c6e A |
488 | { |
489 | /* Nothing to do, already all 64-bit */ | |
490 | } | |
491 | ||
492 | void | |
fe8ab488 | 493 | munge_lw(void *args) |
39236c6e A |
494 | { |
495 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
496 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
497 | ||
498 | out_args[1] = in_args[2]; | |
499 | out_args[0] = *(uint64_t*)&in_args[0]; | |
500 | } | |
501 | ||
502 | void | |
fe8ab488 | 503 | munge_lwww(void *args) |
39236c6e A |
504 | { |
505 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
506 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
507 | ||
508 | out_args[3] = in_args[4]; | |
509 | out_args[2] = in_args[3]; | |
510 | out_args[1] = in_args[2]; | |
511 | out_args[0] = *(uint64_t*)&in_args[0]; | |
512 | } | |
513 | ||
514 | void | |
fe8ab488 | 515 | munge_wwlwww(void *args) |
39236c6e A |
516 | { |
517 | volatile uint64_t *out_args = (volatile uint64_t*)args; | |
518 | volatile uint32_t *in_args = (volatile uint32_t*)args; | |
519 | ||
520 | out_args[5] = in_args[6]; | |
521 | out_args[4] = in_args[5]; | |
522 | out_args[3] = in_args[4]; | |
523 | out_args[2] = *(uint64_t*)&in_args[2]; | |
524 | out_args[1] = in_args[1]; | |
525 | out_args[0] = in_args[0]; | |
526 | } | |
527 | ||
528 | /* | |
529 | * Munge array of 32-bit values into an array of 64-bit values, | |
530 | * without sign extension. Note, src and dest can be the same | |
531 | * (copies from end of array) | |
532 | */ | |
533 | static inline __attribute__((always_inline)) void | |
534 | munge_32_to_64_unsigned(volatile uint64_t *dest, volatile uint32_t *src, int count) | |
535 | { | |
536 | int i; | |
537 | ||
538 | for (i = count - 1; i >= 0; i--) { | |
539 | dest[i] = src[i]; | |
540 | } | |
541 | } |