sn1_handler.s revision 1b30f0173f9a56ecd0ce866a75ef47d49210d39c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sn1_misc.h>
#if defined(lint)
void
sn1_handler(void)
{
}
#else /* lint */
#define PIC_SETUP(r) \
call 9f; \
9: \
popl r; \
/*
* %eax - syscall number
* stack contains:
* --------------------------------------
* | 8 | syscall arguments |
* v 4 | syscall wrapper return address |
* %esp+0 | syscall return address |
* --------------------------------------
*/
/* Save registers at the time of the syscall. */
pushfl /* save syscall flags */
/*
* Finish setting up our stack frame. We would normally do this
* upon entry to this function, but in this case we delayed it
* because a "sub" operation can modify flags and we wanted to
* save the flags into the gregset_t above before they get modified.
*
* Our stack frame format is documented in sn1_misc.h.
*/
/* Look up the system call's entry in the sysent table */
/*
* Get the return value flag and the number of arguments from the
* sysent table.
*/
/*
* Setup arguments for our emulation call. Our input arguments,
* 0 to N, will become emulation call arguments 1 to N+1.
* %ecx == number of arguments.
*/
/* copy: %ecx 32-bit words */
/*
* The first parameter to the emulation callback function is a
* pointer to a sysret_t structure.
*/
/* invoke the emulation routine */
/* restore scratch registers */
/* Check for syscall emulation success or failure */
stc /* failure, set carry flag */
jmp return /* return, %rax == errno */
/* There is always at least one return value. */
clc /* success, clear carry flag */
return:
ret /* ret to instr after syscall */
#endif /* lint */