1 /* $NetBSD: SYS.h,v 1.12 2020/05/05 20:43:47 skrll Exp $ */ 2 3 /* $OpenBSD: SYS.h,v 1.9 2001/09/20 20:52:09 millert Exp $ */ 4 5 /* 6 * Copyright (c) 1998-2002 Michael Shalayeff 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND 24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #include <sys/syscall.h> 31 #include <machine/asm.h> 32 #include <machine/vmparam.h> 33 #include <machine/frame.h> 34 35 #define SYSENTRY(x) LEAF_ENTRY(x) 36 #define SYSEXIT(x) EXIT(x) 37 38 /* 39 * The restore of rp in the branch to __cerror delay slot is required 40 */ 41 #define SYSCALL(x) !\ 42 stw %rp, HPPA_FRAME_ERP(%sr0,%sp) !\ 43 ldil L%SYSCALLGATE, %r1 !\ 44 ble 4(%sr2, %r1) !\ 45 ldi __CONCAT(SYS_,x), %t1 !\ 46 comb,=,n %r0, %t1, 1f !\ 47 b __cerror !\ 48 1: !\ 49 ldw HPPA_FRAME_ERP(%sr0,%sp), %rp 50 51 #define PSEUDO(x,y) !\ 52 SYSENTRY(x) !\ 53 SYSCALL(y) !\ 54 bv %r0(%rp) !\ 55 nop !\ 56 SYSEXIT(x) 57 58 #define PSEUDO_NOERROR(x,y) !\ 59 SYSENTRY(x) !\ 60 stw %rp, HPPA_FRAME_ERP(%sr0,%sp) !\ 61 ldil L%SYSCALLGATE, %r1 !\ 62 ble 4(%sr2, %r1) !\ 63 ldi __CONCAT(SYS_,y), %t1 !\ 64 ldw HPPA_FRAME_ERP(%sr0,%sp), %rp !\ 65 bv %r0(%rp) !\ 66 nop !\ 67 SYSEXIT(x) 68 69 #define RSYSCALL(x) PSEUDO(x,x) 70 #define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x) 71 72 #ifdef WEAK_ALIAS 73 #define WSYSCALL(weak,strong) !\ 74 WEAK_ALIAS(weak,strong) !\ 75 PSEUDO(strong,weak) 76 #else 77 #define WSYSCALL(weak,strong) !\ 78 PSEUDO(weak,weak) 79 #endif 80 81 .global __cerror 82 .hidden __cerror 83 .import __cerror, code 84