1 /* $OpenBSD: SYS.h,v 1.9 2002/10/06 23:23:18 art Exp $ */ 2 /* $NetBSD: SYS.h,v 1.4 1996/10/17 03:03:53 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 6 * All rights reserved. 7 * 8 * Author: Chris G. Demetriou 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 */ 30 31 #include <machine/asm.h> 32 #include <sys/syscall.h> 33 34 35 #define CALLSYS_ERROR(name) \ 36 CALLSYS_NOERROR(name); \ 37 br gp, LLABEL(name,0); \ 38 LLABEL(name,0): \ 39 LDGP(gp); \ 40 beq a3, LLABEL(name,1); \ 41 jmp zero, __cerror; \ 42 LLABEL(name,1): 43 44 #define __LEAF(p,n,e) \ 45 LEAF(___CONCAT(p,n),e) 46 #define __END(p,n) \ 47 END(___CONCAT(p,n)) 48 49 #define __SYSCALL(p,name) \ 50 __LEAF(p,name,0); /* XXX # of args? */ \ 51 CALLSYS_ERROR(name) 52 53 #define __SYSCALL_NOERROR(p,name) \ 54 __LEAF(p,name,0); /* XXX # of args? */ \ 55 CALLSYS_NOERROR(name) 56 57 58 #define __RSYSCALL(p,name) \ 59 __SYSCALL(p,name); \ 60 RET; \ 61 __END(p,name) 62 63 #define __RSYSCALL_NOERROR(p,name) \ 64 __SYSCALL_NOERROR(p,name); \ 65 RET; \ 66 __END(p,name) 67 68 69 #define __PSEUDO(p,label,name) \ 70 __LEAF(p,label,0); /* XXX # of args? */ \ 71 CALLSYS_ERROR(name); \ 72 RET; \ 73 __END(p,label); 74 75 #define __PSEUDO_NOERROR(p,label,name) \ 76 __LEAF(p,label,0); /* XXX # of args? */ \ 77 CALLSYS_NOERROR(name); \ 78 RET; \ 79 __END(p,label); 80 81 #define ALIAS(prefix,name) WEAK_ALIAS(name, ___CONCAT(prefix,name)); 82 83 /* 84 * For the thread_safe versions, we prepend _thread_sys_ to the function 85 * name so that the 'C' wrapper can go around the real name. 86 */ 87 # define SYSCALL(x) ALIAS(_thread_sys_,x) \ 88 __SYSCALL(_thread_sys_,x) 89 # define SYSCALL_NOERROR(x) ALIAS(_thread_sys_,x) \ 90 __SYSCALL_NOERROR(_thread_sys_,x) 91 # define RSYSCALL(x) ALIAS(_thread_sys_,x) \ 92 __RSYSCALL(_thread_sys_,x) 93 # define RSYSCALL_NOERROR(x) ALIAS(_thread_sys_,x) \ 94 __RSYSCALL_NOERROR(_thread_sys_,x) 95 # define PSEUDO(x,y) ALIAS(_thread_sys_,x) \ 96 __PSEUDO(_thread_sys_,x,y) 97 # define PSEUDO_NOERROR(x,y) ALIAS(_thread_sys_,x) \ 98 __PSEUDO_NOERROR(_thread_sys_,x,y) 99 # define SYSLEAF(x,e) ALIAS(_thread_sys_,x) \ 100 __LEAF(_thread_sys_,x,e) 101 # define SYSEND(x) __END(_thread_sys_,x) 102