]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/munge.c
xnu-7195.81.3.tar.gz
[apple/xnu.git] / bsd / dev / munge.c
CommitLineData
39236c6e
A
1/*
2 * Coyright (c) 2005-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
39236c6e
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.
0a7de745 14 *
39236c6e
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
39236c6e
A
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.
0a7de745 25 *
39236c6e
A
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 37
0a7de745 38static inline __attribute__((always_inline)) void
fe8ab488
A
39munge_32_to_64_unsigned(volatile uint64_t *dest, volatile uint32_t *src, int count);
40
0a7de745 41void
fe8ab488 42munge_w(void *args)
39236c6e
A
43{
44 munge_32_to_64_unsigned(args, args, 1);
45}
46
0a7de745 47void
fe8ab488 48munge_ww(void *args)
39236c6e
A
49{
50 munge_32_to_64_unsigned(args, args, 2);
51}
52
0a7de745 53void
fe8ab488 54munge_www(void *args)
39236c6e
A
55{
56 munge_32_to_64_unsigned(args, args, 3);
57}
58
0a7de745 59void
fe8ab488 60munge_wwww(void *args)
39236c6e
A
61{
62 munge_32_to_64_unsigned(args, args, 4);
63}
64
0a7de745 65void
fe8ab488 66munge_wwwww(void *args)
39236c6e
A
67{
68 munge_32_to_64_unsigned(args, args, 5);
69}
70
0a7de745 71void
fe8ab488 72munge_wwwwww(void *args)
39236c6e
A
73{
74 munge_32_to_64_unsigned(args, args, 6);
75}
76
0a7de745 77void
fe8ab488 78munge_wwwwwww(void *args)
39236c6e
A
79{
80 munge_32_to_64_unsigned(args, args, 7);
81}
82
0a7de745 83void
fe8ab488 84munge_wwwwwwww(void *args)
39236c6e
A
85{
86 munge_32_to_64_unsigned(args, args, 8);
87}
88
0a7de745 89void
fe8ab488 90munge_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
3e170ce0 95 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
96 out_args[0] = in_args[0];
97}
98
0a7de745 99void
fe8ab488 100munge_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
3e170ce0 105 out_args[2] = *(volatile uint64_t*)&in_args[2];
39236c6e
A
106 out_args[1] = in_args[1];
107 out_args[0] = in_args[0];
108}
109
0a7de745 110void
fe8ab488 111munge_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];
3e170ce0 117 out_args[2] = *(volatile uint64_t*)&in_args[2];
39236c6e
A
118 out_args[1] = in_args[1];
119 out_args[0] = in_args[0];
120}
0a7de745 121void
fe8ab488 122munge_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
3e170ce0
A
127 out_args[4] = *(volatile uint64_t*)&in_args[6];
128 out_args[3] = *(volatile uint64_t*)&in_args[4];
129 out_args[2] = *(volatile uint64_t*)&in_args[2];
39236c6e
A
130 out_args[1] = in_args[1];
131 out_args[0] = in_args[0];
132}
133
134void
fe8ab488 135munge_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];
3e170ce0
A
142 out_args[3] = *(volatile uint64_t*)&in_args[4];
143 out_args[2] = *(volatile uint64_t*)&in_args[2];
39236c6e
A
144 out_args[1] = in_args[1];
145 out_args[0] = in_args[0];
146}
147
148void
fe8ab488 149munge_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];
3e170ce0
A
155 out_args[1] = *(volatile uint64_t*)&in_args[1];
156 out_args[0] = in_args[0];
157}
158
159void
160munge_wlww(void *args)
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[3] = in_args[4];
166 out_args[2] = in_args[3];
167 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
168 out_args[0] = in_args[0];
169}
170
171void
fe8ab488 172munge_wlwwwll(void *args)
39236c6e
A
173{
174 volatile uint64_t *out_args = (volatile uint64_t*)args;
175 volatile uint32_t *in_args = (volatile uint32_t*)args;
176
3e170ce0
A
177 out_args[6] = *(volatile uint64_t*)&in_args[8];
178 out_args[5] = *(volatile uint64_t*)&in_args[6];
39236c6e
A
179 out_args[4] = in_args[5];
180 out_args[3] = in_args[4];
181 out_args[2] = in_args[3];
3e170ce0 182 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
183 out_args[0] = in_args[0];
184}
185
186void
fe8ab488 187munge_wlwwwllw(void *args)
39236c6e
A
188{
189 volatile uint64_t *out_args = (volatile uint64_t*)args;
190 volatile uint32_t *in_args = (volatile uint32_t*)args;
191
192 out_args[7] = in_args[10];
fe8ab488 193 munge_wlwwwll(args);
39236c6e
A
194}
195
0a7de745 196void
fe8ab488 197munge_wlwwlwlw(void *args)
39236c6e
A
198{
199 volatile uint64_t *out_args = (volatile uint64_t*)args;
200 volatile uint32_t *in_args = (volatile uint32_t*)args;
201
202 out_args[7] = in_args[10];
3e170ce0 203 out_args[6] = *(volatile uint64_t*)&in_args[8];
39236c6e 204 out_args[5] = in_args[7];
3e170ce0 205 out_args[4] = *(volatile uint64_t*)&in_args[5];
39236c6e
A
206 out_args[3] = in_args[4];
207 out_args[2] = in_args[3];
3e170ce0 208 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
209 out_args[0] = in_args[0];
210}
211
0a7de745 212void
fe8ab488 213munge_wll(void *args)
39236c6e
A
214{
215 volatile uint64_t *out_args = (volatile uint64_t*)args;
216 volatile uint32_t *in_args = (volatile uint32_t*)args;
217
3e170ce0
A
218 out_args[2] = *(volatile uint64_t*)&in_args[3];
219 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
220 out_args[0] = in_args[0];
221}
222
0a7de745 223void
fe8ab488 224munge_wlll(void *args)
39236c6e
A
225{
226 volatile uint64_t *out_args = (volatile uint64_t*)args;
227 volatile uint32_t *in_args = (volatile uint32_t*)args;
228
3e170ce0
A
229 out_args[3] = *(volatile uint64_t*)&in_args[5];
230 out_args[2] = *(volatile uint64_t*)&in_args[3];
231 out_args[1] = *(volatile uint64_t*)&in_args[1];
a1c7dba1
A
232 out_args[0] = in_args[0];
233}
234
f427ee49
A
235void
236munge_wlllww(void *args)
237{
238 volatile uint64_t *out_args = (volatile uint64_t*)args;
239 volatile uint32_t *in_args = (volatile uint32_t*)args;
240
241 out_args[5] = in_args[8];
242 out_args[4] = in_args[7];
243 out_args[3] = *(volatile uint64_t*)&in_args[5];
244 out_args[2] = *(volatile uint64_t*)&in_args[3];
245 out_args[1] = *(volatile uint64_t*)&in_args[1];
246 out_args[0] = in_args[0];
247}
248
0a7de745 249void
a1c7dba1
A
250munge_wllll(void *args)
251{
252 volatile uint64_t *out_args = (volatile uint64_t*)args;
253 volatile uint32_t *in_args = (volatile uint32_t*)args;
254
3e170ce0
A
255 out_args[4] = *(volatile uint64_t*)&in_args[7];
256 out_args[3] = *(volatile uint64_t*)&in_args[5];
257 out_args[2] = *(volatile uint64_t*)&in_args[3];
258 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
259 out_args[0] = in_args[0];
260}
261
262void
fe8ab488 263munge_wllww(void *args)
39236c6e
A
264{
265 volatile uint64_t *out_args = (volatile uint64_t*)args;
266 volatile uint32_t *in_args = (volatile uint32_t*)args;
267
268 out_args[4] = in_args[6];
269 out_args[3] = in_args[5];
3e170ce0
A
270 out_args[2] = *(volatile uint64_t*)&in_args[3];
271 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
272 out_args[0] = in_args[0];
273}
274
0a7de745 275void
fe8ab488 276munge_wllwwll(void *args)
39236c6e
A
277{
278 volatile uint64_t *out_args = (volatile uint64_t*)args;
279 volatile uint32_t *in_args = (volatile uint32_t*)args;
280
3e170ce0
A
281 out_args[6] = *(volatile uint64_t*)&in_args[9];
282 out_args[5] = *(volatile uint64_t*)&in_args[7];
39236c6e
A
283 out_args[4] = in_args[6];
284 out_args[3] = in_args[5];
3e170ce0
A
285 out_args[2] = *(volatile uint64_t*)&in_args[3];
286 out_args[1] = *(volatile uint64_t*)&in_args[1];
39236c6e
A
287 out_args[0] = in_args[0];
288}
289
0a7de745 290void
fe8ab488 291munge_wwwlw(void *args)
39236c6e
A
292{
293 volatile uint64_t *out_args = (volatile uint64_t*)args;
294 volatile uint32_t *in_args = (volatile uint32_t*)args;
295
296 out_args[4] = in_args[5];
3e170ce0 297 out_args[3] = *(volatile uint64_t*)&in_args[3];
39236c6e
A
298 out_args[2] = in_args[2];
299 out_args[1] = in_args[1];
300 out_args[0] = in_args[0];
301}
302
0a7de745 303void
fe8ab488 304munge_wwwlww(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] = in_args[5];
3e170ce0 311 out_args[3] = *(volatile uint64_t*)&in_args[3];
39236c6e
A
312 out_args[2] = in_args[2];
313 out_args[1] = in_args[1];
314 out_args[0] = in_args[0];
315}
0a7de745 316
f427ee49
A
317void
318munge_wwwlwww(void *args)
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[6] = in_args[7];
324 out_args[5] = in_args[6];
325 out_args[4] = in_args[5];
326 out_args[3] = *(volatile uint64_t*)&in_args[3];
327 out_args[2] = in_args[2];
328 out_args[1] = in_args[1];
329 out_args[0] = in_args[0];
330}
331
0a7de745 332void
fe8ab488 333munge_wwwl(void *args)
39236c6e
A
334{
335 volatile uint64_t *out_args = (volatile uint64_t*)args;
336 volatile uint32_t *in_args = (volatile uint32_t*)args;
337
3e170ce0 338 out_args[3] = *(volatile uint64_t*)&in_args[3];
39236c6e
A
339 out_args[2] = in_args[2];
340 out_args[1] = in_args[1];
341 out_args[0] = in_args[0];
342}
343
0a7de745 344void
fe8ab488 345munge_wwwwlw(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[5] = in_args[6];
3e170ce0 351 out_args[4] = *(volatile uint64_t*)&in_args[4];
f427ee49
A
352 out_args[3] = in_args[3];
353 out_args[2] = in_args[2];
354 out_args[1] = in_args[1];
355 out_args[0] = in_args[0];
356}
357
358void
359munge_wwwwllww(void *args)
360{
361 volatile uint64_t *out_args = (volatile uint64_t*)args;
362 volatile uint32_t *in_args = (volatile uint32_t*)args;
363
364 out_args[7] = in_args[9];
365 out_args[6] = in_args[8];
366 out_args[5] = *(volatile uint64_t*)&in_args[6];
367 out_args[4] = *(volatile uint64_t*)&in_args[4];
39236c6e
A
368 out_args[3] = in_args[3];
369 out_args[2] = in_args[2];
370 out_args[1] = in_args[1];
371 out_args[0] = in_args[0];
372}
373
0a7de745 374void
fe8ab488 375munge_wwwwl(void *args)
39236c6e
A
376{
377 volatile uint64_t *out_args = (volatile uint64_t*)args;
378 volatile uint32_t *in_args = (volatile uint32_t*)args;
379
3e170ce0 380 out_args[4] = *(volatile uint64_t*)&in_args[4];
39236c6e
A
381 out_args[3] = in_args[3];
382 out_args[2] = in_args[2];
383 out_args[1] = in_args[1];
384 out_args[0] = in_args[0];
385}
386
0a7de745 387void
fe8ab488 388munge_wwwwwl(void *args)
39236c6e
A
389{
390 volatile uint64_t *out_args = (volatile uint64_t*)args;
391 volatile uint32_t *in_args = (volatile uint32_t*)args;
392
3e170ce0 393 out_args[5] = *(volatile uint64_t*)&in_args[5];
39236c6e
A
394 out_args[4] = in_args[4];
395 out_args[3] = in_args[3];
396 out_args[2] = in_args[2];
397 out_args[1] = in_args[1];
398 out_args[0] = in_args[0];
399}
400
0a7de745 401void
fe8ab488 402munge_wwwwwlww(void *args)
39236c6e
A
403{
404 volatile uint64_t *out_args = (volatile uint64_t*)args;
405 volatile uint32_t *in_args = (volatile uint32_t*)args;
406
407 out_args[7] = in_args[8];
408 out_args[6] = in_args[7];
3e170ce0 409 out_args[5] = *(volatile uint64_t*)&in_args[5];
39236c6e
A
410 out_args[4] = in_args[4];
411 out_args[3] = in_args[3];
412 out_args[2] = in_args[2];
413 out_args[1] = in_args[1];
414 out_args[0] = in_args[0];
415}
416
0a7de745 417void
fe8ab488 418munge_wwwwwllw(void *args)
39236c6e
A
419{
420 volatile uint64_t *out_args = (volatile uint64_t*)args;
421 volatile uint32_t *in_args = (volatile uint32_t*)args;
422
423 out_args[7] = in_args[9];
3e170ce0
A
424 out_args[6] = *(volatile uint64_t*)&in_args[7];
425 out_args[5] = *(volatile uint64_t*)&in_args[5];
39236c6e
A
426 out_args[4] = in_args[4];
427 out_args[3] = in_args[3];
428 out_args[2] = in_args[2];
429 out_args[1] = in_args[1];
430 out_args[0] = in_args[0];
431}
432
0a7de745 433void
fe8ab488 434munge_wwwwwlll(void *args)
39236c6e
A
435{
436 volatile uint64_t *out_args = (volatile uint64_t*)args;
437 volatile uint32_t *in_args = (volatile uint32_t*)args;
438
3e170ce0
A
439 out_args[7] = *(volatile uint64_t*)&in_args[9];
440 out_args[6] = *(volatile uint64_t*)&in_args[7];
441 out_args[5] = *(volatile uint64_t*)&in_args[5];
39236c6e
A
442 out_args[4] = in_args[4];
443 out_args[3] = in_args[3];
444 out_args[2] = in_args[2];
445 out_args[1] = in_args[1];
446 out_args[0] = in_args[0];
447}
448
0a7de745 449void
fe8ab488 450munge_wwwwwwl(void *args)
39236c6e
A
451{
452 volatile uint64_t *out_args = (volatile uint64_t*)args;
453 volatile uint32_t *in_args = (volatile uint32_t*)args;
454
3e170ce0 455 out_args[6] = *(volatile uint64_t*)&in_args[6];
39236c6e
A
456 out_args[5] = in_args[5];
457 out_args[4] = in_args[4];
458 out_args[3] = in_args[3];
459 out_args[2] = in_args[2];
460 out_args[1] = in_args[1];
461 out_args[0] = in_args[0];
462}
0a7de745
A
463
464void
fe8ab488 465munge_wwwwwwlw(void *args)
39236c6e
A
466{
467 volatile uint64_t *out_args = (volatile uint64_t*)args;
468 volatile uint32_t *in_args = (volatile uint32_t*)args;
469
470 out_args[7] = in_args[8];
3e170ce0 471 out_args[6] = *(volatile uint64_t*)&in_args[6];
39236c6e
A
472 out_args[5] = in_args[5];
473 out_args[4] = in_args[4];
474 out_args[3] = in_args[3];
475 out_args[2] = in_args[2];
476 out_args[1] = in_args[1];
477 out_args[0] = in_args[0];
478}
0a7de745
A
479
480void
fe8ab488 481munge_wwwwwwll(void *args)
39236c6e
A
482{
483 volatile uint64_t *out_args = (volatile uint64_t*)args;
484 volatile uint32_t *in_args = (volatile uint32_t*)args;
485
3e170ce0
A
486 out_args[7] = *(volatile uint64_t*)&in_args[8];
487 out_args[6] = *(volatile uint64_t*)&in_args[6];
39236c6e
A
488 out_args[5] = in_args[5];
489 out_args[4] = in_args[4];
490 out_args[3] = in_args[3];
491 out_args[2] = in_args[2];
492 out_args[1] = in_args[1];
493 out_args[0] = in_args[0];
494}
495
0a7de745 496void
fe8ab488 497munge_wsw(void *args)
39236c6e
A
498{
499 volatile uint64_t *out_args = (volatile uint64_t*)args;
500 volatile uint32_t *in_args = (volatile uint32_t*)args;
501
502 out_args[2] = in_args[2];
503 out_args[1] = (int64_t)(int)in_args[1]; /* Sign-extend */
504 out_args[0] = in_args[0];
505}
506
0a7de745 507void
fe8ab488 508munge_wws(void *args)
39236c6e
A
509{
510 volatile uint64_t *out_args = (volatile uint64_t*)args;
511 volatile uint32_t *in_args = (volatile uint32_t*)args;
512
513 out_args[2] = (int64_t)(int)in_args[2]; /* Sign-extend */
514 out_args[1] = in_args[1];
515 out_args[0] = in_args[0];
516}
517
0a7de745 518void
3e170ce0
A
519munge_wwws(void *args)
520{
521 volatile uint64_t *out_args = (volatile uint64_t*)args;
522 volatile uint32_t *in_args = (volatile uint32_t*)args;
523
524 out_args[3] = (int64_t)(int)in_args[3]; /* Sign-extend */
525 out_args[2] = in_args[2];
526 out_args[1] = in_args[1];
527 out_args[0] = in_args[0];
528}
529
530
531void
fe8ab488 532munge_wwwsw(void *args)
39236c6e
A
533{
534 volatile uint64_t *out_args = (volatile uint64_t*)args;
535 volatile uint32_t *in_args = (volatile uint32_t*)args;
536
537 out_args[4] = in_args[4];
538 out_args[3] = (int64_t)(int)in_args[3]; /* Sign-extend */
539 out_args[2] = in_args[2];
540 out_args[1] = in_args[1];
541 out_args[0] = in_args[0];
542}
543
0a7de745 544void
fe8ab488 545munge_llllll(void *args __unused)
39236c6e
A
546{
547 /* Nothing to do, already all 64-bit */
548}
549
0a7de745 550void
fe8ab488 551munge_ll(void *args __unused)
39236c6e
A
552{
553 /* Nothing to do, already all 64-bit */
554}
555
0a7de745 556void
fe8ab488 557munge_l(void *args __unused)
39236c6e
A
558{
559 /* Nothing to do, already all 64-bit */
560}
561
0a7de745 562void
fe8ab488 563munge_lw(void *args)
39236c6e
A
564{
565 volatile uint64_t *out_args = (volatile uint64_t*)args;
566 volatile uint32_t *in_args = (volatile uint32_t*)args;
567
568 out_args[1] = in_args[2];
3e170ce0 569 out_args[0] = *(volatile uint64_t*)&in_args[0];
39236c6e
A
570}
571
0a7de745 572void
fe8ab488 573munge_lwww(void *args)
39236c6e
A
574{
575 volatile uint64_t *out_args = (volatile uint64_t*)args;
576 volatile uint32_t *in_args = (volatile uint32_t*)args;
577
0a7de745 578 out_args[3] = in_args[4];
39236c6e
A
579 out_args[2] = in_args[3];
580 out_args[1] = in_args[2];
3e170ce0 581 out_args[0] = *(volatile uint64_t*)&in_args[0];
39236c6e
A
582}
583
0a7de745 584void
5ba3f43e
A
585munge_lwwwwwww(void *args)
586{
587 volatile uint64_t *out_args = (volatile uint64_t*)args;
588 volatile uint32_t *in_args = (volatile uint32_t*)args;
589
590 out_args[7] = in_args[8];
0a7de745 591 out_args[6] = in_args[7];
5ba3f43e
A
592 out_args[5] = in_args[6];
593 out_args[4] = in_args[5];
0a7de745 594 out_args[3] = in_args[4];
5ba3f43e
A
595 out_args[2] = in_args[3];
596 out_args[1] = in_args[2];
597 out_args[0] = *(volatile uint64_t*)&in_args[0];
598}
599
39037602
A
600void
601munge_wwlww(void *args)
602{
603 volatile uint64_t *out_args = (volatile uint64_t*)args;
604 volatile uint32_t *in_args = (volatile uint32_t*)args;
605
606 out_args[4] = in_args[5];
607 out_args[3] = in_args[4];
608 out_args[2] = *(volatile uint64_t*)&in_args[2];
609 out_args[1] = in_args[1];
610 out_args[0] = in_args[0];
611}
612
39236c6e 613void
fe8ab488 614munge_wwlwww(void *args)
39236c6e
A
615{
616 volatile uint64_t *out_args = (volatile uint64_t*)args;
617 volatile uint32_t *in_args = (volatile uint32_t*)args;
0a7de745 618
39236c6e
A
619 out_args[5] = in_args[6];
620 out_args[4] = in_args[5];
621 out_args[3] = in_args[4];
3e170ce0 622 out_args[2] = *(volatile uint64_t*)&in_args[2];
39236c6e
A
623 out_args[1] = in_args[1];
624 out_args[0] = in_args[0];
625}
626
39037602
A
627void
628munge_wlwwwl(void *args)
629{
630 volatile uint64_t *out_args = (volatile uint64_t*)args;
631 volatile uint32_t *in_args = (volatile uint32_t*)args;
632
633 out_args[5] = *(volatile uint64_t*)&in_args[6];
634 out_args[4] = in_args[5];
635 out_args[3] = in_args[4];
636 out_args[2] = in_args[3];
637 out_args[1] = *(volatile uint64_t*)&in_args[1];
638 out_args[0] = in_args[0];
639}
640
641void
642munge_wwlwwwl(void *args)
643{
644 volatile uint64_t *out_args = (volatile uint64_t*)args;
645 volatile uint32_t *in_args = (volatile uint32_t*)args;
646
647 out_args[6] = *(volatile uint64_t*)&in_args[7];
648 out_args[5] = in_args[6];
649 out_args[4] = in_args[5];
650 out_args[3] = in_args[4];
651 out_args[2] = *(volatile uint64_t*)&in_args[2];
652 out_args[1] = in_args[1];
653 out_args[0] = in_args[0];
654}
655
39236c6e
A
656/*
657 * Munge array of 32-bit values into an array of 64-bit values,
0a7de745 658 * without sign extension. Note, src and dest can be the same
39236c6e
A
659 * (copies from end of array)
660 */
0a7de745 661static inline __attribute__((always_inline)) void
39236c6e
A
662munge_32_to_64_unsigned(volatile uint64_t *dest, volatile uint32_t *src, int count)
663{
664 int i;
665
666 for (i = count - 1; i >= 0; i--) {
667 dest[i] = src[i];
0a7de745 668 }
39236c6e 669}