1/*
2 * Coyright (c) 2005-2013 Apple 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#ifndef __MUNGE_H__
30#define __MUNGE_H__
31
32/*
33 * Syscall argument mungers.
34 *
35 * The data to be munged has been explicitly copied in to the argument
36 * area, and will be munged in place in the uu_arg[] array. These
37 * mungers are for 32-bit app's syscalls, since 64-bit args are copied
38 * from the save area to the uu_args in the order the
39 * syscall ABI calls for.
40 *
41 * The issue is that the incoming args are 32-bit, but we must expand
42 * them in place into 64-bit args, as if they were from a 64-bit process.
43 *
44 * There are several functions in this file with the following prototype
45 *
46 * void munge_XXXX(void *uu_args);
47 *
48 * The name of the function encodes the number and type of the parameters,
49 * as follows:
50 *
51 * w = a 32-bit value such as an int or a 32-bit ptr, that does not
52 * require sign extension. These are handled by zeroing a word
53 * of output, and copying a word from input to output.
54 *
55 * s = a 32-bit value such as a long, which must be sign-extended to
56 * a 64-bit long-long in the uu_args. These are handled by
57 * loading a word of input and sign extending it to a double,
58 * and storing two words of output.
59 *
60 * l = a 64-bit long-long. These are handled by copying two words
61 * of input to the output.
62 *
63 * For example, "munge_wls" takes a word, a long-long, and a word. This
64 * takes four words in the uu_arg[] area: the first word is in one, the
65 * long-long takes two, and the final word is in the fourth. We store six
66 * words: the low word is left in place, followed by a 0, followed by the
67 * two words of the long-long, followed by the low word and the sign extended
68 * high word of the preceeding low word.
69 *
70 * Because this is an in-place modification, we actually start at the end
71 * of uu_arg[] and work our way back to the beginning of the array.
72 */
73
74#if __arm__ && (__BIGGEST_ALIGNMENT__ > 4)
75int munge_w(const void *regs, void *args);
76int munge_ww(const void *regs, void *args);
77int munge_www(const void *regs, void *args);
78int munge_wwww(const void *regs, void *args);
79int munge_wwwww(const void *regs, void *args);
80int munge_wwwwww(const void *regs, void *args);
81int munge_wwwwwww(const void *regs, void *args);
82int munge_wwwwwwww(const void *regs, void *args);
83int munge_wl(const void *regs, void *args);
84int munge_wwl(const void *regs, void *args);
85int munge_wwlw(const void *regs, void *args);
86int munge_wwlll(const void *regs, void *args);
87int munge_wwlllll(const void *regs, void *args);
88int munge_wwllww(const void *regs, void *args);
89int munge_wlw(const void *regs, void *args);
90int munge_wlww(const void *regs, void *args);
91int munge_wlwwwl(const void *regs, void *args);
92int munge_wlwwwll(const void *regs, void *args);
93int munge_wlwwwllw(const void *regs, void *args);
94int munge_wlwwlwlw(const void *regs, void *args);
95int munge_wll(const void *regs, void *args);
96int munge_wllww(const void *regs, void *args);
97int munge_wlll(const void *regs, void *args);
98int munge_wlllww(const void *regs, void *args);
99int munge_wllll(const void *regs, void *args);
100int munge_wllwwll(const void *regs, void *args);
101int munge_wwwlw(const void *regs, void *args);
102int munge_wwwlww(const void *regs, void *args);
103int munge_wwwlwww(const void *regs, void *args);
104int munge_wwwl(const void *regs, void *args);
105int munge_wwwwlw(const void *regs, void *args);
106int munge_wwwwllww(const void *regs, void *args);
107int munge_wwwwl(const void *regs, void *args);
108int munge_wwwwwl(const void *regs, void *args);
109int munge_wwwwwlww(const void *regs, void *args);
110int munge_wwwwwllw(const void *regs, void *args);
111int munge_wwwwwlll(const void *regs, void *args);
112int munge_wwwwwwl(const void *regs, void *args);
113int munge_wwwwwwlw(const void *regs, void *args);
114int munge_wwwwwwll(const void *regs, void *args);
115int munge_wsw(const void *regs, void *args);
116int munge_wws(const void *regs, void *args);
117int munge_wwws(const void *regs, void *args);
118int munge_wwwsw(const void *regs, void *args);
119int munge_llllllll(const void *regs, void *args);
120int munge_llllll(const void *regs, void *args);
121int munge_l(const void *regs, void *args);
122int munge_ll(const void *regs, void *args);
123int munge_lll(const void *regs, void *args);
124int munge_lw(const void *regs, void *args);
125int munge_lwww(const void *regs, void *args);
126int munge_lwwwwwww(const void *regs, void *args);
127int munge_wwlww(const void *regs, void *args);
128int munge_wwlwww(const void *regs, void *args);
129int munge_wwlwwwl(const void *regs, void *args);
130#else
131void munge_w(void *args);
132void munge_ww(void *args);
133void munge_www(void *args);
134void munge_wwww(void *args);
135void munge_wwwww(void *args);
136void munge_wwwwww(void *args);
137void munge_wwwwwww(void *args);
138void munge_wwwwwwww(void *args);
139void munge_wl(void *args);
140void munge_wwl(void *args);
141void munge_wwlw(void *args);
142void munge_wwlll(void *args);
143void munge_wwlllll(void *args);
144void munge_wwllww(void *args);
145void munge_wlw(void *args);
146void munge_wlww(void *args);
147void munge_wlwwwl(void *args);
148void munge_wlwwwll(void *args);
149void munge_wlwwwllw(void *args);
150void munge_wlwwlwlw(void *args);
151void munge_wll(void *args);
152void munge_wllww(void *args);
153void munge_wlll(void *args);
154void munge_wlllww(void *args);
155void munge_wllll(void *args);
156void munge_wllwwll(void *args);
157void munge_wwwlw(void *args);
158void munge_wwwlww(void *args);
159void munge_wwwlwww(void *args);
160void munge_wwwl(void *args);
161void munge_wwwwlw(void *args);
162void munge_wwwwllww(void *args);
163void munge_wwwwl(void *args);
164void munge_wwwwwl(void *args);
165void munge_wwwwwlww(void *args);
166void munge_wwwwwllw(void *args);
167void munge_wwwwwlll(void *args);
168void munge_wwwwwwl(void *args);
169void munge_wwwwwwlw(void *args);
170void munge_wwwwwwll(void *args);
171void munge_wsw(void *args);
172void munge_wws(void *args);
173void munge_wwws(void *args);
174void munge_wwwsw(void *args);
175void munge_llllllll(void *args);
176void munge_llllll(void *args);
177void munge_llll(void *args);
178void munge_l(void *args);
179void munge_ll(void *args);
180void munge_lll(void *args);
181void munge_lw(void *args);
182void munge_lwww(void *args);
183void munge_lwwwwwww(void *args);
184void munge_wwlww(void *args);
185void munge_wwlwww(void *args);
186void munge_wwlwwwl(void *args);
187#endif /* __arm__ && (__BIGGEST_ALIGNMENT__ > 4) */
188#endif /* __MUNGE_H__ */
189