1 /*- 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)SYS.h 5.2 (Berkeley) 06/25/92 12 */ 13 14 #include <sys/syscall.h> 15 #include <machine/trap.h> 16 17 #ifdef PROF 18 #define ENTRY(x) \ 19 .align 4; .globl _##x; .proc 1; _##x:; .data; .align 4; 1: .long 0; \ 20 .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \ 21 or %o0,%lo(1b),%o0; restore 22 #else 23 #define ENTRY(x) \ 24 .align 4; .globl _##x; .proc 1; _##x: 25 #endif 26 27 /* 28 * ERROR branches to cerror. This is done with a macro so that I can 29 * change it to be position independent later, if need be. 30 */ 31 #define ERROR() \ 32 sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop 33 34 /* 35 * SYSCALL is used when further action must be taken before returning. 36 * Note that it adds a `nop' over what we could do, if we only knew what 37 * came at label 1.... 38 */ 39 #define SYSCALL(x) \ 40 ENTRY(x); mov SYS_##x,%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: 41 42 /* 43 * RSYSCALL is used when the system call should just return. Here 44 * we use the SYSCALL_RFLAG to put the `success' return address in %g7 45 * and avoid a branch. 46 */ 47 #define RSYSCALL(x) \ 48 ENTRY(x); mov (SYS_##x)|SYSCALL_RFLAG,%g1; add %o7,8,%g7; \ 49 t ST_SYSCALL; ERROR() 50 51 /* 52 * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x. 53 */ 54 #define PSEUDO(x,y) \ 55 ENTRY(x); mov (SYS_##y)|SYSCALL_RFLAG,%g1; add %o7,8,%g7; \ 56 t ST_SYSCALL; ERROR() 57 58 #define ASMSTR .asciz 59 60 .globl cerror 61