xref: /onnv-gate/usr/src/lib/libc/sparc/sys/syscall.s (revision 0:68f95e015346)
1*0Sstevel@tonic-gate/*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate/*	Copyright (c) 1988 AT&T	*/
23*0Sstevel@tonic-gate/*	  All Rights Reserved	*/
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate/*
27*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate * Use is subject to license terms.
29*0Sstevel@tonic-gate */
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate/*
34*0Sstevel@tonic-gate * C library -- int syscall(int sysnum, ...);
35*0Sstevel@tonic-gate * C library -- int __systemcall(sysret_t *, int sysnum, ...);
36*0Sstevel@tonic-gate *
37*0Sstevel@tonic-gate * Interpret a given system call
38*0Sstevel@tonic-gate *
39*0Sstevel@tonic-gate * This version handles up to 8 'long' arguments to a system call.
40*0Sstevel@tonic-gate *
41*0Sstevel@tonic-gate * Even though indirect system call support exists in the SPARC
42*0Sstevel@tonic-gate * 32-bit kernel, we want to eliminate it in a future release,
43*0Sstevel@tonic-gate * so the real trap for the desired system call is issued right here.
44*0Sstevel@tonic-gate *
45*0Sstevel@tonic-gate * Even though %g5 can be used as a scratch register for sparcv9, we don't
46*0Sstevel@tonic-gate * use it here because this code is shared between sparcv8 and sparcv9.
47*0Sstevel@tonic-gate */
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gate	.file	"%M%"
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate#include <sys/asm_linkage.h>
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate	ANSI_PRAGMA_WEAK(syscall,function)
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate#include "SYS.h"
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate#undef _syscall		/* override "synonyms.h" */
58*0Sstevel@tonic-gate#undef __systemcall
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate	ENTRY(_syscall)
61*0Sstevel@tonic-gate	save	%sp, -SA(MINFRAME + 2*CLONGSIZE), %sp
62*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME], %o5	! arg 5
63*0Sstevel@tonic-gate	mov	%i3, %o2				! arg 2
64*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %g1
65*0Sstevel@tonic-gate	mov	%i4, %o3				! arg 3
66*0Sstevel@tonic-gate	stn	%g1, [%sp + STACK_BIAS + MINFRAME]	! arg 6
67*0Sstevel@tonic-gate	mov	%i5, %o4				! arg 4
68*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1
69*0Sstevel@tonic-gate	mov	%i1, %o0				! arg 0
70*0Sstevel@tonic-gate	stn	%g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg 7
71*0Sstevel@tonic-gate	mov	%i2, %o1				! arg 1
72*0Sstevel@tonic-gate	mov	%i0, %g1				! sysnum
73*0Sstevel@tonic-gate	ta	SYSCALL_TRAPNUM
74*0Sstevel@tonic-gate	bcc,a,pt %icc, 1f
75*0Sstevel@tonic-gate	  sra	%o0, 0, %i0				! (int) cast
76*0Sstevel@tonic-gate	restore	%o0, 0, %o0
77*0Sstevel@tonic-gate	ba	__cerror
78*0Sstevel@tonic-gate	  nop
79*0Sstevel@tonic-gate1:
80*0Sstevel@tonic-gate	ret
81*0Sstevel@tonic-gate	  restore
82*0Sstevel@tonic-gate	SET_SIZE(_syscall)
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate/*
85*0Sstevel@tonic-gate * Same as _syscall(), but restricted to 6 syscall arguments
86*0Sstevel@tonic-gate * so it doesn't need to incur the overhead of a register window.
87*0Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported.
88*0Sstevel@tonic-gate */
89*0Sstevel@tonic-gate	ENTRY(_syscall6)
90*0Sstevel@tonic-gate	mov	%o0, %g1			/* sysnum */
91*0Sstevel@tonic-gate	mov	%o1, %o0			/* syscall args */
92*0Sstevel@tonic-gate	mov	%o2, %o1
93*0Sstevel@tonic-gate	mov	%o3, %o2
94*0Sstevel@tonic-gate	mov	%o4, %o3
95*0Sstevel@tonic-gate	mov	%o5, %o4
96*0Sstevel@tonic-gate	ldn	[%sp + STACK_BIAS + MINFRAME], %o5
97*0Sstevel@tonic-gate	ta	SYSCALL_TRAPNUM
98*0Sstevel@tonic-gate	SYSCERROR
99*0Sstevel@tonic-gate	retl
100*0Sstevel@tonic-gate	  sra	%o0, 0, %o0			/* (int) cast */
101*0Sstevel@tonic-gate	SET_SIZE(_syscall6)
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate	ENTRY(__systemcall)
104*0Sstevel@tonic-gate	save	%sp, -SA(MINFRAME + 2*CLONGSIZE), %sp
105*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME], %o4	! arg 4
106*0Sstevel@tonic-gate	mov	%i3, %o1				! arg 1
107*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5 ! arg5
108*0Sstevel@tonic-gate	mov	%i4, %o2				! arg 2
109*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1
110*0Sstevel@tonic-gate	mov	%i5, %o3				! arg 3
111*0Sstevel@tonic-gate	stn	%g1, [%sp + STACK_BIAS + MINFRAME]	! arg 6
112*0Sstevel@tonic-gate	mov	%i2, %o0				! arg 0
113*0Sstevel@tonic-gate	ldn	[%fp + STACK_BIAS + MINFRAME + 3*CLONGSIZE], %g1
114*0Sstevel@tonic-gate	stn	%g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg7
115*0Sstevel@tonic-gate	mov	%i1, %g1				! sysnum
116*0Sstevel@tonic-gate	ta	SYSCALL_TRAPNUM
117*0Sstevel@tonic-gate	bcc,pt	%icc, 1f
118*0Sstevel@tonic-gate	  mov	-1, %g1
119*0Sstevel@tonic-gate	stn	%g1, [%i0]	/* error */
120*0Sstevel@tonic-gate	ba	2f
121*0Sstevel@tonic-gate	  stn	%g1, [%i0 + CLONGSIZE]
122*0Sstevel@tonic-gate1:
123*0Sstevel@tonic-gate	stn	%o0, [%i0]	/* no error */
124*0Sstevel@tonic-gate	clr	%o0
125*0Sstevel@tonic-gate	stn	%o1, [%i0 + CLONGSIZE]
126*0Sstevel@tonic-gate2:
127*0Sstevel@tonic-gate	ret
128*0Sstevel@tonic-gate	  restore %o0, 0, %o0
129*0Sstevel@tonic-gate	SET_SIZE(__systemcall)
130*0Sstevel@tonic-gate
131*0Sstevel@tonic-gate/*
132*0Sstevel@tonic-gate * Same as __systemcall(), but restricted to 6 syscall arguments
133*0Sstevel@tonic-gate * so it doesn't need to incur the overhead of a register window.
134*0Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported.
135*0Sstevel@tonic-gate */
136*0Sstevel@tonic-gate	ENTRY(__systemcall6)
137*0Sstevel@tonic-gate	stn	%o0, [%sp + SAVE_OFFSET]	/* sysret address */
138*0Sstevel@tonic-gate	mov	%o1, %g1			/* sysnum */
139*0Sstevel@tonic-gate	mov	%o2, %o0			/* syscall args */
140*0Sstevel@tonic-gate	mov	%o3, %o1
141*0Sstevel@tonic-gate	mov	%o4, %o2
142*0Sstevel@tonic-gate	mov	%o5, %o3
143*0Sstevel@tonic-gate	ldn	[%sp + STACK_BIAS + MINFRAME], %o4
144*0Sstevel@tonic-gate	ldn	[%sp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5
145*0Sstevel@tonic-gate	ta	SYSCALL_TRAPNUM
146*0Sstevel@tonic-gate	bcs,pn	%icc, 1f
147*0Sstevel@tonic-gate	  ldn	[%sp + SAVE_OFFSET], %g1
148*0Sstevel@tonic-gate	stn	%o0, [%g1]	/* no error */
149*0Sstevel@tonic-gate	stn	%o1, [%g1 + CLONGSIZE]
150*0Sstevel@tonic-gate	retl
151*0Sstevel@tonic-gate	  clr	%o0
152*0Sstevel@tonic-gate1:
153*0Sstevel@tonic-gate	mov	-1, %o1		/* error */
154*0Sstevel@tonic-gate	stn	%o1, [%g1]
155*0Sstevel@tonic-gate	retl
156*0Sstevel@tonic-gate	  stn	%o1, [%g1 + CLONGSIZE]
157*0Sstevel@tonic-gate	SET_SIZE(__systemcall6)
158