/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBC_AMD64_INC_SYS_H
#define _LIBC_AMD64_INC_SYS_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file defines common code sequences for system calls.
*/
#include <sys/asm_linkage.h>
/*
* Define the external symbol __cerror for all files.
*/
/*
* __SYSCALL provides the basic trap sequence. It assumes that
* Note that %rcx is smashed by the syscall instruction,
* so we move it to %r10 in order to pass it to the kernel.
*/
/* CSTYLED */ \
/*
* SYSFASTTRAP provides the fast system call trap sequence. It assumes
*/
/* CSTYLED */ \
int $T_FASTTRAP
/*
* SYSCERROR provides the sequence to branch to __cerror if an error is
* indicated by the carry-bit being set upon return from a trap.
*/
#define SYSCERROR \
/*
* SYSLWPERR provides the sequence to return 0 on a successful trap
* and the error code if unsuccessful.
* Error is indicated by the carry-bit being set upon return from a trap.
*/
#define SYSLWPERR \
jae 1f; \
jne 2f; \
jmp 2f; \
1: \
2:
/*
* SYSREENTRY provides the entry sequence for restartable system calls.
*/
1:
/*
* SYSRESTART provides the error handling sequence for restartable
* system calls.
* XX64 -- Are all of the argument registers restored to their
* original values on an ERESTART return (including %rcx)?
*/
jae 1f; \
je 1b; \
1:
/*
* SYSINTR_RESTART provides the error handling sequence for restartable
* system calls in case of EINTR or ERESTART.
*/
jae 1f; \
je 1b; \
je 1b; \
jmp 2f; \
1: \
2:
/*
* SYSCALL provides the standard (i.e.: most common) system call sequence.
*/
SYSTRAP_2RVALS(name); \
SYSTRAP_RVAL1(name); \
/*
* SYSCALL64 provides the standard (i.e.: most common) system call sequence
* for system calls that return 64-bit values.
*/
/*
* SYSCALL_RESTART provides the most common restartable system call sequence.
*/
SYSREENTRY(name); \
SYSTRAP_2RVALS(name); \
SYSREENTRY(name); \
SYSTRAP_RVAL1(name); \
/*
* SYSCALL2 provides a common system call sequence when the entry name
* is different than the trap name.
*/
/*
* SYSCALL2_RESTART provides a common restartable system call sequence when the
* entry name is different than the trap name.
*/
SYSREENTRY(entryname); \
SYSREENTRY(entryname); \
/*
* SYSCALL_NOERROR provides the most common system call sequence for those
* system calls which don't check the error reture (carry bit).
*/
/*
* Standard syscall return sequence, return code equal to rval1.
*/
#define RET \
/*
* Syscall return sequence, return code equal to rval2.
*/
#define RET2 \
/*
* Syscall return sequence with return code forced to zero.
*/
#define RETC \
#endif /* _LIBC_AMD64_INC_SYS_H */