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