2 * Coyright (c) 2005-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 * Syscall argument mungers.
34 * The data to be munged has been explicitly copied in to the arguement area,
35 * and will be munged in place in the uu_arg[] array. Because of this, the
36 * functions all take the same arguments as their PPC equivalents, but the
37 * first argument is ignored. These mungers are for 32-bit app's syscalls,
38 * since 64-bit args are stored into the save area (which overlays the
39 * uu_args) in the order the syscall ABI calls for.
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.
44 * There are several functions in this file. Each takes two parameters:
46 * void munge_XXXX( const void *regs, void *uu_args);
48 * The name of the function encodes the number and type of the parameters,
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.
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.
60 * l = a 64-bit long-long. These are handled by copying two words
61 * of input to the output.
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.
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.
73 * As you can see, we save a lot of code by collapsing mungers that are
74 * prefixes or suffixes of each other.
79 movl 8(%esp),%ecx // get &uu_args
84 movl 8(%esp),%ecx // get &uu_args
88 movl 8(%esp),%ecx // get &uu_args
92 movl 8(%esp),%ecx // get &uu_args
96 movl 8(%esp),%ecx // get &uu_args
100 movl 8(%esp),%ecx // get &uu_args
104 movl 8(%esp),%ecx // get &uu_args
107 ENTRY(munge_wwwwwwww)
108 movl 8(%esp),%ecx // get &uu_args
141 Entry(munge_wl) /* Costs an extra w move to do this */
143 movl 8(%esp),%ecx // get &uu_args
156 movl 8(%esp),%ecx // get &uu_args
165 movl 8(%esp),%ecx // get &uu_args
174 movl 8(%esp),%ecx // get &uu_args
183 movl 8(%esp),%ecx // get &uu_args
195 movl 8(%esp),%ecx // get &uu_args
204 movl 8(%esp),%ecx // get &uu_args