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 22*6812Sraf/* 23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*6812Sraf * Use is subject to license terms. 25*6812Sraf */ 26*6812Sraf 270Sstevel@tonic-gate/* Copyright (c) 1988 AT&T */ 280Sstevel@tonic-gate/* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate/* 330Sstevel@tonic-gate * C library -- int syscall(int sysnum, ...); 340Sstevel@tonic-gate * C library -- int __systemcall(sysret_t *, int sysnum, ...); 350Sstevel@tonic-gate * 360Sstevel@tonic-gate * Interpret a given system call 370Sstevel@tonic-gate * 380Sstevel@tonic-gate * This version handles up to 8 'long' arguments to a system call. 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * Even though indirect system call support exists in the SPARC 410Sstevel@tonic-gate * 32-bit kernel, we want to eliminate it in a future release, 420Sstevel@tonic-gate * so the real trap for the desired system call is issued right here. 430Sstevel@tonic-gate * 440Sstevel@tonic-gate * Even though %g5 can be used as a scratch register for sparcv9, we don't 450Sstevel@tonic-gate * use it here because this code is shared between sparcv8 and sparcv9. 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate 480Sstevel@tonic-gate .file "%M%" 490Sstevel@tonic-gate 50*6812Sraf#include "SYS.h" 510Sstevel@tonic-gate 520Sstevel@tonic-gate ANSI_PRAGMA_WEAK(syscall,function) 530Sstevel@tonic-gate 54*6812Sraf ENTRY(syscall) 550Sstevel@tonic-gate save %sp, -SA(MINFRAME + 2*CLONGSIZE), %sp 560Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME], %o5 ! arg 5 570Sstevel@tonic-gate mov %i3, %o2 ! arg 2 580Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %g1 590Sstevel@tonic-gate mov %i4, %o3 ! arg 3 600Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME] ! arg 6 610Sstevel@tonic-gate mov %i5, %o4 ! arg 4 620Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1 630Sstevel@tonic-gate mov %i1, %o0 ! arg 0 640Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg 7 650Sstevel@tonic-gate mov %i2, %o1 ! arg 1 660Sstevel@tonic-gate mov %i0, %g1 ! sysnum 670Sstevel@tonic-gate ta SYSCALL_TRAPNUM 680Sstevel@tonic-gate bcc,a,pt %icc, 1f 690Sstevel@tonic-gate sra %o0, 0, %i0 ! (int) cast 700Sstevel@tonic-gate restore %o0, 0, %o0 710Sstevel@tonic-gate ba __cerror 720Sstevel@tonic-gate nop 730Sstevel@tonic-gate1: 740Sstevel@tonic-gate ret 750Sstevel@tonic-gate restore 76*6812Sraf SET_SIZE(syscall) 770Sstevel@tonic-gate 780Sstevel@tonic-gate/* 790Sstevel@tonic-gate * Same as _syscall(), but restricted to 6 syscall arguments 800Sstevel@tonic-gate * so it doesn't need to incur the overhead of a register window. 810Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate ENTRY(_syscall6) 840Sstevel@tonic-gate mov %o0, %g1 /* sysnum */ 850Sstevel@tonic-gate mov %o1, %o0 /* syscall args */ 860Sstevel@tonic-gate mov %o2, %o1 870Sstevel@tonic-gate mov %o3, %o2 880Sstevel@tonic-gate mov %o4, %o3 890Sstevel@tonic-gate mov %o5, %o4 900Sstevel@tonic-gate ldn [%sp + STACK_BIAS + MINFRAME], %o5 910Sstevel@tonic-gate ta SYSCALL_TRAPNUM 920Sstevel@tonic-gate SYSCERROR 930Sstevel@tonic-gate retl 940Sstevel@tonic-gate sra %o0, 0, %o0 /* (int) cast */ 950Sstevel@tonic-gate SET_SIZE(_syscall6) 960Sstevel@tonic-gate 970Sstevel@tonic-gate ENTRY(__systemcall) 980Sstevel@tonic-gate save %sp, -SA(MINFRAME + 2*CLONGSIZE), %sp 990Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME], %o4 ! arg 4 1000Sstevel@tonic-gate mov %i3, %o1 ! arg 1 1010Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5 ! arg5 1020Sstevel@tonic-gate mov %i4, %o2 ! arg 2 1030Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1 1040Sstevel@tonic-gate mov %i5, %o3 ! arg 3 1050Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME] ! arg 6 1060Sstevel@tonic-gate mov %i2, %o0 ! arg 0 1070Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + 3*CLONGSIZE], %g1 1080Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg7 1090Sstevel@tonic-gate mov %i1, %g1 ! sysnum 1100Sstevel@tonic-gate ta SYSCALL_TRAPNUM 1110Sstevel@tonic-gate bcc,pt %icc, 1f 1120Sstevel@tonic-gate mov -1, %g1 1130Sstevel@tonic-gate stn %g1, [%i0] /* error */ 1140Sstevel@tonic-gate ba 2f 1150Sstevel@tonic-gate stn %g1, [%i0 + CLONGSIZE] 1160Sstevel@tonic-gate1: 1170Sstevel@tonic-gate stn %o0, [%i0] /* no error */ 1180Sstevel@tonic-gate clr %o0 1190Sstevel@tonic-gate stn %o1, [%i0 + CLONGSIZE] 1200Sstevel@tonic-gate2: 1210Sstevel@tonic-gate ret 1220Sstevel@tonic-gate restore %o0, 0, %o0 1230Sstevel@tonic-gate SET_SIZE(__systemcall) 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate/* 1260Sstevel@tonic-gate * Same as __systemcall(), but restricted to 6 syscall arguments 1270Sstevel@tonic-gate * so it doesn't need to incur the overhead of a register window. 1280Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate ENTRY(__systemcall6) 1310Sstevel@tonic-gate stn %o0, [%sp + SAVE_OFFSET] /* sysret address */ 1320Sstevel@tonic-gate mov %o1, %g1 /* sysnum */ 1330Sstevel@tonic-gate mov %o2, %o0 /* syscall args */ 1340Sstevel@tonic-gate mov %o3, %o1 1350Sstevel@tonic-gate mov %o4, %o2 1360Sstevel@tonic-gate mov %o5, %o3 1370Sstevel@tonic-gate ldn [%sp + STACK_BIAS + MINFRAME], %o4 1380Sstevel@tonic-gate ldn [%sp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5 1390Sstevel@tonic-gate ta SYSCALL_TRAPNUM 1400Sstevel@tonic-gate bcs,pn %icc, 1f 1410Sstevel@tonic-gate ldn [%sp + SAVE_OFFSET], %g1 1420Sstevel@tonic-gate stn %o0, [%g1] /* no error */ 1430Sstevel@tonic-gate stn %o1, [%g1 + CLONGSIZE] 1440Sstevel@tonic-gate retl 1450Sstevel@tonic-gate clr %o0 1460Sstevel@tonic-gate1: 1470Sstevel@tonic-gate mov -1, %o1 /* error */ 1480Sstevel@tonic-gate stn %o1, [%g1] 1490Sstevel@tonic-gate retl 1500Sstevel@tonic-gate stn %o1, [%g1 + CLONGSIZE] 1510Sstevel@tonic-gate SET_SIZE(__systemcall6) 152