10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*6812Sraf * Common Development and Distribution License (the "License"). 6*6812Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*6812Sraf 220Sstevel@tonic-gate/* 23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate .file "%M%" 300Sstevel@tonic-gate 31*6812Sraf#include "SYS.h" 320Sstevel@tonic-gate 330Sstevel@tonic-gate ANSI_PRAGMA_WEAK(syscall,function) 340Sstevel@tonic-gate 35*6812Sraf ENTRY(syscall) 360Sstevel@tonic-gate pushq %rbp 370Sstevel@tonic-gate movq %rsp, %rbp 380Sstevel@tonic-gate /* construct a new call stack frame */ 390Sstevel@tonic-gate movl %edi, %eax /* sysnum */ 400Sstevel@tonic-gate movq %rsi, %rdi /* arg0 */ 410Sstevel@tonic-gate movq %rdx, %rsi /* arg1 */ 420Sstevel@tonic-gate movq %rcx, %rdx /* arg2 */ 430Sstevel@tonic-gate movq %r8, %rcx /* arg3 */ 440Sstevel@tonic-gate movq %r9, %r8 /* arg4 */ 450Sstevel@tonic-gate movq 16(%rbp), %r9 /* arg5 */ 460Sstevel@tonic-gate movq 32(%rbp), %r10 470Sstevel@tonic-gate pushq %r10 /* arg7 */ 480Sstevel@tonic-gate movq 24(%rbp), %r10 490Sstevel@tonic-gate pushq %r10 /* arg6 */ 500Sstevel@tonic-gate movq 8(%rbp), %r10 510Sstevel@tonic-gate pushq %r10 /* return addr */ 520Sstevel@tonic-gate /* issue the system call */ 530Sstevel@tonic-gate movq %rcx, %r10 540Sstevel@tonic-gate syscall 550Sstevel@tonic-gate /* restore the stack frame */ 560Sstevel@tonic-gate leave 570Sstevel@tonic-gate SYSCERROR 580Sstevel@tonic-gate ret 59*6812Sraf SET_SIZE(syscall) 600Sstevel@tonic-gate 610Sstevel@tonic-gate/* 620Sstevel@tonic-gate * Same as _syscall(), but restricted to 6 syscall arguments 630Sstevel@tonic-gate * so it doesn't need to incur the overhead of a new call stack frame. 640Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 650Sstevel@tonic-gate */ 660Sstevel@tonic-gate ENTRY(_syscall6) 670Sstevel@tonic-gate movl %edi, %eax /* sysnum */ 680Sstevel@tonic-gate movq %rsi, %rdi /* arg0 */ 690Sstevel@tonic-gate movq %rdx, %rsi /* arg1 */ 700Sstevel@tonic-gate movq %rcx, %rdx /* arg2 */ 710Sstevel@tonic-gate movq %r8, %rcx /* arg3 */ 720Sstevel@tonic-gate movq %r9, %r8 /* arg4 */ 730Sstevel@tonic-gate movq 8(%rsp), %r9 /* arg5 */ 740Sstevel@tonic-gate movq %rcx, %r10 750Sstevel@tonic-gate syscall 760Sstevel@tonic-gate SYSCERROR 770Sstevel@tonic-gate ret 780Sstevel@tonic-gate SET_SIZE(_syscall6) 790Sstevel@tonic-gate 800Sstevel@tonic-gate ENTRY(__systemcall) 810Sstevel@tonic-gate pushq %rbp 820Sstevel@tonic-gate movq %rsp, %rbp 830Sstevel@tonic-gate /* construct a new call stack frame */ 840Sstevel@tonic-gate pushq %rdi /* sysret_t pointer */ 850Sstevel@tonic-gate movl %esi, %eax /* sysnum */ 860Sstevel@tonic-gate movq %rdx, %rdi /* arg0 */ 870Sstevel@tonic-gate movq %rcx, %rsi /* arg1 */ 880Sstevel@tonic-gate movq %r8, %rdx /* arg2 */ 890Sstevel@tonic-gate movq %r9, %rcx /* arg3 */ 900Sstevel@tonic-gate movq 16(%rbp), %r8 /* arg4 */ 910Sstevel@tonic-gate movq 24(%rbp), %r9 /* arg5 */ 920Sstevel@tonic-gate movq 40(%rbp), %r10 930Sstevel@tonic-gate pushq %r10 /* arg7 */ 940Sstevel@tonic-gate movq 32(%rbp), %r10 950Sstevel@tonic-gate pushq %r10 /* arg6 */ 960Sstevel@tonic-gate movq 8(%rbp), %r10 970Sstevel@tonic-gate pushq %r10 /* return addr */ 980Sstevel@tonic-gate /* issue the system call */ 990Sstevel@tonic-gate movq %rcx, %r10 1000Sstevel@tonic-gate syscall 1010Sstevel@tonic-gate movq -8(%rbp), %r10 /* sysret_t pointer */ 1020Sstevel@tonic-gate jb 1f 1030Sstevel@tonic-gate movq %rax, 0(%r10) /* no error */ 1040Sstevel@tonic-gate movq %rdx, 8(%r10) 1050Sstevel@tonic-gate xorq %rax, %rax 1060Sstevel@tonic-gate /* restore the stack frame */ 1070Sstevel@tonic-gate leave 1080Sstevel@tonic-gate ret 1090Sstevel@tonic-gate1: 1100Sstevel@tonic-gate movq $-1, 0(%r10) /* error */ 1110Sstevel@tonic-gate movq $-1, 8(%r10) 1120Sstevel@tonic-gate /* restore the stack frame */ 1130Sstevel@tonic-gate leave 1140Sstevel@tonic-gate ret 1150Sstevel@tonic-gate SET_SIZE(__systemcall) 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate/* 1180Sstevel@tonic-gate * Same as __systemcall(), but restricted to 6 syscall arguments 1190Sstevel@tonic-gate * so it doesn't need to incur the overhead of a new call stack frame. 1200Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 1210Sstevel@tonic-gate */ 1220Sstevel@tonic-gate ENTRY(__systemcall6) 1230Sstevel@tonic-gate pushq %rdi /* sysret_t pointer */ 1240Sstevel@tonic-gate movl %esi, %eax /* sysnum */ 1250Sstevel@tonic-gate movq %rdx, %rdi /* arg0 */ 1260Sstevel@tonic-gate movq %rcx, %rsi /* arg1 */ 1270Sstevel@tonic-gate movq %r8, %rdx /* arg2 */ 1280Sstevel@tonic-gate movq %r9, %rcx /* arg3 */ 1290Sstevel@tonic-gate movq 16(%rsp), %r8 /* arg4 */ 1300Sstevel@tonic-gate movq 24(%rsp), %r9 /* arg5 */ 1310Sstevel@tonic-gate /* issue the system call */ 1320Sstevel@tonic-gate movq %rcx, %r10 1330Sstevel@tonic-gate syscall 1340Sstevel@tonic-gate popq %r10 /* sysret_t pointer */ 1350Sstevel@tonic-gate jb 1f 1360Sstevel@tonic-gate movq %rax, 0(%r10) /* no error */ 1370Sstevel@tonic-gate movq %rdx, 8(%r10) 1380Sstevel@tonic-gate xorq %rax, %rax 1390Sstevel@tonic-gate ret 1400Sstevel@tonic-gate1: 1410Sstevel@tonic-gate movq $-1, 0(%r10) /* error */ 1420Sstevel@tonic-gate movq $-1, 8(%r10) 1430Sstevel@tonic-gate ret 1440Sstevel@tonic-gate SET_SIZE(__systemcall6) 145