SYS.h revision 1.1
11.1Sfredette/* $NetBSD: SYS.h,v 1.1 2002/06/06 20:31:20 fredette Exp $ */ 21.1Sfredette 31.1Sfredette/* $OpenBSD: SYS.h,v 1.9 2001/09/20 20:52:09 millert Exp $ */ 41.1Sfredette 51.1Sfredette/* 61.1Sfredette * Copyright (c) 1998-1999 Michael Shalayeff 71.1Sfredette * All rights reserved. 81.1Sfredette * 91.1Sfredette * Redistribution and use in source and binary forms, with or without 101.1Sfredette * modification, are permitted provided that the following conditions 111.1Sfredette * are met: 121.1Sfredette * 1. Redistributions of source code must retain the above copyright 131.1Sfredette * notice, this list of conditions and the following disclaimer. 141.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright 151.1Sfredette * notice, this list of conditions and the following disclaimer in the 161.1Sfredette * documentation and/or other materials provided with the distribution. 171.1Sfredette * 3. All advertising materials mentioning features or use of this software 181.1Sfredette * must display the following acknowledgement: 191.1Sfredette * This product includes software developed by Michael Shalayeff. 201.1Sfredette * 4. The name of the author may not be used to endorse or promote products 211.1Sfredette * derived from this software without specific prior written permission. 221.1Sfredette * 231.1Sfredette * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 241.1Sfredette * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 251.1Sfredette * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 261.1Sfredette * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 271.1Sfredette * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 281.1Sfredette * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND 291.1Sfredette * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 301.1Sfredette * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 311.1Sfredette * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 321.1Sfredette * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 331.1Sfredette */ 341.1Sfredette 351.1Sfredette#include <sys/syscall.h> 361.1Sfredette#include <machine/asm.h> 371.1Sfredette#include <machine/vmparam.h> 381.1Sfredette#undef _LOCORE 391.1Sfredette#define _LOCORE 401.1Sfredette#include <machine/frame.h> 411.1Sfredette 421.1Sfredette#define __ENTRY(p,x) ENTRY(__CONCAT(p,x),0) 431.1Sfredette#define __EXIT(p,x) EXIT(__CONCAT(p,x)) 441.1Sfredette 451.1Sfredette#define __SYSCALL_NOERROR(p,x) !\ 461.1Sfredette stw rp, HPPA_FRAME_ERP(sr0,sp) !\ 471.1Sfredette ldil L%SYSCALLGATE, r1 !\ 481.1Sfredette ble 4(sr7, r1) !\ 491.1Sfredette ldi __CONCAT(SYS_,x), t1 !\ 501.1Sfredette ldw HPPA_FRAME_ERP(sr0,sp), rp 511.1Sfredette 521.1Sfredette#define __SYSCALL(p,x) !\ 531.1Sfredette .import errno, data !\ 541.1Sfredette __SYSCALL_NOERROR(p,x) !\ 551.1Sfredette comb,=,n r0, t1, __CONCAT(x,$noerr) !\ 561.1Sfredette ldil L%errno, r1 !\ 571.1Sfredette stw t1, R%errno(r1) !\ 581.1Sfredette ldi -1, ret0 !\ 591.1Sfredette bv r0(rp) !\ 601.1Sfredette ldi -1, ret1 !\ 611.1Sfredette .label __CONCAT(x,$noerr) 621.1Sfredette 631.1Sfredette#define __RSYSCALL(p,x) !\ 641.1Sfredette__ENTRY(p,x) !\ 651.1Sfredette __SYSCALL(p,x) !\ 661.1Sfredette bv r0(rp) !\ 671.1Sfredette nop !\ 681.1Sfredette__EXIT(p,x) 691.1Sfredette 701.1Sfredette#define __RSYSCALL_NOERROR(p,x) !\ 711.1Sfredette__ENTRY(p,x) !\ 721.1Sfredette __SYSCALL_NOERROR(p,x) !\ 731.1Sfredette bv r0(rp) !\ 741.1Sfredette nop !\ 751.1Sfredette__EXIT(p,x) 761.1Sfredette 771.1Sfredette#define __PSEUDO(p,x,y) !\ 781.1Sfredette__ENTRY(p,x) !\ 791.1Sfredette __SYSCALL(p,y) !\ 801.1Sfredette bv r0(rp) !\ 811.1Sfredette nop !\ 821.1Sfredette__EXIT(p,x) 831.1Sfredette 841.1Sfredette#define __PSEUDO_NOERROR(p,x,y) !\ 851.1Sfredette__ENTRY(p,x) !\ 861.1Sfredette __SYSCALL_NOERROR(p,y) !\ 871.1Sfredette bv r0(rp) !\ 881.1Sfredette nop !\ 891.1Sfredette__EXIT(p,x) 901.1Sfredette 911.1Sfredette#ifdef WEAK_ALIAS 921.1Sfredette#define WSYSCALL(weak,strong) !\ 931.1Sfredette WEAK_ALIAS(weak,strong) !\ 941.1Sfredette PSEUDO(strong,weak) 951.1Sfredette#else 961.1Sfredette#define WSYSCALL(weak,strong) !\ 971.1Sfredette PSEUDO(weak,weak) 981.1Sfredette#endif 991.1Sfredette 1001.1Sfredette/* 1011.1Sfredette * Design note: 1021.1Sfredette * 1031.1Sfredette * When the syscalls need to be renamed so they can be handled 1041.1Sfredette * specially by the threaded library, these macros insert `_thread_sys_' 1051.1Sfredette * in front of their name. This avoids the need to #ifdef _THREAD_SAFE 1061.1Sfredette * everywhere that the renamed function needs to be called. 1071.1Sfredette */ 1081.1Sfredette#ifdef _THREAD_SAFE 1091.1Sfredette/* 1101.1Sfredette * For the thread_safe versions, we prepend _thread_sys_ to the function 1111.1Sfredette * name so that the 'C' wrapper can go around the real name. 1121.1Sfredette */ 1131.1Sfredette# define SYSCALL(x) __SYSCALL(_thread_sys_,x) 1141.1Sfredette# define RSYSCALL(x) __RSYSCALL(_thread_sys_,x) 1151.1Sfredette# define RSYSCALL_NOERROR(x) __RSYSCALL_NOERROR(_thread_sys_,x) 1161.1Sfredette# define PSEUDO(x,y) __PSEUDO(_thread_sys_,x,y) 1171.1Sfredette# define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(_thread_sys_,x,y) 1181.1Sfredette/*# define SYSENTRY(x) __ENTRY(_thread_sys_,x)*/ 1191.1Sfredette#else /* _THREAD_SAFE */ 1201.1Sfredette/* 1211.1Sfredette * The non-threaded library defaults to traditional syscalls where 1221.1Sfredette * the function name matches the syscall name. 1231.1Sfredette */ 1241.1Sfredette# define SYSCALL(x) __SYSCALL(,x) 1251.1Sfredette# define RSYSCALL(x) __RSYSCALL(,x) 1261.1Sfredette# define RSYSCALL_NOERROR(x) __RSYSCALL_NOERROR(,x) 1271.1Sfredette# define PSEUDO(x,y) __PSEUDO(,x,y) 1281.1Sfredette# define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(,x,y) 1291.1Sfredette/*# define SYSENTRY(x) __ENTRY(,x)*/ 1301.1Sfredette#endif /* _THREAD_SAFE */ 131