2 * Coyright (c) 2005-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
24 * Syscall argument mungers.
26 * The data to be munged has been explicitly copied in to the arguement area,
27 * and will be munged in place in the uu_arg[] array. Because of this, the
28 * functions all take the same arguments as their PPC equivalents, but the
29 * first argument is ignored. These mungers are for 32-bit app's syscalls,
30 * since 64-bit args are stored into the save area (which overlays the
31 * uu_args) in the order the syscall ABI calls for.
33 * The issue is that the incoming args are 32-bit, but we must expand
34 * them in place into 64-bit args, as if they were from a 64-bit process.
36 * There are several functions in this file. Each takes two parameters:
38 * void munge_XXXX( const void *regs, void *uu_args);
40 * The name of the function encodes the number and type of the parameters,
43 * w = a 32-bit value such as an int or a 32-bit ptr, that does not
44 * require sign extension. These are handled by zeroing a word
45 * of output, and copying a word from input to output.
47 * s = a 32-bit value such as a long, which must be sign-extended to
48 * a 64-bit long-long in the uu_args. These are handled by
49 * loading a word of input and sign extending it to a double,
50 * and storing two words of output.
52 * l = a 64-bit long-long. These are handled by copying two words
53 * of input to the output.
55 * For example, "munge_wls" takes a word, a long-long, and a word. This
56 * takes four words in the uu_arg[] area: the first word is in one, the
57 * long-long takes two, and the final word is in the fourth. We store six
58 * words: the low word is left in place, followed by a 0, followed by the
59 * two words of the long-long, followed by the low word and the sign extended
60 * high word of the preceeding low word.
62 * Because this is an in-place modification, we actually start at the end
63 * of uu_arg[] and work our way back to the beginning of the array.
65 * As you can see, we save a lot of code by collapsing mungers that are
66 * prefixes or suffixes of each other.
71 movl 8(%esp),%ecx // get &uu_args
76 movl 8(%esp),%ecx // get &uu_args
80 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
133 Entry(munge_wl) /* Costs an extra w move to do this */
135 movl 8(%esp),%ecx // get &uu_args
148 movl 8(%esp),%ecx // get &uu_args
157 movl 8(%esp),%ecx // get &uu_args
166 movl 8(%esp),%ecx // get &uu_args
175 movl 8(%esp),%ecx // get &uu_args
187 movl 8(%esp),%ecx // get &uu_args
196 movl 8(%esp),%ecx // get &uu_args