1 /* $OpenBSD: SYS.h,v 1.2 2001/08/20 20:15:29 jason Exp $ */ 2 /* $NetBSD: SYS.h,v 1.2 1999/02/15 04:54:36 hubertf Exp $ */ 3 /*- 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This software was developed by the Computer Systems Engineering group 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9 * contributed to Berkeley. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)SYS.h 8.1 (Berkeley) 6/4/93 40 * 41 * from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp 42 * $Id: SYS.h,v 1.2 2001/08/20 20:15:29 jason Exp $ 43 */ 44 45 #include <machine/asm.h> 46 #include <sys/syscall.h> 47 #include <machine/trap.h> 48 49 #ifdef __STDC__ 50 #define _CAT(x,y) x##y 51 #else 52 #define _CAT(x,y) x/**/y 53 #endif 54 55 /* 56 * ERROR branches to cerror. This is done with a macro so that I can 57 * change it to be position independent later, if need be. 58 */ 59 #ifdef PIC 60 #define ERROR() \ 61 PIC_PROLOGUE(%g1,%g2); \ 62 ld [%g1+cerror],%g2; jmp %g2; nop 63 #else 64 #define ERROR() \ 65 sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop 66 #endif 67 68 /* 69 * SYSCALL is used when further action must be taken before returning. 70 * Note that it adds a `nop' over what we could do, if we only knew what 71 * came at label 1.... 72 */ 73 #define SYSCALL(x) \ 74 ENTRY(x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: 75 76 /* 77 * RSYSCALL is used when the system call should just return. Here 78 * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2 79 * and avoid a branch. 80 */ 81 #define RSYSCALL(x) \ 82 ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ 83 t ST_SYSCALL; ERROR() 84 85 /* 86 * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x. 87 */ 88 #define PSEUDO(x,y) \ 89 ENTRY(x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ 90 t ST_SYSCALL; ERROR() 91 92 /* 93 * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls 94 * that never fail. 95 * 96 * XXX - This should be optimized. 97 */ 98 #define SYSCALL_NOERROR(x) \ 99 ENTRY(x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL 100 101 /* 102 * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls 103 * that never fail. 104 * 105 * XXX - This should be optimized. 106 */ 107 #define RSYSCALL_NOERROR(x) \ 108 ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ 109 t ST_SYSCALL 110 111 .globl cerror 112