2 * Coyright (c) 2005-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 * Syscall argument mungers.
32 * The data to be munged has been explicitly copied in to the argument area,
33 * and will be munged in place in the uu_arg[] array. Because of this, the
34 * functions all take the same arguments as their PPC equivalents, but the
35 * first argument is ignored. These mungers are for 32-bit app's syscalls,
36 * since 64-bit args are stored into the save area (which overlays the
37 * uu_args) in the order the syscall ABI calls for.
39 * The issue is that the incoming args are 32-bit, but we must expand
40 * them in place into 64-bit args, as if they were from a 64-bit process.
42 * There are several functions in this file. Each takes two parameters:
44 * void munge_XXXX( const void *regs, void *uu_args);
46 * The name of the function encodes the number and type of the parameters,
49 * w = a 32-bit value such as an int or a 32-bit ptr, that does not
50 * require sign extension. These are handled by zeroing a word
51 * of output, and copying a word from input to output.
53 * s = a 32-bit value such as a long, which must be sign-extended to
54 * a 64-bit long-long in the uu_args. These are handled by
55 * loading a word of input and sign extending it to a double,
56 * and storing two words of output.
58 * l = a 64-bit long-long. These are handled by copying two words
59 * of input to the output.
61 * For example, "munge_wls" takes a word, a long-long, and a word. This
62 * takes four words in the uu_arg[] area: the first word is in one, the
63 * long-long takes two, and the final word is in the fourth. We store six
64 * words: the low word is left in place, followed by a 0, followed by the
65 * two words of the long-long, followed by the low word and the sign extended
66 * high word of the preceeding low word.
68 * Because this is an in-place modification, we actually start at the end
69 * of uu_arg[] and work our way back to the beginning of the array.
71 * As you can see, we save a lot of code by collapsing mungers that are
72 * prefixes or suffixes of each other.
77 movl 8(%esp),%ecx // get &uu_args
82 movl 8(%esp),%ecx // get &uu_args
86 movl 8(%esp),%ecx // get &uu_args
90 movl 8(%esp),%ecx // get &uu_args
94 movl 8(%esp),%ecx // get &uu_args
98 movl 8(%esp),%ecx // get &uu_args
102 movl 8(%esp),%ecx // get &uu_args
105 ENTRY(munge_wwwwwwww)
106 movl 8(%esp),%ecx // get &uu_args
139 Entry(munge_wl) /* Costs an extra w move to do this */
141 movl 8(%esp),%ecx // get &uu_args
154 movl 8(%esp),%ecx // get &uu_args
162 movl 8(%esp),%ecx // get &uu_args
172 movl 8(%esp),%ecx // get &uu_args
180 movl 8(%esp),%ecx // get &uu_args
190 movl 8(%esp),%ecx // get &uu_args
198 ENTRY(munge_wwwwwwlw)
199 movl 8(%esp),%ecx // get &uu_args
211 ENTRY(munge_wwwwwwll)
212 movl 8(%esp),%ecx // get &uu_args
225 movl 8(%esp),%ecx // get &uu_args
237 movl 8(%esp),%ecx // get &uu_args
246 movl 8(%esp),%ecx // get &uu_args
258 ret // actually, this method has nothing to do - all
259 // arguments are already 64-bits, with no mixing of
260 // args that need sign/zero extension