summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/sparc/sys/syscall.s
blob: 41af4eb8d96191abdbb99e15da6a3a6c488c33e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * C library -- long syscall(int sysnum, ...);
 * C library -- long __systemcall(sysret_t *, int sysnum, ...);
 *
 * Interpret a given system call
 *
 * This version handles up to 8 'long' arguments to a system call.
 *
 * Even though indirect system call support exists in the SPARC
 * 32-bit kernel, we want to eliminate it in a future release,
 * so the real trap for the desired system call is issued right here.
 *
 * Even though %g5 can be used as a scratch register for sparcv9, we don't
 * use it here because this code is shared between sparcv8 and sparcv9.
 */

	.file	"syscall.s"

#include "SYS.h"

	ANSI_PRAGMA_WEAK(syscall,function)

	ENTRY(syscall)
	save	%sp, -SA(MINFRAME + 2*CLONGSIZE), %sp
	ldn	[%fp + STACK_BIAS + MINFRAME], %o5	! arg 5
	mov	%i3, %o2				! arg 2
	ldn	[%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %g1
	mov	%i4, %o3				! arg 3
	stn	%g1, [%sp + STACK_BIAS + MINFRAME]	! arg 6
	mov	%i5, %o4				! arg 4
	ldn	[%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1
	mov	%i1, %o0				! arg 0
	stn	%g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg 7
	mov	%i2, %o1				! arg 1
	mov	%i0, %g1				! sysnum
	ta	SYSCALL_TRAPNUM
	bcc,a,pt %icc, 1f
	  sra	%o0, 0, %i0				! (int) cast
	restore	%o0, 0, %o0
	ba	__cerror
	  nop
1:
	ret
	  restore
	SET_SIZE(syscall)

/*
 * Same as _syscall(), but restricted to 6 syscall arguments
 * so it doesn't need to incur the overhead of a register window.
 * Implemented for use only within libc; symbol is not exported.
 */
	ENTRY(_syscall6)
	mov	%o0, %g1			/* sysnum */
	mov	%o1, %o0			/* syscall args */
	mov	%o2, %o1
	mov	%o3, %o2
	mov	%o4, %o3
	mov	%o5, %o4
	ldn	[%sp + STACK_BIAS + MINFRAME], %o5
	ta	SYSCALL_TRAPNUM
	SYSCERROR
	retl
	  sra	%o0, 0, %o0			/* (int) cast */
	SET_SIZE(_syscall6)

	ENTRY(__systemcall)
	save	%sp, -SA(MINFRAME + 2*CLONGSIZE), %sp
	ldn	[%fp + STACK_BIAS + MINFRAME], %o4	! arg 4
	mov	%i3, %o1				! arg 1
	ldn	[%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5 ! arg5
	mov	%i4, %o2				! arg 2
	ldn	[%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1
	mov	%i5, %o3				! arg 3
	stn	%g1, [%sp + STACK_BIAS + MINFRAME]	! arg 6
	mov	%i2, %o0				! arg 0
	ldn	[%fp + STACK_BIAS + MINFRAME + 3*CLONGSIZE], %g1
	stn	%g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg7
	mov	%i1, %g1				! sysnum
	ta	SYSCALL_TRAPNUM
	bcc,pt	%icc, 1f
	  mov	-1, %g1
	stn	%g1, [%i0]	/* error */
	ba	2f
	  stn	%g1, [%i0 + CLONGSIZE]
1:
	stn	%o0, [%i0]	/* no error */
	clr	%o0
	stn	%o1, [%i0 + CLONGSIZE]
2:
	ret
	  restore %o0, 0, %o0
	SET_SIZE(__systemcall)

/*
 * Same as __systemcall(), but restricted to 6 syscall arguments
 * so it doesn't need to incur the overhead of a register window.
 * Implemented for use only within libc; symbol is not exported.
 */
	ENTRY(__systemcall6)
	stn	%o0, [%sp + SAVE_OFFSET]	/* sysret address */
	mov	%o1, %g1			/* sysnum */
	mov	%o2, %o0			/* syscall args */
	mov	%o3, %o1
	mov	%o4, %o2
	mov	%o5, %o3
	ldn	[%sp + STACK_BIAS + MINFRAME], %o4
	ldn	[%sp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5
	ta	SYSCALL_TRAPNUM
	bcs,pn	%icc, 1f
	  ldn	[%sp + SAVE_OFFSET], %g1
	stn	%o0, [%g1]	/* no error */
	stn	%o1, [%g1 + CLONGSIZE]
	retl
	  clr	%o0
1:
	mov	-1, %o1		/* error */
	stn	%o1, [%g1]
	retl
	  stn	%o1, [%g1 + CLONGSIZE]
	SET_SIZE(__systemcall6)