xref: /xnu-11215.1.10/bsd/sys/munge.h (revision 8d741a5de7ff4191bf97d57b9f54c2f6d4a15585) !
1*8d741a5dSApple OSS Distributions /*
2*8d741a5dSApple OSS Distributions  * Coyright (c) 2005-2013 Apple Inc. All rights reserved.
3*8d741a5dSApple OSS Distributions  *
4*8d741a5dSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*8d741a5dSApple OSS Distributions  *
6*8d741a5dSApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*8d741a5dSApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*8d741a5dSApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*8d741a5dSApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*8d741a5dSApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*8d741a5dSApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*8d741a5dSApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*8d741a5dSApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*8d741a5dSApple OSS Distributions  *
15*8d741a5dSApple OSS Distributions  * Please obtain a copy of the License at
16*8d741a5dSApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*8d741a5dSApple OSS Distributions  *
18*8d741a5dSApple OSS Distributions  * The Original Code and all software distributed under the License are
19*8d741a5dSApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*8d741a5dSApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*8d741a5dSApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*8d741a5dSApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*8d741a5dSApple OSS Distributions  * Please see the License for the specific language governing rights and
24*8d741a5dSApple OSS Distributions  * limitations under the License.
25*8d741a5dSApple OSS Distributions  *
26*8d741a5dSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*8d741a5dSApple OSS Distributions  */
28*8d741a5dSApple OSS Distributions 
29*8d741a5dSApple OSS Distributions #ifndef __MUNGE_H__
30*8d741a5dSApple OSS Distributions #define __MUNGE_H__
31*8d741a5dSApple OSS Distributions 
32*8d741a5dSApple OSS Distributions /*
33*8d741a5dSApple OSS Distributions  * Syscall argument mungers.
34*8d741a5dSApple OSS Distributions  *
35*8d741a5dSApple OSS Distributions  * The data to be munged has been explicitly copied in to the argument
36*8d741a5dSApple OSS Distributions  * area, and will be munged in place in the uu_arg[] array. These
37*8d741a5dSApple OSS Distributions  * mungers are for 32-bit app's syscalls, since 64-bit args are copied
38*8d741a5dSApple OSS Distributions  * from the save area to the uu_args in the order the
39*8d741a5dSApple OSS Distributions  * syscall ABI calls for.
40*8d741a5dSApple OSS Distributions  *
41*8d741a5dSApple OSS Distributions  * The issue is that the incoming args are 32-bit, but we must expand
42*8d741a5dSApple OSS Distributions  * them in place into 64-bit args, as if they were from a 64-bit process.
43*8d741a5dSApple OSS Distributions  *
44*8d741a5dSApple OSS Distributions  * There are several functions in this file with the following prototype
45*8d741a5dSApple OSS Distributions  *
46*8d741a5dSApple OSS Distributions  *	void	munge_XXXX(void *uu_args);
47*8d741a5dSApple OSS Distributions  *
48*8d741a5dSApple OSS Distributions  * The name of the function encodes the number and type of the parameters,
49*8d741a5dSApple OSS Distributions  * as follows:
50*8d741a5dSApple OSS Distributions  *
51*8d741a5dSApple OSS Distributions  *	w = a 32-bit value such as an int or a 32-bit ptr, that does not
52*8d741a5dSApple OSS Distributions  *	    require sign extension.  These are handled by zeroing a word
53*8d741a5dSApple OSS Distributions  *          of output, and copying a word from input to output.
54*8d741a5dSApple OSS Distributions  *
55*8d741a5dSApple OSS Distributions  *	s = a 32-bit value such as a long, which must be sign-extended to
56*8d741a5dSApple OSS Distributions  *	    a 64-bit long-long in the uu_args.  These are handled by
57*8d741a5dSApple OSS Distributions  *	    loading a word of input and sign extending it to a double,
58*8d741a5dSApple OSS Distributions  *          and storing two words of output.
59*8d741a5dSApple OSS Distributions  *
60*8d741a5dSApple OSS Distributions  *	l = a 64-bit long-long.  These are handled by copying two words
61*8d741a5dSApple OSS Distributions  *          of input to the output.
62*8d741a5dSApple OSS Distributions  *
63*8d741a5dSApple OSS Distributions  * For example, "munge_wls" takes a word, a long-long, and a word.  This
64*8d741a5dSApple OSS Distributions  * takes four words in the uu_arg[] area: the first word is in one, the
65*8d741a5dSApple OSS Distributions  * long-long takes two, and the final word is in the fourth.  We store six
66*8d741a5dSApple OSS Distributions  * words: the low word is left in place, followed by a 0, followed by the
67*8d741a5dSApple OSS Distributions  * two words of the long-long, followed by the low word and the sign extended
68*8d741a5dSApple OSS Distributions  * high word of the preceeding low word.
69*8d741a5dSApple OSS Distributions  *
70*8d741a5dSApple OSS Distributions  * Because this is an in-place modification, we actually start at the end
71*8d741a5dSApple OSS Distributions  * of uu_arg[] and work our way back to the beginning of the array.
72*8d741a5dSApple OSS Distributions  */
73*8d741a5dSApple OSS Distributions 
74*8d741a5dSApple OSS Distributions #if __arm__ && (__BIGGEST_ALIGNMENT__ > 4)
75*8d741a5dSApple OSS Distributions int munge_w(const void *regs, void *args);
76*8d741a5dSApple OSS Distributions int munge_ww(const void *regs, void *args);
77*8d741a5dSApple OSS Distributions int munge_www(const void *regs, void *args);
78*8d741a5dSApple OSS Distributions int munge_wwww(const void *regs, void *args);
79*8d741a5dSApple OSS Distributions int munge_wwwww(const void *regs, void *args);
80*8d741a5dSApple OSS Distributions int munge_wwwwww(const void *regs, void *args);
81*8d741a5dSApple OSS Distributions int munge_wwwwwww(const void *regs, void *args);
82*8d741a5dSApple OSS Distributions int munge_wwwwwwww(const void *regs, void *args);
83*8d741a5dSApple OSS Distributions int munge_wl(const void *regs, void *args);
84*8d741a5dSApple OSS Distributions int munge_wwl(const void *regs, void *args);
85*8d741a5dSApple OSS Distributions int munge_wwlw(const void *regs, void *args);
86*8d741a5dSApple OSS Distributions int munge_wwlll(const void *regs, void *args);
87*8d741a5dSApple OSS Distributions int munge_wwlllll(const void *regs, void *args);
88*8d741a5dSApple OSS Distributions int munge_wwllww(const void *regs, void *args);
89*8d741a5dSApple OSS Distributions int munge_wlw(const void *regs, void *args);
90*8d741a5dSApple OSS Distributions int munge_wlww(const void *regs, void *args);
91*8d741a5dSApple OSS Distributions int munge_wlwwwl(const void *regs, void *args);
92*8d741a5dSApple OSS Distributions int munge_wlwwwll(const void *regs, void *args);
93*8d741a5dSApple OSS Distributions int munge_wlwwwllw(const void *regs, void *args);
94*8d741a5dSApple OSS Distributions int munge_wlwwlwlw(const void *regs, void *args);
95*8d741a5dSApple OSS Distributions int munge_wll(const void *regs, void *args);
96*8d741a5dSApple OSS Distributions int munge_wllww(const void *regs, void *args);
97*8d741a5dSApple OSS Distributions int munge_wlll(const void *regs, void *args);
98*8d741a5dSApple OSS Distributions int munge_wlllww(const void *regs, void *args);
99*8d741a5dSApple OSS Distributions int munge_wllll(const void *regs, void *args);
100*8d741a5dSApple OSS Distributions int munge_wllwwll(const void *regs, void *args);
101*8d741a5dSApple OSS Distributions int munge_wwwlw(const void *regs, void *args);
102*8d741a5dSApple OSS Distributions int munge_wwwlww(const void *regs, void *args);
103*8d741a5dSApple OSS Distributions int munge_wwwlwww(const void *regs, void *args);
104*8d741a5dSApple OSS Distributions int munge_wwwl(const void *regs, void *args);
105*8d741a5dSApple OSS Distributions int munge_wwwwlw(const void *regs, void *args);
106*8d741a5dSApple OSS Distributions int munge_wwwwllww(const void *regs, void *args);
107*8d741a5dSApple OSS Distributions int munge_wwwwl(const void *regs, void *args);
108*8d741a5dSApple OSS Distributions int munge_wwwwwl(const void *regs, void *args);
109*8d741a5dSApple OSS Distributions int munge_wwwwwlww(const void *regs, void *args);
110*8d741a5dSApple OSS Distributions int munge_wwwwwllw(const void *regs, void *args);
111*8d741a5dSApple OSS Distributions int munge_wwwwwlll(const void *regs, void *args);
112*8d741a5dSApple OSS Distributions int munge_wwwwwwl(const void *regs, void *args);
113*8d741a5dSApple OSS Distributions int munge_wwwwwwlw(const void *regs, void *args);
114*8d741a5dSApple OSS Distributions int munge_wwwwwwll(const void *regs, void *args);
115*8d741a5dSApple OSS Distributions int munge_wsw(const void *regs, void *args);
116*8d741a5dSApple OSS Distributions int munge_wws(const void *regs, void *args);
117*8d741a5dSApple OSS Distributions int munge_wwws(const void *regs, void *args);
118*8d741a5dSApple OSS Distributions int munge_wwwsw(const void *regs, void *args);
119*8d741a5dSApple OSS Distributions int munge_llllllll(const void *regs, void *args);
120*8d741a5dSApple OSS Distributions int munge_llllll(const void *regs, void *args);
121*8d741a5dSApple OSS Distributions int munge_l(const void *regs, void *args);
122*8d741a5dSApple OSS Distributions int munge_ll(const void *regs, void *args);
123*8d741a5dSApple OSS Distributions int munge_lll(const void *regs, void *args);
124*8d741a5dSApple OSS Distributions int munge_lw(const void *regs, void *args);
125*8d741a5dSApple OSS Distributions int munge_lww(const void *regs, void *args);
126*8d741a5dSApple OSS Distributions int munge_lwww(const void *regs, void *args);
127*8d741a5dSApple OSS Distributions int munge_lwwwwwww(const void *regs, void *args);
128*8d741a5dSApple OSS Distributions int munge_wwlww(const void *regs, void *args);
129*8d741a5dSApple OSS Distributions int munge_wwlwww(const void *regs, void *args);
130*8d741a5dSApple OSS Distributions int munge_wwlwwwl(const void *regs, void *args);
131*8d741a5dSApple OSS Distributions #else
132*8d741a5dSApple OSS Distributions void munge_w(void *args);
133*8d741a5dSApple OSS Distributions void munge_ww(void *args);
134*8d741a5dSApple OSS Distributions void munge_www(void *args);
135*8d741a5dSApple OSS Distributions void munge_wwww(void *args);
136*8d741a5dSApple OSS Distributions void munge_wwwww(void *args);
137*8d741a5dSApple OSS Distributions void munge_wwwwww(void *args);
138*8d741a5dSApple OSS Distributions void munge_wwwwwww(void *args);
139*8d741a5dSApple OSS Distributions void munge_wwwwwwww(void *args);
140*8d741a5dSApple OSS Distributions void munge_wl(void *args);
141*8d741a5dSApple OSS Distributions void munge_wwl(void *args);
142*8d741a5dSApple OSS Distributions void munge_wwlw(void *args);
143*8d741a5dSApple OSS Distributions void munge_wwlll(void *args);
144*8d741a5dSApple OSS Distributions void munge_wwlllll(void *args);
145*8d741a5dSApple OSS Distributions void munge_wwllww(void *args);
146*8d741a5dSApple OSS Distributions void munge_wlw(void *args);
147*8d741a5dSApple OSS Distributions void munge_wlww(void *args);
148*8d741a5dSApple OSS Distributions void munge_wlwwwl(void *args);
149*8d741a5dSApple OSS Distributions void munge_wlwwwll(void *args);
150*8d741a5dSApple OSS Distributions void munge_wlwwwllw(void *args);
151*8d741a5dSApple OSS Distributions void munge_wlwwlwlw(void *args);
152*8d741a5dSApple OSS Distributions void munge_wll(void *args);
153*8d741a5dSApple OSS Distributions void munge_wllww(void *args);
154*8d741a5dSApple OSS Distributions void munge_wlll(void *args);
155*8d741a5dSApple OSS Distributions void munge_wlllww(void *args);
156*8d741a5dSApple OSS Distributions void munge_wllll(void *args);
157*8d741a5dSApple OSS Distributions void munge_wllwwll(void *args);
158*8d741a5dSApple OSS Distributions void munge_wwwlw(void *args);
159*8d741a5dSApple OSS Distributions void munge_wwwlww(void *args);
160*8d741a5dSApple OSS Distributions void munge_wwwlwww(void *args);
161*8d741a5dSApple OSS Distributions void munge_wwwl(void *args);
162*8d741a5dSApple OSS Distributions void munge_wwwwlw(void *args);
163*8d741a5dSApple OSS Distributions void munge_wwwwllww(void *args);
164*8d741a5dSApple OSS Distributions void munge_wwwwl(void *args);
165*8d741a5dSApple OSS Distributions void munge_wwwwwl(void *args);
166*8d741a5dSApple OSS Distributions void munge_wwwwwlww(void *args);
167*8d741a5dSApple OSS Distributions void munge_wwwwwllw(void *args);
168*8d741a5dSApple OSS Distributions void munge_wwwwwlll(void *args);
169*8d741a5dSApple OSS Distributions void munge_wwwwwwl(void *args);
170*8d741a5dSApple OSS Distributions void munge_wwwwwwlw(void *args);
171*8d741a5dSApple OSS Distributions void munge_wwwwwwll(void *args);
172*8d741a5dSApple OSS Distributions void munge_wsw(void *args);
173*8d741a5dSApple OSS Distributions void munge_wws(void *args);
174*8d741a5dSApple OSS Distributions void munge_wwws(void *args);
175*8d741a5dSApple OSS Distributions void munge_wwwsw(void *args);
176*8d741a5dSApple OSS Distributions void munge_llllllll(void *args);
177*8d741a5dSApple OSS Distributions void munge_llllll(void *args);
178*8d741a5dSApple OSS Distributions void munge_llll(void *args);
179*8d741a5dSApple OSS Distributions void munge_l(void *args);
180*8d741a5dSApple OSS Distributions void munge_ll(void *args);
181*8d741a5dSApple OSS Distributions void munge_lll(void *args);
182*8d741a5dSApple OSS Distributions void munge_lw(void *args);
183*8d741a5dSApple OSS Distributions void munge_lww(void *args);
184*8d741a5dSApple OSS Distributions void munge_lwww(void *args);
185*8d741a5dSApple OSS Distributions void munge_lwwwwwww(void *args);
186*8d741a5dSApple OSS Distributions void munge_wwlww(void *args);
187*8d741a5dSApple OSS Distributions void munge_wwlwww(void *args);
188*8d741a5dSApple OSS Distributions void munge_wwlwwwl(void *args);
189*8d741a5dSApple OSS Distributions #endif /* __arm__ && (__BIGGEST_ALIGNMENT__ > 4) */
190*8d741a5dSApple OSS Distributions #endif /* __MUNGE_H__ */
191