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