SYS.h revision 1.1
1/* $NetBSD: SYS.h,v 1.1 2002/06/06 20:31:20 fredette Exp $ */ 2 3/* $OpenBSD: SYS.h,v 1.9 2001/09/20 20:52:09 millert Exp $ */ 4 5/* 6 * Copyright (c) 1998-1999 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 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Michael Shalayeff. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND 29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35#include <sys/syscall.h> 36#include <machine/asm.h> 37#include <machine/vmparam.h> 38#undef _LOCORE 39#define _LOCORE 40#include <machine/frame.h> 41 42#define __ENTRY(p,x) ENTRY(__CONCAT(p,x),0) 43#define __EXIT(p,x) EXIT(__CONCAT(p,x)) 44 45#define __SYSCALL_NOERROR(p,x) !\ 46 stw rp, HPPA_FRAME_ERP(sr0,sp) !\ 47 ldil L%SYSCALLGATE, r1 !\ 48 ble 4(sr7, r1) !\ 49 ldi __CONCAT(SYS_,x), t1 !\ 50 ldw HPPA_FRAME_ERP(sr0,sp), rp 51 52#define __SYSCALL(p,x) !\ 53 .import errno, data !\ 54 __SYSCALL_NOERROR(p,x) !\ 55 comb,=,n r0, t1, __CONCAT(x,$noerr) !\ 56 ldil L%errno, r1 !\ 57 stw t1, R%errno(r1) !\ 58 ldi -1, ret0 !\ 59 bv r0(rp) !\ 60 ldi -1, ret1 !\ 61 .label __CONCAT(x,$noerr) 62 63#define __RSYSCALL(p,x) !\ 64__ENTRY(p,x) !\ 65 __SYSCALL(p,x) !\ 66 bv r0(rp) !\ 67 nop !\ 68__EXIT(p,x) 69 70#define __RSYSCALL_NOERROR(p,x) !\ 71__ENTRY(p,x) !\ 72 __SYSCALL_NOERROR(p,x) !\ 73 bv r0(rp) !\ 74 nop !\ 75__EXIT(p,x) 76 77#define __PSEUDO(p,x,y) !\ 78__ENTRY(p,x) !\ 79 __SYSCALL(p,y) !\ 80 bv r0(rp) !\ 81 nop !\ 82__EXIT(p,x) 83 84#define __PSEUDO_NOERROR(p,x,y) !\ 85__ENTRY(p,x) !\ 86 __SYSCALL_NOERROR(p,y) !\ 87 bv r0(rp) !\ 88 nop !\ 89__EXIT(p,x) 90 91#ifdef WEAK_ALIAS 92#define WSYSCALL(weak,strong) !\ 93 WEAK_ALIAS(weak,strong) !\ 94 PSEUDO(strong,weak) 95#else 96#define WSYSCALL(weak,strong) !\ 97 PSEUDO(weak,weak) 98#endif 99 100/* 101 * Design note: 102 * 103 * When the syscalls need to be renamed so they can be handled 104 * specially by the threaded library, these macros insert `_thread_sys_' 105 * in front of their name. This avoids the need to #ifdef _THREAD_SAFE 106 * everywhere that the renamed function needs to be called. 107 */ 108#ifdef _THREAD_SAFE 109/* 110 * For the thread_safe versions, we prepend _thread_sys_ to the function 111 * name so that the 'C' wrapper can go around the real name. 112 */ 113# define SYSCALL(x) __SYSCALL(_thread_sys_,x) 114# define RSYSCALL(x) __RSYSCALL(_thread_sys_,x) 115# define RSYSCALL_NOERROR(x) __RSYSCALL_NOERROR(_thread_sys_,x) 116# define PSEUDO(x,y) __PSEUDO(_thread_sys_,x,y) 117# define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(_thread_sys_,x,y) 118/*# define SYSENTRY(x) __ENTRY(_thread_sys_,x)*/ 119#else /* _THREAD_SAFE */ 120/* 121 * The non-threaded library defaults to traditional syscalls where 122 * the function name matches the syscall name. 123 */ 124# define SYSCALL(x) __SYSCALL(,x) 125# define RSYSCALL(x) __RSYSCALL(,x) 126# define RSYSCALL_NOERROR(x) __RSYSCALL_NOERROR(,x) 127# define PSEUDO(x,y) __PSEUDO(,x,y) 128# define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(,x,y) 129/*# define SYSENTRY(x) __ENTRY(,x)*/ 130#endif /* _THREAD_SAFE */ 131