SYS.h revision 1.2
11.2Sfredette/* $NetBSD: SYS.h,v 1.2 2002/07/01 16:00:50 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.2Sfredette#ifdef PIC 531.2Sfredette#define __SYSCALL_ERRNO !\ 541.2Sfredette addil LT%errno, %r19 !\ 551.2Sfredette ldw RT%errno(%r1), %r1 !\ 561.2Sfredette stw t1, 0(%r1) 571.2Sfredette#else 581.2Sfredette#define __SYSCALL_ERRNO !\ 591.2Sfredette ldil L%errno, %r1 !\ 601.2Sfredette stw t1, R%errno(%r1) 611.2Sfredette#endif 621.2Sfredette 631.1Sfredette#define __SYSCALL(p,x) !\ 641.1Sfredette .import errno, data !\ 651.1Sfredette __SYSCALL_NOERROR(p,x) !\ 661.1Sfredette comb,=,n r0, t1, __CONCAT(x,$noerr) !\ 671.2Sfredette __SYSCALL_ERRNO !\ 681.1Sfredette ldi -1, ret0 !\ 691.1Sfredette bv r0(rp) !\ 701.1Sfredette ldi -1, ret1 !\ 711.1Sfredette .label __CONCAT(x,$noerr) 721.1Sfredette 731.1Sfredette#define __RSYSCALL(p,x) !\ 741.1Sfredette__ENTRY(p,x) !\ 751.1Sfredette __SYSCALL(p,x) !\ 761.1Sfredette bv r0(rp) !\ 771.1Sfredette nop !\ 781.1Sfredette__EXIT(p,x) 791.1Sfredette 801.1Sfredette#define __RSYSCALL_NOERROR(p,x) !\ 811.1Sfredette__ENTRY(p,x) !\ 821.1Sfredette __SYSCALL_NOERROR(p,x) !\ 831.1Sfredette bv r0(rp) !\ 841.1Sfredette nop !\ 851.1Sfredette__EXIT(p,x) 861.1Sfredette 871.1Sfredette#define __PSEUDO(p,x,y) !\ 881.1Sfredette__ENTRY(p,x) !\ 891.1Sfredette __SYSCALL(p,y) !\ 901.1Sfredette bv r0(rp) !\ 911.1Sfredette nop !\ 921.1Sfredette__EXIT(p,x) 931.1Sfredette 941.1Sfredette#define __PSEUDO_NOERROR(p,x,y) !\ 951.1Sfredette__ENTRY(p,x) !\ 961.1Sfredette __SYSCALL_NOERROR(p,y) !\ 971.1Sfredette bv r0(rp) !\ 981.1Sfredette nop !\ 991.1Sfredette__EXIT(p,x) 1001.1Sfredette 1011.1Sfredette#ifdef WEAK_ALIAS 1021.1Sfredette#define WSYSCALL(weak,strong) !\ 1031.1Sfredette WEAK_ALIAS(weak,strong) !\ 1041.1Sfredette PSEUDO(strong,weak) 1051.1Sfredette#else 1061.1Sfredette#define WSYSCALL(weak,strong) !\ 1071.1Sfredette PSEUDO(weak,weak) 1081.1Sfredette#endif 1091.1Sfredette 1101.1Sfredette/* 1111.1Sfredette * Design note: 1121.1Sfredette * 1131.1Sfredette * When the syscalls need to be renamed so they can be handled 1141.1Sfredette * specially by the threaded library, these macros insert `_thread_sys_' 1151.1Sfredette * in front of their name. This avoids the need to #ifdef _THREAD_SAFE 1161.1Sfredette * everywhere that the renamed function needs to be called. 1171.1Sfredette */ 1181.1Sfredette#ifdef _THREAD_SAFE 1191.1Sfredette/* 1201.1Sfredette * For the thread_safe versions, we prepend _thread_sys_ to the function 1211.1Sfredette * name so that the 'C' wrapper can go around the real name. 1221.1Sfredette */ 1231.1Sfredette# define SYSCALL(x) __SYSCALL(_thread_sys_,x) 1241.1Sfredette# define RSYSCALL(x) __RSYSCALL(_thread_sys_,x) 1251.1Sfredette# define RSYSCALL_NOERROR(x) __RSYSCALL_NOERROR(_thread_sys_,x) 1261.1Sfredette# define PSEUDO(x,y) __PSEUDO(_thread_sys_,x,y) 1271.1Sfredette# define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(_thread_sys_,x,y) 1281.1Sfredette/*# define SYSENTRY(x) __ENTRY(_thread_sys_,x)*/ 1291.1Sfredette#else /* _THREAD_SAFE */ 1301.1Sfredette/* 1311.1Sfredette * The non-threaded library defaults to traditional syscalls where 1321.1Sfredette * the function name matches the syscall name. 1331.1Sfredette */ 1341.1Sfredette# define SYSCALL(x) __SYSCALL(,x) 1351.1Sfredette# define RSYSCALL(x) __RSYSCALL(,x) 1361.1Sfredette# define RSYSCALL_NOERROR(x) __RSYSCALL_NOERROR(,x) 1371.1Sfredette# define PSEUDO(x,y) __PSEUDO(,x,y) 1381.1Sfredette# define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(,x,y) 1391.1Sfredette/*# define SYSENTRY(x) __ENTRY(,x)*/ 1401.1Sfredette#endif /* _THREAD_SAFE */ 141