]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | /* |
2 | * Coyright (c) 2005-2015 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
0a7de745 | 5 | * |
5ba3f43e 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 | * |
5ba3f43e 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 | * |
5ba3f43e 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 | * |
5ba3f43e A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | ||
0a7de745 | 29 | /* |
5ba3f43e A |
30 | * For arm32 ABI where 64-bit types are aligned to even registers and |
31 | * 64-bits on stack, we need to unpack registers differently. So | |
32 | * we use the mungers for that. Currently this is just ARMv7k. | |
33 | * | |
34 | * Since arm32 has no need for munging otherwise, we don't include | |
35 | * any of this for other arm32 ABIs | |
36 | */ | |
37 | #if __arm__ && (__BIGGEST_ALIGNMENT__ > 4) | |
38 | ||
39 | #include <sys/munge.h> | |
40 | #include <sys/param.h> | |
41 | #include <mach/thread_status.h> | |
42 | #include <libkern/libkern.h> | |
43 | #include <stdint.h> | |
44 | ||
45 | ||
0a7de745 | 46 | /* |
5ba3f43e A |
47 | * Userspace args are in r0-r6, then r8, then stack unless this is an |
48 | * indirect call in which case the syscall number is in r0 then args | |
49 | * are in registers r1-r6, then r8, then stack. This is for mach and | |
50 | * BSD style syscalls. | |
51 | */ | |
52 | ||
53 | ||
54 | #define SS_TO_STYLE(ss) ((ss->r[12] != 0) ? kDirect : kIndirect) | |
55 | #define REGS_TO_STYLE(regs) (SS_TO_STYLE(((const arm_saved_state_t *)regs))) | |
56 | ||
57 | typedef enum { | |
58 | kIndirect = 0, | |
59 | kDirect | |
60 | } style_t; | |
61 | ||
62 | #define DECLARE_AND_CAST(regs, args, ss, uu_args) const arm_saved_state_t *ss = (const arm_saved_state_t *)regs; \ | |
0a7de745 | 63 | uint32_t *uu_args = (uint32_t *)args; |
5ba3f43e | 64 | |
0a7de745 | 65 | /* |
5ba3f43e | 66 | * We start 32 bytes after sp since 4 registers are pushed onto the stack |
0a7de745 | 67 | * in the userspace syscall handler, and the first 4 stack argumnets are moved |
5ba3f43e A |
68 | * into registers already |
69 | */ | |
70 | #define ARG_SP_BYTE_OFFSET 32 | |
71 | ||
72 | ||
73 | /* | |
74 | * Marshal in arguments from userspace where no padding exists | |
75 | */ | |
76 | ||
77 | static int | |
78 | marshal_no_pad(const arm_saved_state_t *ss, uint32_t *args, const uint32_t word_count) | |
79 | { | |
80 | int error = 0; | |
81 | /* init assuming kDirect style */ | |
82 | uint32_t copy_count, contiguous_reg_count = 7, contiguous_reg_start = 0; | |
83 | style_t style = SS_TO_STYLE(ss); | |
84 | ||
85 | if (style == kIndirect) { | |
86 | contiguous_reg_count--; | |
87 | contiguous_reg_start++; | |
88 | } | |
89 | ||
90 | /* r0 through r6 */ | |
91 | copy_count = MIN(word_count, contiguous_reg_count); | |
92 | memcpy(args, &(ss->r[contiguous_reg_start]), copy_count * sizeof(uint32_t)); | |
93 | args += copy_count; | |
94 | ||
95 | if (word_count > copy_count) { | |
96 | /* r8 */ | |
97 | *args = ss->r[8]; | |
98 | args++; | |
99 | copy_count++; | |
100 | ||
101 | /* stack */ | |
102 | if (word_count > copy_count) { | |
103 | error = copyin(ss->sp + ARG_SP_BYTE_OFFSET, | |
0a7de745 A |
104 | args, (word_count - copy_count) * sizeof(uint32_t)); |
105 | if (error) { | |
5ba3f43e | 106 | return error; |
0a7de745 | 107 | } |
5ba3f43e A |
108 | } |
109 | } | |
110 | return error; | |
111 | } | |
112 | ||
113 | /* | |
114 | * Define mungers to marshal userspace data into argument structs | |
115 | */ | |
116 | ||
117 | int | |
118 | munge_w(const void *regs, void *args) | |
119 | { | |
120 | return marshal_no_pad(regs, args, 1); | |
121 | } | |
122 | ||
0a7de745 | 123 | int |
5ba3f43e A |
124 | munge_ww(const void *regs, void *args) |
125 | { | |
126 | return marshal_no_pad(regs, args, 2); | |
127 | } | |
128 | ||
0a7de745 | 129 | int |
5ba3f43e A |
130 | munge_www(const void *regs, void *args) |
131 | { | |
132 | return marshal_no_pad(regs, args, 3); | |
133 | } | |
134 | ||
0a7de745 | 135 | int |
5ba3f43e A |
136 | munge_wwww(const void *regs, void *args) |
137 | { | |
138 | return marshal_no_pad(regs, args, 4); | |
139 | } | |
140 | ||
0a7de745 | 141 | int |
5ba3f43e A |
142 | munge_wwwww(const void *regs, void *args) |
143 | { | |
144 | return marshal_no_pad(regs, args, 5); | |
145 | } | |
146 | ||
0a7de745 | 147 | int |
5ba3f43e A |
148 | munge_wwwwww(const void *regs, void *args) |
149 | { | |
150 | return marshal_no_pad(regs, args, 6); | |
151 | } | |
152 | ||
0a7de745 | 153 | int |
5ba3f43e A |
154 | munge_wwwwwww(const void *regs, void *args) |
155 | { | |
156 | return marshal_no_pad(regs, args, 7); | |
157 | } | |
158 | ||
0a7de745 | 159 | int |
5ba3f43e A |
160 | munge_wwwwwwww(const void *regs, void *args) |
161 | { | |
162 | return marshal_no_pad(regs, args, 8); | |
163 | } | |
164 | ||
0a7de745 | 165 | int |
5ba3f43e A |
166 | munge_wwl(const void *regs, void *args) |
167 | { | |
0a7de745 | 168 | if (REGS_TO_STYLE(regs) == kDirect) { |
cb323159 | 169 | return marshal_no_pad(regs, args, 4); |
0a7de745 | 170 | } else { |
5ba3f43e A |
171 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
172 | ||
173 | uu_args[0] = ss->r[1]; // w | |
174 | uu_args[1] = ss->r[2]; // w | |
175 | uu_args[2] = ss->r[4]; // l (longs are aligned to even registers for armv7k, so skip r3) | |
0a7de745 | 176 | uu_args[3] = ss->r[5]; // |
5ba3f43e A |
177 | return 0; |
178 | } | |
179 | } | |
180 | ||
0a7de745 | 181 | int |
5ba3f43e A |
182 | munge_wwlw(const void *regs, void *args) |
183 | { | |
0a7de745 | 184 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 185 | return marshal_no_pad(regs, args, 5); |
0a7de745 | 186 | } else { |
5ba3f43e A |
187 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
188 | ||
189 | int error = munge_wwl(regs, args); // wwl | |
190 | uu_args[4] = ss->r[6]; // w | |
191 | return error; | |
192 | } | |
193 | } | |
194 | ||
195 | int | |
196 | munge_wwlww(const void *regs, void *args) | |
197 | { | |
0a7de745 | 198 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e A |
199 | // the long-long here is aligned on an even register |
200 | // so there shouldn't be any padding | |
201 | return marshal_no_pad(regs, args, 6); | |
0a7de745 | 202 | } else { |
5ba3f43e A |
203 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
204 | ||
205 | int error = munge_wwlw(regs, args); // wwlw | |
206 | uu_args[5] = ss->r[8]; // w | |
207 | return error; | |
208 | } | |
209 | } | |
210 | ||
0a7de745 | 211 | int |
5ba3f43e A |
212 | munge_wwlll(const void *regs, void *args) |
213 | { | |
0a7de745 | 214 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 215 | return marshal_no_pad(regs, args, 8); |
0a7de745 | 216 | } else { |
5ba3f43e A |
217 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
218 | ||
219 | int error = munge_wwl(regs, args); // wwl | |
0a7de745 | 220 | if (error) { |
5ba3f43e | 221 | return error; |
0a7de745 | 222 | } |
5ba3f43e A |
223 | uu_args[4] = ss->r[6]; // l |
224 | uu_args[5] = ss->r[8]; // | |
225 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // l | |
0a7de745 | 226 | &(uu_args[6]), 2 * sizeof(uint32_t)); |
5ba3f43e A |
227 | } |
228 | } | |
229 | ||
230 | int | |
231 | munge_wwllww(const void *regs, void *args) | |
232 | { | |
233 | return munge_wwlll(regs, args); | |
234 | } | |
235 | ||
236 | int | |
237 | munge_wl(const void *regs, void *args) | |
238 | { | |
0a7de745 | 239 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 240 | memcpy(args, regs, 4 * sizeof(uint32_t)); |
0a7de745 | 241 | } else { |
5ba3f43e A |
242 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
243 | ||
244 | uu_args[0] = ss->r[1]; // w | |
245 | uu_args[2] = ss->r[2]; // l | |
246 | uu_args[3] = ss->r[3]; // | |
247 | } | |
248 | return 0; | |
249 | } | |
250 | ||
251 | int | |
252 | munge_wlw(const void *regs, void *args) | |
253 | { | |
0a7de745 A |
254 | if (REGS_TO_STYLE(regs) == kDirect) { |
255 | memcpy(args, regs, 5 * sizeof(uint32_t)); | |
256 | } else { | |
5ba3f43e A |
257 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
258 | ||
259 | uu_args[0] = ss->r[1]; // w | |
260 | uu_args[2] = ss->r[2]; // l | |
261 | uu_args[3] = ss->r[3]; // | |
262 | uu_args[4] = ss->r[4]; // w | |
263 | } | |
264 | return 0; | |
265 | } | |
266 | ||
267 | int | |
268 | munge_wlww(const void *regs, void *args) | |
269 | { | |
0a7de745 | 270 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 271 | memcpy(args, regs, 6 * sizeof(uint32_t)); |
0a7de745 | 272 | } else { |
5ba3f43e A |
273 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
274 | ||
275 | uu_args[0] = ss->r[1]; // w | |
276 | uu_args[2] = ss->r[2]; // l | |
277 | uu_args[3] = ss->r[3]; // | |
278 | uu_args[4] = ss->r[4]; // w | |
279 | uu_args[5] = ss->r[5]; // w | |
280 | } | |
281 | return 0; | |
282 | } | |
283 | ||
284 | int | |
285 | munge_wlwwwll(const void *regs, void *args) | |
286 | { | |
287 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
288 | ||
289 | if (REGS_TO_STYLE(regs) == kDirect) { | |
290 | memcpy(args, regs, 7 * sizeof(uint32_t)); // wlwww | |
291 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ll | |
0a7de745 A |
292 | uu_args + 8, 4 * sizeof(uint32_t)); |
293 | } else { | |
5ba3f43e A |
294 | uu_args[0] = ss->r[1]; // w |
295 | uu_args[2] = ss->r[2]; // l | |
0a7de745 | 296 | uu_args[3] = ss->r[3]; // |
5ba3f43e A |
297 | uu_args[4] = ss->r[4]; // w |
298 | uu_args[5] = ss->r[5]; // w | |
299 | uu_args[6] = ss->r[6]; // w | |
300 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ll | |
0a7de745 | 301 | uu_args + 8, 4 * sizeof(uint32_t)); |
5ba3f43e A |
302 | } |
303 | } | |
304 | ||
305 | int | |
306 | munge_wlwwwllw(const void *regs, void *args) | |
307 | { | |
308 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
309 | ||
310 | if (REGS_TO_STYLE(regs) == kDirect) { | |
311 | memcpy(args, regs, 7 * sizeof(uint32_t)); // wlwww | |
312 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, | |
0a7de745 A |
313 | uu_args + 8, 5 * sizeof(uint32_t)); // ll |
314 | } else { | |
5ba3f43e A |
315 | uu_args[0] = ss->r[1]; // w |
316 | uu_args[2] = ss->r[2]; // l | |
0a7de745 | 317 | uu_args[3] = ss->r[3]; // |
5ba3f43e A |
318 | uu_args[4] = ss->r[4]; // w |
319 | uu_args[5] = ss->r[5]; // w | |
320 | uu_args[6] = ss->r[6]; // w | |
321 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // llw | |
0a7de745 | 322 | uu_args + 8, 5 * sizeof(uint32_t)); |
5ba3f43e A |
323 | } |
324 | } | |
325 | ||
0a7de745 | 326 | int |
5ba3f43e A |
327 | munge_wlwwlwlw(const void *regs, void *args) |
328 | { | |
329 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
330 | ||
0a7de745 | 331 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 332 | uu_args[0] = ss->r[0]; // w |
0a7de745 | 333 | } else { |
5ba3f43e | 334 | uu_args[0] = ss->r[1]; // w |
0a7de745 | 335 | } |
5ba3f43e A |
336 | uu_args[2] = ss->r[2]; // l |
337 | uu_args[3] = ss->r[3]; // | |
338 | uu_args[4] = ss->r[4]; // w | |
339 | uu_args[5] = ss->r[5]; // w | |
340 | uu_args[6] = ss->r[6]; // l | |
341 | uu_args[7] = ss->r[8]; // | |
342 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // wlw | |
0a7de745 | 343 | uu_args + 8, 5 * sizeof(uint32_t)); |
5ba3f43e A |
344 | } |
345 | ||
0a7de745 | 346 | int |
5ba3f43e A |
347 | munge_wll(const void *regs, void *args) |
348 | { | |
0a7de745 A |
349 | if (REGS_TO_STYLE(regs) == kDirect) { |
350 | memcpy(args, regs, 6 * sizeof(uint32_t)); | |
351 | } else { | |
5ba3f43e A |
352 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
353 | ||
354 | uu_args[0] = ss->r[1]; // w | |
355 | uu_args[2] = ss->r[2]; // l | |
356 | uu_args[3] = ss->r[3]; // | |
357 | uu_args[4] = ss->r[4]; // l | |
358 | uu_args[5] = ss->r[5]; // | |
359 | } | |
360 | return 0; | |
361 | } | |
362 | ||
0a7de745 | 363 | int |
5ba3f43e A |
364 | munge_wlll(const void *regs, void *args) |
365 | { | |
366 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
367 | ||
368 | int error = munge_wll(regs, args); // wll | |
369 | uu_args[6] = ss->r[6]; // l | |
370 | uu_args[7] = ss->r[8]; // | |
371 | return error; | |
372 | } | |
373 | ||
0a7de745 | 374 | int |
5ba3f43e A |
375 | munge_wllll(const void *regs, void *args) |
376 | { | |
377 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
378 | ||
379 | munge_wlll(regs, args); // wlll | |
380 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // l | |
0a7de745 | 381 | uu_args + 8, 2 * sizeof(uint32_t)); |
5ba3f43e A |
382 | } |
383 | ||
384 | int | |
385 | munge_wllww(const void *regs, void *args) | |
386 | { | |
387 | return munge_wlll(regs, args); | |
388 | } | |
389 | ||
0a7de745 | 390 | int |
5ba3f43e A |
391 | munge_wllwwll(const void *regs, void *args) |
392 | { | |
393 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
394 | ||
395 | int error = munge_wlll(regs, args); // wllww | |
0a7de745 | 396 | if (error) { |
5ba3f43e | 397 | return error; |
0a7de745 | 398 | } |
5ba3f43e | 399 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ll |
0a7de745 | 400 | uu_args + 8, 4 * sizeof(uint32_t)); |
5ba3f43e A |
401 | } |
402 | ||
0a7de745 | 403 | int |
5ba3f43e A |
404 | munge_wwwlw(const void *regs, void *args) |
405 | { | |
0a7de745 | 406 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 407 | memcpy(args, regs, 7 * sizeof(uint32_t)); |
0a7de745 | 408 | } else { |
5ba3f43e A |
409 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
410 | ||
411 | uu_args[0] = ss->r[1]; // w | |
412 | uu_args[1] = ss->r[2]; // w | |
413 | uu_args[2] = ss->r[3]; // w | |
414 | uu_args[4] = ss->r[4]; // l | |
415 | uu_args[5] = ss->r[5]; // | |
416 | uu_args[6] = ss->r[6]; // w | |
417 | } | |
418 | return 0; | |
419 | } | |
420 | ||
421 | int | |
422 | munge_wwwlww(const void *regs, void *args) | |
423 | { | |
0a7de745 | 424 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 425 | return munge_wlll(regs, args); |
0a7de745 | 426 | } else { |
5ba3f43e A |
427 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
428 | ||
429 | uu_args[0] = ss->r[1]; // w | |
430 | uu_args[1] = ss->r[2]; // w | |
431 | uu_args[2] = ss->r[3]; // w | |
432 | uu_args[4] = ss->r[4]; // l | |
433 | uu_args[5] = ss->r[5]; // | |
434 | uu_args[6] = ss->r[6]; // w | |
435 | uu_args[7] = ss->r[8]; // w | |
436 | return 0; | |
437 | } | |
438 | } | |
0a7de745 A |
439 | |
440 | int | |
5ba3f43e A |
441 | munge_wwwl(const void *regs, void *args) |
442 | { | |
0a7de745 | 443 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 444 | return munge_wll(regs, args); |
0a7de745 | 445 | } else { |
5ba3f43e A |
446 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
447 | ||
448 | uu_args[0] = ss->r[1]; // w | |
449 | uu_args[1] = ss->r[2]; // w | |
450 | uu_args[2] = ss->r[3]; // w | |
451 | uu_args[4] = ss->r[4]; // l | |
452 | uu_args[5] = ss->r[5]; // | |
453 | return 0; | |
454 | } | |
455 | } | |
456 | ||
0a7de745 | 457 | int |
5ba3f43e A |
458 | munge_wwwwl(const void *regs, void *args) |
459 | { | |
0a7de745 | 460 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 461 | return marshal_no_pad(regs, args, 6); |
0a7de745 | 462 | } else { |
5ba3f43e A |
463 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
464 | ||
465 | uu_args[0] = ss->r[1]; // w | |
466 | uu_args[1] = ss->r[2]; // w | |
467 | uu_args[2] = ss->r[3]; // w | |
468 | uu_args[3] = ss->r[4]; // w | |
469 | uu_args[4] = ss->r[6]; // l | |
470 | uu_args[5] = ss->r[8]; // | |
471 | return 0; | |
472 | } | |
473 | } | |
474 | ||
475 | int | |
476 | munge_wwwwlw(const void *regs, void *args) | |
477 | { | |
0a7de745 | 478 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 479 | return marshal_no_pad(regs, args, 7); |
0a7de745 | 480 | } else { |
5ba3f43e A |
481 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
482 | ||
483 | int error = munge_wwwwl(regs, args); // wwwwl | |
0a7de745 | 484 | if (error) { |
5ba3f43e | 485 | return error; |
0a7de745 | 486 | } |
5ba3f43e | 487 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // w |
0a7de745 | 488 | uu_args + 6, sizeof(uint32_t)); |
5ba3f43e A |
489 | } |
490 | } | |
491 | ||
0a7de745 | 492 | int |
5ba3f43e A |
493 | munge_wwwwwl(const void *regs, void *args) |
494 | { | |
0a7de745 | 495 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 496 | return munge_wlll(regs, args); |
0a7de745 | 497 | } else { |
5ba3f43e A |
498 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
499 | ||
500 | uu_args[0] = ss->r[1]; // w | |
501 | uu_args[1] = ss->r[2]; // w | |
502 | uu_args[2] = ss->r[3]; // w | |
503 | uu_args[3] = ss->r[4]; // w | |
504 | uu_args[4] = ss->r[5]; // w | |
505 | uu_args[6] = ss->r[6]; // l | |
506 | uu_args[7] = ss->r[8]; // | |
507 | return 0; | |
508 | } | |
509 | } | |
510 | ||
0a7de745 | 511 | int |
5ba3f43e A |
512 | munge_wwwwwlww(const void *regs, void *args) |
513 | { | |
0a7de745 | 514 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 515 | return munge_wllll(regs, args); |
0a7de745 | 516 | } else { |
5ba3f43e A |
517 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
518 | ||
519 | int error = munge_wwwwwl(regs, args); // wwwwwl | |
0a7de745 | 520 | if (error) { |
5ba3f43e | 521 | return error; |
0a7de745 | 522 | } |
5ba3f43e | 523 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ww |
0a7de745 | 524 | uu_args + 8, 2 * sizeof(uint32_t)); |
5ba3f43e A |
525 | } |
526 | } | |
527 | ||
528 | int | |
529 | munge_wwwwwllw(const void *regs, void *args) | |
530 | { | |
531 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
532 | ||
533 | int error = munge_wwwwwl(regs, args); // wwwwwl | |
0a7de745 | 534 | if (error) { |
5ba3f43e | 535 | return error; |
0a7de745 | 536 | } |
5ba3f43e | 537 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // lw |
0a7de745 | 538 | uu_args + 8, 3 * sizeof(uint32_t)); |
5ba3f43e A |
539 | } |
540 | ||
541 | int | |
542 | munge_wwwwwlll(const void *regs, void *args) | |
543 | { | |
544 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
545 | int error; | |
546 | ||
547 | if (REGS_TO_STYLE(regs) == kDirect) { | |
548 | error = munge_wlll(regs, args); // wlll | |
0a7de745 | 549 | if (error) { |
5ba3f43e | 550 | return error; |
0a7de745 | 551 | } |
5ba3f43e | 552 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ll |
0a7de745 A |
553 | uu_args + 8, 4 * sizeof(uint32_t)); |
554 | } else { | |
5ba3f43e | 555 | error = munge_wwwwwl(regs, args); // wwwwwl |
0a7de745 | 556 | if (error) { |
5ba3f43e | 557 | return error; |
0a7de745 | 558 | } |
5ba3f43e | 559 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ll |
0a7de745 | 560 | uu_args + 8, 4 * sizeof(uint32_t)); |
5ba3f43e A |
561 | } |
562 | } | |
563 | ||
564 | int | |
565 | munge_wwwwwwl(const void *regs, void *args) | |
566 | { | |
567 | munge_wwlll(regs, args); | |
568 | ||
0a7de745 | 569 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 570 | return marshal_no_pad(regs, args, 8); |
0a7de745 | 571 | } else { |
5ba3f43e A |
572 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
573 | ||
574 | memcpy(args, &(ss->r[1]), 6 * sizeof(uint32_t)); // wwwwww | |
575 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // l | |
0a7de745 | 576 | &(uu_args[6]), 2 * sizeof(uint32_t)); |
5ba3f43e A |
577 | } |
578 | } | |
579 | ||
0a7de745 | 580 | int |
5ba3f43e A |
581 | munge_wwwwwwlw(const void *regs, void *args) |
582 | { | |
0a7de745 | 583 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 584 | return marshal_no_pad(regs, args, 9); |
0a7de745 | 585 | } else { |
5ba3f43e A |
586 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
587 | ||
588 | memcpy(args, &(ss->r[1]), 6 * sizeof(uint32_t)); // wwwwww | |
589 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // lw | |
0a7de745 | 590 | &(uu_args[6]), 3 * sizeof(uint32_t)); |
5ba3f43e A |
591 | } |
592 | } | |
0a7de745 A |
593 | |
594 | int | |
5ba3f43e A |
595 | munge_wwwwwwll(const void *regs, void *args) |
596 | { | |
0a7de745 | 597 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 598 | return marshal_no_pad(regs, args, 10); |
0a7de745 | 599 | } else { |
5ba3f43e A |
600 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
601 | ||
602 | memcpy(args, &(ss->r[1]), 6 * sizeof(uint32_t)); // wwwwww | |
603 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // ll | |
0a7de745 | 604 | &(uu_args[6]), 4 * sizeof(uint32_t)); |
5ba3f43e A |
605 | } |
606 | } | |
607 | ||
0a7de745 | 608 | int |
5ba3f43e A |
609 | munge_wsw(const void *regs, void *args) |
610 | { | |
611 | return munge_wlw(regs, args); | |
612 | } | |
613 | ||
0a7de745 | 614 | int |
5ba3f43e A |
615 | munge_wws(const void *regs, void *args) |
616 | { | |
617 | return munge_wwl(regs, args); | |
618 | } | |
619 | ||
620 | int | |
621 | munge_wwws(const void *regs, void *args) | |
622 | { | |
623 | return munge_wwwl(regs, args); | |
624 | } | |
625 | ||
626 | int | |
627 | munge_wwwsw(const void *regs, void *args) | |
628 | { | |
629 | return munge_wwwlw(regs, args); | |
630 | } | |
631 | ||
0a7de745 | 632 | int |
5ba3f43e A |
633 | munge_llllll(const void *regs, void *args) |
634 | { | |
0a7de745 | 635 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 636 | return marshal_no_pad(regs, args, 12); |
0a7de745 | 637 | } else { |
5ba3f43e A |
638 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
639 | ||
640 | uu_args[0] = ss->r[2]; // l | |
641 | uu_args[1] = ss->r[3]; // | |
642 | uu_args[2] = ss->r[4]; // l | |
643 | uu_args[3] = ss->r[5]; // | |
644 | uu_args[4] = ss->r[6]; // l | |
645 | uu_args[5] = ss->r[8]; // | |
646 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // lll | |
0a7de745 | 647 | uu_args + 6, 6 * sizeof(uint32_t)); |
5ba3f43e A |
648 | } |
649 | } | |
650 | ||
0a7de745 | 651 | int |
5ba3f43e A |
652 | munge_ll(const void *regs, void *args) |
653 | { | |
0a7de745 | 654 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 655 | return marshal_no_pad(regs, args, 4); |
0a7de745 | 656 | } else { |
5ba3f43e | 657 | memcpy(args, (const uint32_t*)regs + 2, 4 * sizeof(uint32_t)); |
0a7de745 | 658 | } |
5ba3f43e A |
659 | return 0; |
660 | } | |
661 | ||
0a7de745 | 662 | int |
5ba3f43e A |
663 | munge_l(const void *regs, void *args) |
664 | { | |
0a7de745 | 665 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 666 | return marshal_no_pad(regs, args, 2); |
0a7de745 | 667 | } else { |
5ba3f43e | 668 | memcpy(args, (const uint32_t*)regs + 2, 2 * sizeof(uint32_t)); |
0a7de745 | 669 | } |
5ba3f43e A |
670 | return 0; |
671 | } | |
672 | ||
0a7de745 | 673 | int |
5ba3f43e A |
674 | munge_lw(const void *regs, void *args) |
675 | { | |
0a7de745 | 676 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 677 | return marshal_no_pad(regs, args, 3); |
0a7de745 | 678 | } else { |
5ba3f43e | 679 | memcpy(args, (const uint32_t*)regs + 2, 3 * sizeof(uint32_t)); |
0a7de745 | 680 | } |
5ba3f43e A |
681 | return 0; |
682 | } | |
683 | ||
684 | int | |
685 | munge_lwww(const void *regs, void *args) | |
686 | { | |
0a7de745 | 687 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 688 | return marshal_no_pad(regs, args, 5); |
0a7de745 | 689 | } else { |
5ba3f43e | 690 | memcpy(args, (const uint32_t*)regs + 2, 5 * sizeof(uint32_t)); |
0a7de745 | 691 | } |
5ba3f43e A |
692 | return 0; |
693 | } | |
694 | ||
0a7de745 | 695 | int |
5ba3f43e A |
696 | munge_lwwwwwww(const void *regs, void *args) |
697 | { | |
0a7de745 | 698 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 699 | return marshal_no_pad(regs, args, 9); |
0a7de745 | 700 | } else { |
5ba3f43e A |
701 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
702 | ||
703 | uu_args[0] = ss->r[2]; // l | |
0a7de745 | 704 | uu_args[1] = ss->r[3]; // |
5ba3f43e A |
705 | uu_args[2] = ss->r[4]; // w |
706 | uu_args[3] = ss->r[5]; // w | |
707 | uu_args[4] = ss->r[6]; // w | |
708 | uu_args[5] = ss->r[8]; // w | |
709 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // www | |
0a7de745 | 710 | uu_args + 6, 3 * sizeof(uint32_t)); |
5ba3f43e A |
711 | } |
712 | } | |
713 | ||
714 | int | |
715 | munge_wwlwww(const void *regs, void *args) | |
716 | { | |
0a7de745 | 717 | if (REGS_TO_STYLE(regs) == kDirect) { |
5ba3f43e | 718 | return marshal_no_pad(regs, args, 7); |
0a7de745 | 719 | } else { |
5ba3f43e A |
720 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
721 | ||
722 | uu_args[0] = ss->r[1]; // w | |
723 | uu_args[1] = ss->r[2]; // w | |
724 | uu_args[2] = ss->r[4]; // l | |
725 | uu_args[3] = ss->r[5]; // | |
726 | uu_args[4] = ss->r[6]; // w | |
727 | uu_args[5] = ss->r[8]; // w | |
728 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // w | |
0a7de745 | 729 | uu_args + 6, sizeof(uint32_t)); |
5ba3f43e | 730 | } |
5ba3f43e A |
731 | } |
732 | ||
733 | int | |
734 | munge_wlwwwl(const void *regs, void *args) | |
735 | { | |
736 | DECLARE_AND_CAST(regs, args, ss, uu_args); | |
737 | ||
738 | if (REGS_TO_STYLE(regs) == kDirect) { | |
0a7de745 | 739 | memcpy(args, regs, 7 * sizeof(uint32_t)); // wlwww |
5ba3f43e | 740 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // l |
0a7de745 | 741 | uu_args + 8, 2 * sizeof(uint32_t)); |
5ba3f43e A |
742 | } else { |
743 | uu_args[0] = ss->r[1]; // w | |
744 | uu_args[2] = ss->r[2]; // l | |
745 | uu_args[3] = ss->r[3]; // | |
746 | uu_args[4] = ss->r[4]; // w | |
747 | uu_args[5] = ss->r[5]; // w | |
748 | uu_args[6] = ss->r[6]; // w | |
749 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // l | |
0a7de745 | 750 | uu_args + 8, 2 * sizeof(uint32_t)); |
5ba3f43e A |
751 | } |
752 | } | |
753 | ||
754 | int | |
755 | munge_wwlwwwl(const void *regs, void *args) | |
756 | { | |
0a7de745 | 757 | DECLARE_AND_CAST(regs, args, ss, uu_args); |
5ba3f43e A |
758 | |
759 | if (REGS_TO_STYLE(regs) == kDirect) { | |
0a7de745 | 760 | memcpy(args, regs, 7 * sizeof(uint32_t)); // wwlwww |
5ba3f43e | 761 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // l |
0a7de745 | 762 | uu_args + 8, 2 * sizeof(uint32_t)); |
5ba3f43e A |
763 | } else { |
764 | uu_args[0] = ss->r[1]; // w | |
765 | uu_args[1] = ss->r[2]; // w | |
766 | uu_args[2] = ss->r[4]; // l | |
767 | uu_args[3] = ss->r[5]; // | |
768 | uu_args[4] = ss->r[6]; // w | |
769 | uu_args[5] = ss->r[8]; // w | |
770 | return copyin(ss->sp + ARG_SP_BYTE_OFFSET, // wl | |
0a7de745 | 771 | uu_args + 6, 4 * sizeof(uint32_t)); |
5ba3f43e A |
772 | } |
773 | } | |
774 | ||
775 | #endif // __arm__ && (__BIGGEST_ALIGNMENT__ > 4) |