2 * Copyright (c) 2004 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_EN
24 * Syscall argument mungers.
26 * Passed a pointer to the users register array in the savearea, we copy args into
27 * the uu_arg[] array, padding etc as appropriate. The issue is that parameters
28 * passed in registers from a 32-bit address space do not map directly into the uu_args.
29 * For example, a 32-bit long-long comes in two registers, but we need to combine
30 * them into one 64-bit long-long in the uu_args.
32 * There are several functions in this file. Each takes two parameters:
34 * void munge_XXXX( const void *regs, void *uu_args);
36 * The name of the function encodes the number and type of the parameters, as follows:
38 * w = a 32-bit value such as an int or a 32-bit ptr, that does not require
39 * sign extension. These are handled by skipping a word in the input,
40 * zeroing a word of output, and copying a word from input to output.
42 * s = a 32-bit value such as a long, which must be sign-extended to a 64-bit
43 * long-long in the uu_args. These are handled by skipping a word of
44 * input, loading a word of input and sign extending it to a double,
45 * and storing two words of output.
47 * l = a 64-bit long-long, passed in two registers. These are handled by skipping
48 * a word of input, copying a word, skipping another word of input, and
49 * copying another word.
51 * d = a 32-bit int or a 64-bit ptr or long, passed in via a 64-bit GPR
52 * from a 64-bit process. We copy two words from input to output.
54 * For example, "munge_wls" takes a word, a long-long, and a word. This takes
55 * four registers: the first word is in one, the long-long takes two, and the
56 * final word is in the fourth. We store six words: a 0, the low words of the
57 * first three registers, and the two words resulting from sign-extending the
58 * low word of the fourth register.
60 * As you can see, we save a lot of code by collapsing mungers that are prefixes
61 * of each other, into the more general routine. This ends up copying a few extra
62 * bytes of parameters, but big deal. The old kernel copied all eight words for
65 * These routines assume explicit pad words in the uu_arg structures, that fill out
66 * int parameters to 64 bits. Having pad words makes munging args for 64-bit
67 * processes the equivalent of a simple bcopy(), though it does introduce an
72 .globl _munge_dddddddd // that is 8 'd's
124 .globl _munge_wwwwwwww // that is 8 'w's
126 .globl _munge_wwwwwww
244 .globl _munge_wwwwl // 4 'w's and an l
269 .globl _munge_wwwwwl // 5 'w's and an l