xref: /titanic_51/usr/src/lib/libbc/sparc/inc/SYS.h (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 !
23 !	"@(#)SYS.h 1.14 88/02/08"
24 !       Copyright (c) 1986, 1996 by Sun Microsystems, Inc.
25 !	All rights reserved.
26 !
27 
28 #include <sys/syscall.h>
29 #include <machine/asm_linkage.h>
30 #include "PIC.h"
31 
32 #define SV_ERESTART	91	/* ERESTART is returned by the kernel for
33 				   restartable system calls */
34 
35 #define WINDOWSIZE	(16*4)
36 
37 	.global	.cerror
38 
39 #define SYSCALL(x) \
40 	ENTRY(x); \
41 	mov	SYS_/**/x, %g1; \
42 	t	8; \
43 	CERROR(o5)
44 
45 #define BSDSYSCALL(x) \
46 	ENTRY(_/**/x); \
47 	mov	SYS_/**/x, %g1; \
48 	t	8; \
49 	CERROR(o5)
50 
51 /*
52  * SYSREENTRY provides the entry sequence for restartable system calls.
53  */
54 #define SYSREENTRY(x)	\
55 	ENTRY(x);	\
56 	st      %o0,[%sp+68]; \
57 .restart_/**/x:
58 
59 #define PSEUDO(x, y) \
60 	ENTRY(x); \
61 	mov	SYS_/**/y, %g1; \
62 	t	8;
63 
64 /*
65  * SYSCALL_RESTART provides the most common restartable system call sequence.
66  */
67 #define SYSCALL_RESTART(x) \
68 	SYSREENTRY(x); \
69 	mov	SYS_/**/x, %g1; \
70 	t	8; \
71 	SYSRESTART(.restart_/**/x)
72 
73 /*
74  * SYSREENTRY provides the entry sequence for restartable system calls.
75  */
76 #define SYSREENTRY(x) \
77 	ENTRY(x); \
78 	st      %o0,[%sp+68]; \
79 .restart_/**/x:
80 
81 /*
82  * SYSRESTART provides the error handling sequence for restartable
83  * system calls.
84  */
85 #ifdef PIC
86 #define SYSRESTART(x) \
87 	bcc	noerr; \
88 	cmp	%o0, SV_ERESTART; \
89 	be,a	x; \
90 	ld	 [%sp+68], %o0; \
91 	PIC_SETUP(o5); \
92 	ld	[%o5 + .cerror], %o5; \
93 	jmp	%o5; \
94 	.empty; \
95 noerr:	nop	;
96 #else
97 #define SYSRESTART(x) \
98 	bcc	noerr; \
99 	cmp	%o0, SV_ERESTART; \
100 	be,a	x; \
101 	ld	[%sp+68], %o0; \
102 	ba	.cerror; \
103 	.empty; \
104 noerr:	nop	;
105 #endif
106 
107 #define RET	retl; nop;
108 
109 #ifdef PIC
110 #define CERROR(free_reg) \
111 	bcc	noerr; \
112 	PIC_SETUP(free_reg); \
113 	.empty;	\
114 	ld	[%free_reg+ .cerror],%free_reg; \
115 	jmp	%free_reg; \
116 	.empty;	\
117 noerr:	nop;
118 #else
119 #define CERROR(free_reg) \
120 	bcc 	noerr; \
121 	.empty; \
122 	sethi	%hi(.cerror), %free_reg;\
123 	or	%free_reg, %lo(.cerror), %free_reg;\
124 	jmp	%free_reg;\
125 	.empty;\
126 noerr: nop;
127 #endif
128