2N/A/*
2N/A * CDDL HEADER START
2N/A *
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 *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
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 *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A .file "syscall.s"
2N/A
2N/A#include "SYS.h"
2N/A
2N/A ANSI_PRAGMA_WEAK(syscall,function)
2N/A
2N/A ENTRY(syscall)
2N/A pushq %rbp
2N/A movq %rsp, %rbp
2N/A /* construct a new call stack frame */
2N/A movl %edi, %eax /* sysnum */
2N/A movq %rsi, %rdi /* arg0 */
2N/A movq %rdx, %rsi /* arg1 */
2N/A movq %rcx, %rdx /* arg2 */
2N/A movq %r8, %rcx /* arg3 */
2N/A movq %r9, %r8 /* arg4 */
2N/A movq 16(%rbp), %r9 /* arg5 */
2N/A movq 32(%rbp), %r10
2N/A pushq %r10 /* arg7 */
2N/A movq 24(%rbp), %r10
2N/A pushq %r10 /* arg6 */
2N/A movq 8(%rbp), %r10
2N/A pushq %r10 /* return addr */
2N/A /* issue the system call */
2N/A movq %rcx, %r10
2N/A syscall
2N/A /* restore the stack frame */
2N/A leave
2N/A SYSCERROR
2N/A ret
2N/A SET_SIZE(syscall)
2N/A
2N/A/*
2N/A * Same as _syscall(), but restricted to 6 syscall arguments
2N/A * so it doesn't need to incur the overhead of a new call stack frame.
2N/A * Implemented for use only within libc; symbol is not exported.
2N/A */
2N/A ENTRY(_syscall6)
2N/A movl %edi, %eax /* sysnum */
2N/A movq %rsi, %rdi /* arg0 */
2N/A movq %rdx, %rsi /* arg1 */
2N/A movq %rcx, %rdx /* arg2 */
2N/A movq %r8, %rcx /* arg3 */
2N/A movq %r9, %r8 /* arg4 */
2N/A movq 8(%rsp), %r9 /* arg5 */
2N/A movq %rcx, %r10
2N/A syscall
2N/A SYSCERROR
2N/A ret
2N/A SET_SIZE(_syscall6)
2N/A
2N/A ENTRY(__systemcall)
2N/A pushq %rbp
2N/A movq %rsp, %rbp
2N/A /* construct a new call stack frame */
2N/A pushq %rdi /* sysret_t pointer */
2N/A movl %esi, %eax /* sysnum */
2N/A movq %rdx, %rdi /* arg0 */
2N/A movq %rcx, %rsi /* arg1 */
2N/A movq %r8, %rdx /* arg2 */
2N/A movq %r9, %rcx /* arg3 */
2N/A movq 16(%rbp), %r8 /* arg4 */
2N/A movq 24(%rbp), %r9 /* arg5 */
2N/A movq 40(%rbp), %r10
2N/A pushq %r10 /* arg7 */
2N/A movq 32(%rbp), %r10
2N/A pushq %r10 /* arg6 */
2N/A movq 8(%rbp), %r10
2N/A pushq %r10 /* return addr */
2N/A /* issue the system call */
2N/A movq %rcx, %r10
2N/A syscall
2N/A movq -8(%rbp), %r10 /* sysret_t pointer */
2N/A jb 1f
2N/A movq %rax, 0(%r10) /* no error */
2N/A movq %rdx, 8(%r10)
2N/A xorq %rax, %rax
2N/A /* restore the stack frame */
2N/A leave
2N/A ret
2N/A1:
2N/A movq $-1, 0(%r10) /* error */
2N/A movq $-1, 8(%r10)
2N/A /* restore the stack frame */
2N/A leave
2N/A ret
2N/A SET_SIZE(__systemcall)
2N/A
2N/A/*
2N/A * Same as __systemcall(), but restricted to 6 syscall arguments
2N/A * so it doesn't need to incur the overhead of a new call stack frame.
2N/A * Implemented for use only within libc; symbol is not exported.
2N/A */
2N/A ENTRY(__systemcall6)
2N/A pushq %rdi /* sysret_t pointer */
2N/A movl %esi, %eax /* sysnum */
2N/A movq %rdx, %rdi /* arg0 */
2N/A movq %rcx, %rsi /* arg1 */
2N/A movq %r8, %rdx /* arg2 */
2N/A movq %r9, %rcx /* arg3 */
2N/A movq 16(%rsp), %r8 /* arg4 */
2N/A movq 24(%rsp), %r9 /* arg5 */
2N/A /* issue the system call */
2N/A movq %rcx, %r10
2N/A syscall
2N/A popq %r10 /* sysret_t pointer */
2N/A jb 1f
2N/A movq %rax, 0(%r10) /* no error */
2N/A movq %rdx, 8(%r10)
2N/A xorq %rax, %rax
2N/A ret
2N/A1:
2N/A movq $-1, 0(%r10) /* error */
2N/A movq $-1, 8(%r10)
2N/A ret
2N/A SET_SIZE(__systemcall6)