xref: /csrg-svn/lib/libc/sparc/SYS.h (revision 61176)
154382Storek /*-
2*61176Sbostic  * Copyright (c) 1992, 1993
3*61176Sbostic  *	The Regents of the University of California.  All rights reserved.
454383Storek  *
554383Storek  * This software was developed by the Computer Systems Engineering group
654383Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
754383Storek  * contributed to Berkeley.
854383Storek  *
954382Storek  * %sccs.include.redist.c%
1054382Storek  *
11*61176Sbostic  *	@(#)SYS.h	8.1 (Berkeley) 06/04/93
1254870Storek  *
1354870Storek  * from: $Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp $
1454382Storek  */
1554382Storek 
1654382Storek #include <sys/syscall.h>
1754382Storek #include <machine/trap.h>
1854382Storek 
1954382Storek #ifdef PROF
2054382Storek #define	ENTRY(x) \
2154382Storek 	.align 4; .globl _##x; .proc 1; _##x:; .data; .align 4; 1: .long 0; \
2254382Storek 	.text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
2354382Storek 	or %o0,%lo(1b),%o0; restore
2454382Storek #else
2554382Storek #define	ENTRY(x) \
2654382Storek 	.align 4; .globl _##x; .proc 1; _##x:
2754382Storek #endif
2854382Storek 
2954382Storek /*
3054382Storek  * ERROR branches to cerror.  This is done with a macro so that I can
3154382Storek  * change it to be position independent later, if need be.
3254382Storek  */
3354382Storek #define	ERROR() \
3454382Storek 	sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop
3554382Storek 
3654382Storek /*
3754382Storek  * SYSCALL is used when further action must be taken before returning.
3854382Storek  * Note that it adds a `nop' over what we could do, if we only knew what
3954382Storek  * came at label 1....
4054382Storek  */
4154382Storek #define	SYSCALL(x) \
4254382Storek 	ENTRY(x); mov SYS_##x,%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1:
4354382Storek 
4454382Storek /*
4554382Storek  * RSYSCALL is used when the system call should just return.  Here
4654870Storek  * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2
4754382Storek  * and avoid a branch.
4854382Storek  */
4954382Storek #define	RSYSCALL(x) \
5054870Storek 	ENTRY(x); mov (SYS_##x)|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
5154382Storek 	t ST_SYSCALL; ERROR()
5254382Storek 
5354382Storek /*
5454870Storek  * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x.
5554382Storek  */
5654382Storek #define	PSEUDO(x,y) \
5754870Storek 	ENTRY(x); mov (SYS_##y)|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
5854382Storek 	t ST_SYSCALL; ERROR()
5954382Storek 
6054382Storek #define	ASMSTR		.asciz
6154382Storek 
6254382Storek 	.globl	cerror
63