1 1.1 cgd /*- 2 1.1 cgd * Copyright (c) 1992, 1993 3 1.1 cgd * The Regents of the University of California. All rights reserved. 4 1.1 cgd * 5 1.1 cgd * This software was developed by the Computer Systems Engineering group 6 1.1 cgd * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 1.1 cgd * contributed to Berkeley. 8 1.1 cgd * 9 1.1 cgd * Redistribution and use in source and binary forms, with or without 10 1.1 cgd * modification, are permitted provided that the following conditions 11 1.1 cgd * are met: 12 1.1 cgd * 1. Redistributions of source code must retain the above copyright 13 1.1 cgd * notice, this list of conditions and the following disclaimer. 14 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright 15 1.1 cgd * notice, this list of conditions and the following disclaimer in the 16 1.1 cgd * documentation and/or other materials provided with the distribution. 17 1.15 agc * 3. Neither the name of the University nor the names of its contributors 18 1.1 cgd * may be used to endorse or promote products derived from this software 19 1.1 cgd * without specific prior written permission. 20 1.1 cgd * 21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 1.1 cgd * SUCH DAMAGE. 32 1.1 cgd * 33 1.1 cgd * @(#)SYS.h 8.1 (Berkeley) 6/4/93 34 1.1 cgd * 35 1.1 cgd * from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp 36 1.19 joerg * $NetBSD: SYS.h,v 1.19 2013/09/12 15:36:16 joerg Exp $ 37 1.1 cgd */ 38 1.1 cgd 39 1.3 pk #include <machine/asm.h> 40 1.1 cgd #include <sys/syscall.h> 41 1.1 cgd #include <machine/trap.h> 42 1.1 cgd 43 1.14 wiz #ifdef __STDC__ 44 1.2 pk #define _CAT(x,y) x##y 45 1.14 wiz #else 46 1.14 wiz #define _CAT(x,y) x/**/y 47 1.14 wiz #endif 48 1.2 pk 49 1.9 kleink #ifdef __ELF__ 50 1.9 kleink #define CERROR _C_LABEL(__cerror) 51 1.9 kleink #define CURBRK _C_LABEL(__curbrk) 52 1.9 kleink #else 53 1.9 kleink #define CERROR _ASM_LABEL(cerror) 54 1.9 kleink #define CURBRK _ASM_LABEL(curbrk) 55 1.9 kleink #endif 56 1.9 kleink 57 1.1 cgd /* 58 1.16 uwe * ERROR branches to cerror. 59 1.1 cgd */ 60 1.19 joerg #ifdef __PIC__ 61 1.16 uwe #define CALL(name) \ 62 1.18 martin PIC_PROLOGUE(%g1, %g5); \ 63 1.18 martin set name, %g5; \ 64 1.18 martin ld [%g1 + %g5], %g5; \ 65 1.18 martin jmp %g5; \ 66 1.16 uwe nop 67 1.3 pk #else 68 1.16 uwe #define CALL(name) \ 69 1.16 uwe set name, %g1; \ 70 1.16 uwe jmp %g1; \ 71 1.16 uwe nop 72 1.3 pk #endif 73 1.11 christos #define ERROR() CALL(CERROR) 74 1.1 cgd 75 1.1 cgd /* 76 1.1 cgd * SYSCALL is used when further action must be taken before returning. 77 1.16 uwe * Note that it adds a `nop' over what we could do, if we only knew 78 1.16 uwe * what came at label 1.... 79 1.1 cgd */ 80 1.16 uwe #define _SYSCALL(x,y) \ 81 1.16 uwe ENTRY(x); \ 82 1.16 uwe mov _CAT(SYS_,y), %g1; \ 83 1.16 uwe t ST_SYSCALL; \ 84 1.16 uwe bcc 1f; \ 85 1.16 uwe nop; \ 86 1.16 uwe ERROR(); \ 87 1.16 uwe 1: /* next insn */ 88 1.10 kleink 89 1.16 uwe #define SYSCALL(x) \ 90 1.10 kleink _SYSCALL(x,x) 91 1.1 cgd 92 1.1 cgd /* 93 1.16 uwe * RSYSCALL is used when the system call should just return. Here we 94 1.18 martin * use the SYSCALL_G5RFLAG to put the `success' return address in %g5 95 1.1 cgd * and avoid a branch. 96 1.16 uwe * 97 1.16 uwe * PSEUDO(x,y) is like RSYSCALL(y), except that the name is x. 98 1.1 cgd */ 99 1.16 uwe #define _RSYSCALL(x,y) \ 100 1.16 uwe ENTRY(x); \ 101 1.18 martin mov (_CAT(SYS_,y)) | SYSCALL_G5RFLAG, %g1; \ 102 1.18 martin add %o7, 8, %g5; \ 103 1.16 uwe t ST_SYSCALL; \ 104 1.16 uwe ERROR() 105 1.1 cgd 106 1.16 uwe #define RSYSCALL(x) _RSYSCALL(x,x) 107 1.16 uwe #define PSEUDO(x,y) _RSYSCALL(x,y) 108 1.12 thorpej 109 1.12 thorpej /* 110 1.16 uwe * WSYSCALL(weak,strong) is like RSYSCALL(weak), 111 1.16 uwe * except that weak is a weak internal alias for the strong symbol. 112 1.12 thorpej */ 113 1.12 thorpej #ifdef WEAK_ALIAS 114 1.16 uwe #define WSYSCALL(weak,strong) \ 115 1.16 uwe WEAK_ALIAS(weak,strong); \ 116 1.12 thorpej PSEUDO(strong,weak) 117 1.12 thorpej #else 118 1.16 uwe #define WSYSCALL(weak,strong) \ 119 1.12 thorpej RSYSCALL(weak) 120 1.12 thorpej #endif 121 1.4 jtc 122 1.4 jtc /* 123 1.16 uwe * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls that 124 1.16 uwe * never fail. 125 1.4 jtc * 126 1.4 jtc * XXX - This should be optimized. 127 1.4 jtc */ 128 1.16 uwe #define SYSCALL_NOERROR(x) \ 129 1.16 uwe ENTRY(x); \ 130 1.16 uwe mov _CAT(SYS_,x), %g1; \ 131 1.16 uwe t ST_SYSCALL 132 1.4 jtc 133 1.4 jtc /* 134 1.16 uwe * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls 135 1.4 jtc * that never fail. 136 1.4 jtc * 137 1.16 uwe * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y), except that the 138 1.16 uwe * name is x. 139 1.16 uwe * 140 1.4 jtc * XXX - This should be optimized. 141 1.4 jtc */ 142 1.16 uwe #define _RSYSCALL_NOERROR(x,y) \ 143 1.16 uwe ENTRY(x); \ 144 1.18 martin mov (_CAT(SYS_,y)) | SYSCALL_G5RFLAG, %g1; \ 145 1.18 martin add %o7, 8, %g5; \ 146 1.16 uwe t ST_SYSCALL 147 1.7 kleink 148 1.16 uwe #define RSYSCALL_NOERROR(x) _RSYSCALL_NOERROR(x,x) 149 1.16 uwe #define PSEUDO_NOERROR(x,y) _RSYSCALL_NOERROR(x,y) 150 1.1 cgd 151 1.9 kleink .globl CERROR 152