2 * Coyright (c) 2005-2008 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, // %rdi
45 * void *uu_args); // %rsi
47 * The name of the function encodes the number and type of the parameters,
50 * w = a 32-bit value such as an int or a 32-bit ptr, that does not
51 * require sign extension. These are handled by zeroing a word
52 * of output, and copying a word from input to output.
54 * s = a 32-bit value such as a long, which must be sign-extended to
55 * a 64-bit long-long in the uu_args. These are handled by
56 * loading a word of input and sign extending it to a double,
57 * and storing two words of output.
59 * l = a 64-bit long-long. These are handled by copying two words
60 * of input to the output.
62 * For example, "munge_wls" takes a word, a long-long, and a word. This
63 * takes four words in the uu_arg[] area: the first word is in one, the
64 * long-long takes two, and the final word is in the fourth. We store six
65 * words: the low word is left in place, followed by a 0, followed by the
66 * two words of the long-long, followed by the low word and the sign extended
67 * high word of the preceeding low word.
69 * Because this is an in-place modification, we actually start at the end
70 * of uu_arg[] and work our way back to the beginning of the array.
72 * As you can see, we save a lot of code by collapsing mungers that are
73 * prefixes or suffixes of each other.
132 Entry(munge_wl) /* Costs an extra w move to do this */
170 ENTRY(munge_wlwwwllw)
177 ENTRY(munge_wlwwlwlw)
199 movl 40(%rsi),%eax //l
203 movl 32(%rsi),%eax //l
207 movl 24(%rsi),%eax //w
210 movl 20(%rsi),%eax //w
213 movl 16(%rsi),%eax //l
262 ENTRY(munge_wwwwwlww)
277 ENTRY(munge_wwwwwllw)
292 ENTRY(munge_wwwwwlll)
316 ENTRY(munge_wwwwwwlw)
327 ENTRY(munge_wwwwwwll)
370 ret // nothing to do here, either - all args are already
371 // 64-bit and do not require sign/zero extension
372 // also, there is no mixing in of shorter args that