2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * This header file must uses _ASM defines to allow it to be included 2N/A * in assmebly source files 2N/A * Our syscall emulation callback handler adds one argument to each 2N/A * system call, so we'll need to allocate space for one more argument 2N/A * above the maximum number of arguments that a system call can normally 2N/A * take. Also, we assume that each syscall argument is a long, ie, we 2N/A * don't support long long syscall parameters. 2N/A * 32-bit and 64-bit sparc syscalls can take up to 8 arguments. 2N/A * 32-bit sparc indirect syscalls can take up to 9 arguments. 2N/A * Arguments 1 - 6 are passed via %o0 - %o5. 2N/A * Additional arguments are passed on the stack. 2N/A * So make space for 4 arguments on the stack. 2N/A * amd64 syscalls can take up to 8 arguments. 2N/A * Arguments 1 - 6 are passed via: %rdi, %rsi, %rdx, %r10, %r8, %r9 2N/A * Additional arguments are passed on the stack. 2N/A * So make space for 3 arguments on the stack. 2N/A#
else /* !__sparc && !__amd64 */ 2N/A * ia32 syscalls can take up to 8 arguments. 2N/A * All arguments are passed on the stack. 2N/A * So make space for 9 arguments on the stack. 2N/A#
endif /* !__sparc && !__amd64 */ 2N/A * On sparc, all emulation callback handler variable access is done 2N/A * relative to %sp, so access offsets are positive. 2N/A * On x86, all emulation callback handler variable access is done 2N/A * relative to %ebp/%rbp, so access offsets are negative. 2N/A#
endif /* !__sparc */ 2N/A * In our emulation callback handler, our stack will look like: 2N/A * ------------------------------------------------- 2N/A * %bp | long rvflag | 2N/A * | | sysret_t sysret | 2N/A * v | gregset_t gregs | 2N/A * %sp | long callback args[EH_ARGS_COUNT] | 2N/A * ------------------------------------------------- 2N/A * For ia32, use %ebp and %esp instead of %bp and %sp. 2N/A * For amd64, use %rbp and %rsp instead of %bp and %sp. 2N/A * Our emulation callback handler always saves enough space to hold the 2N/A * maximum number of stack arguments to a system call. This is architecture 2N/A * specific and is defined via EH_ARGS_COUNT. 2N/A#
endif /* (EH_LOCALS_END != EH_LOCALS_END_TGT) */ 2N/A * The second parameter of each entry in the {BRAND}_sysent_table 2N/A * contains the number of parameters and flags that describe the 2N/A * syscall return value encoding. 2N/A * When declaring new syscall emulation functions, it is very important 2N/A * to to set the proper RV_* flags in the brand_sysent_table. Upon failure, 2N/A * syscall emulation fuctions should return an errno value. Upon success 2N/A * syscall emulation functions should return 0 and set the sysret_t return 2N/A * value parameters accordingly. 2N/A * There are five possible syscall macro wrappers used in the kernel's system 2N/A * call sysent table. These turn into the following return values: 2N/A * SYSENT_CL -> SYSENT_C or SYSENT_CI 2N/A * SYSENT_C SE_64RVAL RV_DEFAULT 2N/A * SYSENT_CI SE_32RVAL1 RV_DEFAULT 2N/A * SYSENT_2CI SE_32RVAL1|SE_32RVAL2 RV_32RVAL2 2N/A * SYSENT_AP SE_64RVAL RV_64RVAL 2N/A#
define NARGS_MASK 0x000000FF /* Mask for syscalls argument count */ 2N/A#
define RV_MASK 0x0000FF00 /* Mask for return value flags */ 2N/A#
define RV_DEFAULT 0x00000100 /* syscall returns "default" values */ 2N/A#
define RV_32RVAL2 0x00000200 /* syscall returns two 32-bit values */ 2N/A#
define RV_64RVAL 0x00000400 /* syscall returns a 64-bit value */ 2N/A * We define our own version of assert because the default one will 2N/A * try to emit a localized message. That is bad because first, we can't 2N/A * emit messages to random file descriptors, and second localizing a message 2N/A * requires allocating memory and we can't do that either. 2N/A * These macros invoke a brandsys subcommand, B_TRUSS_POINT, used to expose 2N/A * a call to an interpositioned syscall that would have otherwise gone 2N/A * unnoticed by truss(1) because the interpositioned system call did not call 2N/A * any system calls before returning. 2N/A#
endif /* __sparc && !__sparcv9 */ 2N/A#
endif /* _BRAND_MISC_H */