1 /* $OpenBSD: SYS.h,v 1.27 2023/12/13 09:01:25 miod Exp $ */ 2 3 /* 4 * Copyright (c) 1998-2002 Michael Shalayeff 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND 22 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include <sys/syscall.h> 29 #include "DEFS.h" 30 #undef _LOCORE 31 #define _LOCORE 32 #include <machine/frame.h> 33 #include <machine/vmparam.h> 34 #undef _LOCORE 35 36 /* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */ 37 #define TCB_OFFSET_ERRNO -8 38 39 /* 40 * For functions implemented in ASM that aren't syscalls. 41 * EXIT_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names 42 * EXIT_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names 43 */ 44 #define EXIT_STRONG(x) EXIT(x) !\ 45 _HIDDEN_FALIAS(x,x) !\ 46 _END(_HIDDEN(x)) 47 #define EXIT_WEAK(x) EXIT_STRONG(x) !\ 48 .weak x 49 50 #define SYSENTRY(x) !\ 51 LEAF_ENTRY(__CONCAT(_thread_sys_,x)) !\ 52 WEAK_ALIAS(x,__CONCAT(_thread_sys_,x)) 53 #define SYSENTRY_HIDDEN(x) !\ 54 LEAF_ENTRY(__CONCAT(_thread_sys_,x)) 55 #define SYSEXIT(x) !\ 56 SYSEXIT_HIDDEN(x) !\ 57 _END(x) 58 #define SYSEXIT_HIDDEN(x) !\ 59 EXIT(__CONCAT(_thread_sys_,x)) !\ 60 _HIDDEN_FALIAS(x,_thread_sys_##x) !\ 61 _END(_HIDDEN(x)) 62 63 #define SYSCALL(x) !\ 64 stw rp, HPPA_FRAME_ERP(sr0,sp) !\ 65 ldil L%SYSCALLGATE, r1 !\ 66 97: ble 4(sr7, r1) !\ 67 PINSYSCALL(__CONCAT(SYS_,x), 97b) !\ 68 ldi __CONCAT(SYS_,x), t1 !\ 69 comb,= 0, t1, 1f !\ 70 ldw HPPA_FRAME_ERP(sr0,sp), rp !\ 71 /* set errno */ \ 72 mfctl cr27, r1 !\ 73 stw t1, TCB_OFFSET_ERRNO(r1) !\ 74 ldi -1, ret0 !\ 75 bv r0(rp) !\ 76 ldi -1, ret1 /* for lseek */ !\ 77 1: 78 79 #define PSEUDO(x,y) !\ 80 SYSENTRY(x) !\ 81 SYSCALL(y) !\ 82 bv r0(rp) !\ 83 nop !\ 84 SYSEXIT(x) 85 #define PSEUDO_HIDDEN(x,y) !\ 86 SYSENTRY_HIDDEN(x) !\ 87 SYSCALL(y) !\ 88 bv r0(rp) !\ 89 nop !\ 90 SYSEXIT_HIDDEN(x) 91 92 #define PSEUDO_NOERROR(x,y) !\ 93 SYSENTRY(x) !\ 94 stw rp, HPPA_FRAME_ERP(sr0,sp) !\ 95 ldil L%SYSCALLGATE, r1 !\ 96 97: ble 4(sr7, r1) !\ 97 PINSYSCALL(__CONCAT(SYS_,y), 97b) !\ 98 ldi __CONCAT(SYS_,y), t1 !\ 99 ldw HPPA_FRAME_ERP(sr0,sp), rp !\ 100 bv r0(rp) !\ 101 nop !\ 102 SYSEXIT(x) 103 104 #define RSYSCALL(x) PSEUDO(x,x) 105 #define RSYSCALL_HIDDEN(x) PSEUDO_HIDDEN(x,x) 106