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 56812Sraf * Common Development and Distribution License (the "License"). 66812Sraf * 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 */ 216812Sraf 220Sstevel@tonic-gate/* 236812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 27*7298SMark.J.Nelson@Sun.COM .file "syscall.s" 280Sstevel@tonic-gate 296812Sraf#include "SYS.h" 300Sstevel@tonic-gate 310Sstevel@tonic-gate ANSI_PRAGMA_WEAK(syscall,function) 320Sstevel@tonic-gate 336812Sraf ENTRY(syscall) 340Sstevel@tonic-gate pushq %rbp 350Sstevel@tonic-gate movq %rsp, %rbp 360Sstevel@tonic-gate /* construct a new call stack frame */ 370Sstevel@tonic-gate movl %edi, %eax /* sysnum */ 380Sstevel@tonic-gate movq %rsi, %rdi /* arg0 */ 390Sstevel@tonic-gate movq %rdx, %rsi /* arg1 */ 400Sstevel@tonic-gate movq %rcx, %rdx /* arg2 */ 410Sstevel@tonic-gate movq %r8, %rcx /* arg3 */ 420Sstevel@tonic-gate movq %r9, %r8 /* arg4 */ 430Sstevel@tonic-gate movq 16(%rbp), %r9 /* arg5 */ 440Sstevel@tonic-gate movq 32(%rbp), %r10 450Sstevel@tonic-gate pushq %r10 /* arg7 */ 460Sstevel@tonic-gate movq 24(%rbp), %r10 470Sstevel@tonic-gate pushq %r10 /* arg6 */ 480Sstevel@tonic-gate movq 8(%rbp), %r10 490Sstevel@tonic-gate pushq %r10 /* return addr */ 500Sstevel@tonic-gate /* issue the system call */ 510Sstevel@tonic-gate movq %rcx, %r10 520Sstevel@tonic-gate syscall 530Sstevel@tonic-gate /* restore the stack frame */ 540Sstevel@tonic-gate leave 550Sstevel@tonic-gate SYSCERROR 560Sstevel@tonic-gate ret 576812Sraf SET_SIZE(syscall) 580Sstevel@tonic-gate 590Sstevel@tonic-gate/* 600Sstevel@tonic-gate * Same as _syscall(), but restricted to 6 syscall arguments 610Sstevel@tonic-gate * so it doesn't need to incur the overhead of a new call stack frame. 620Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate ENTRY(_syscall6) 650Sstevel@tonic-gate movl %edi, %eax /* sysnum */ 660Sstevel@tonic-gate movq %rsi, %rdi /* arg0 */ 670Sstevel@tonic-gate movq %rdx, %rsi /* arg1 */ 680Sstevel@tonic-gate movq %rcx, %rdx /* arg2 */ 690Sstevel@tonic-gate movq %r8, %rcx /* arg3 */ 700Sstevel@tonic-gate movq %r9, %r8 /* arg4 */ 710Sstevel@tonic-gate movq 8(%rsp), %r9 /* arg5 */ 720Sstevel@tonic-gate movq %rcx, %r10 730Sstevel@tonic-gate syscall 740Sstevel@tonic-gate SYSCERROR 750Sstevel@tonic-gate ret 760Sstevel@tonic-gate SET_SIZE(_syscall6) 770Sstevel@tonic-gate 780Sstevel@tonic-gate ENTRY(__systemcall) 790Sstevel@tonic-gate pushq %rbp 800Sstevel@tonic-gate movq %rsp, %rbp 810Sstevel@tonic-gate /* construct a new call stack frame */ 820Sstevel@tonic-gate pushq %rdi /* sysret_t pointer */ 830Sstevel@tonic-gate movl %esi, %eax /* sysnum */ 840Sstevel@tonic-gate movq %rdx, %rdi /* arg0 */ 850Sstevel@tonic-gate movq %rcx, %rsi /* arg1 */ 860Sstevel@tonic-gate movq %r8, %rdx /* arg2 */ 870Sstevel@tonic-gate movq %r9, %rcx /* arg3 */ 880Sstevel@tonic-gate movq 16(%rbp), %r8 /* arg4 */ 890Sstevel@tonic-gate movq 24(%rbp), %r9 /* arg5 */ 900Sstevel@tonic-gate movq 40(%rbp), %r10 910Sstevel@tonic-gate pushq %r10 /* arg7 */ 920Sstevel@tonic-gate movq 32(%rbp), %r10 930Sstevel@tonic-gate pushq %r10 /* arg6 */ 940Sstevel@tonic-gate movq 8(%rbp), %r10 950Sstevel@tonic-gate pushq %r10 /* return addr */ 960Sstevel@tonic-gate /* issue the system call */ 970Sstevel@tonic-gate movq %rcx, %r10 980Sstevel@tonic-gate syscall 990Sstevel@tonic-gate movq -8(%rbp), %r10 /* sysret_t pointer */ 1000Sstevel@tonic-gate jb 1f 1010Sstevel@tonic-gate movq %rax, 0(%r10) /* no error */ 1020Sstevel@tonic-gate movq %rdx, 8(%r10) 1030Sstevel@tonic-gate xorq %rax, %rax 1040Sstevel@tonic-gate /* restore the stack frame */ 1050Sstevel@tonic-gate leave 1060Sstevel@tonic-gate ret 1070Sstevel@tonic-gate1: 1080Sstevel@tonic-gate movq $-1, 0(%r10) /* error */ 1090Sstevel@tonic-gate movq $-1, 8(%r10) 1100Sstevel@tonic-gate /* restore the stack frame */ 1110Sstevel@tonic-gate leave 1120Sstevel@tonic-gate ret 1130Sstevel@tonic-gate SET_SIZE(__systemcall) 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate/* 1160Sstevel@tonic-gate * Same as __systemcall(), but restricted to 6 syscall arguments 1170Sstevel@tonic-gate * so it doesn't need to incur the overhead of a new call stack frame. 1180Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate ENTRY(__systemcall6) 1210Sstevel@tonic-gate pushq %rdi /* sysret_t pointer */ 1220Sstevel@tonic-gate movl %esi, %eax /* sysnum */ 1230Sstevel@tonic-gate movq %rdx, %rdi /* arg0 */ 1240Sstevel@tonic-gate movq %rcx, %rsi /* arg1 */ 1250Sstevel@tonic-gate movq %r8, %rdx /* arg2 */ 1260Sstevel@tonic-gate movq %r9, %rcx /* arg3 */ 1270Sstevel@tonic-gate movq 16(%rsp), %r8 /* arg4 */ 1280Sstevel@tonic-gate movq 24(%rsp), %r9 /* arg5 */ 1290Sstevel@tonic-gate /* issue the system call */ 1300Sstevel@tonic-gate movq %rcx, %r10 1310Sstevel@tonic-gate syscall 1320Sstevel@tonic-gate popq %r10 /* sysret_t pointer */ 1330Sstevel@tonic-gate jb 1f 1340Sstevel@tonic-gate movq %rax, 0(%r10) /* no error */ 1350Sstevel@tonic-gate movq %rdx, 8(%r10) 1360Sstevel@tonic-gate xorq %rax, %rax 1370Sstevel@tonic-gate ret 1380Sstevel@tonic-gate1: 1390Sstevel@tonic-gate movq $-1, 0(%r10) /* error */ 1400Sstevel@tonic-gate movq $-1, 8(%r10) 1410Sstevel@tonic-gate ret 1420Sstevel@tonic-gate SET_SIZE(__systemcall6) 143