1 /* $OpenBSD: SYS.h,v 1.1.1.1 2006/10/10 22:07:10 miod Exp $ */ 2 /*- 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * William Jolitz. 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. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 34 * $NetBSD: SYS.h,v 1.9 2006/01/06 06:19:20 uwe Exp $ 35 */ 36 37 #include <machine/asm.h> 38 #include <sys/syscall.h> 39 40 #ifdef __STDC__ 41 #define SYSENTRY(x) \ 42 .weak _C_LABEL(x); \ 43 _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \ 44 ENTRY(_thread_sys_ ## x) 45 #else 46 #define SYSENTRY(x) \ 47 .weak _C_LABEL(x); \ 48 _C_LABEL(x) = _C_LABEL(_thread_sys_/**/x); \ 49 ENTRY(_thread_sys_/**/x) 50 #endif 51 52 #ifdef __STDC__ 53 #define SYSTRAP(x) \ 54 mov.l 903f, r0; \ 55 .word 0xc380; /* trapa #0x80; */ \ 56 bra 904f; \ 57 nop; \ 58 .align 2; \ 59 903: .long (SYS_ ## x); \ 60 904: 61 #else 62 #define SYSTRAP(x) \ 63 mov.l 903f, r0; \ 64 trapa #0x80; \ 65 bra 904f; \ 66 nop; \ 67 .align 2; \ 68 903: .long (SYS_/**/x); \ 69 904: 70 #endif 71 72 #define CERROR _C_LABEL(__cerror) 73 74 #define _SYSCALL_NOERROR(x,y) \ 75 SYSENTRY(x); \ 76 SYSTRAP(y) 77 78 #ifdef PIC 79 80 #define JUMP_CERROR \ 81 mov r0, r4; \ 82 mov.l 912f, r1; \ 83 mova 912f, r0; \ 84 mov.l 913f, r2; \ 85 add r1, r0; \ 86 mov.l @(r0, r2), r3; \ 87 jmp @r3; \ 88 nop; \ 89 .align 2; \ 90 912: .long _GLOBAL_OFFSET_TABLE_; \ 91 913: .long PIC_GOT(CERROR) 92 93 #else /* !PIC */ 94 95 #define JUMP_CERROR \ 96 mov.l 912f, r3; \ 97 jmp @r3; \ 98 mov r0, r4; \ 99 .align 2; \ 100 912: .long CERROR 101 102 #endif /* !PIC */ 103 104 #define _SYSCALL(x,y) \ 105 .text; \ 106 911: JUMP_CERROR; \ 107 _SYSCALL_NOERROR(x,y); \ 108 bf 911b 109 110 #define SYSCALL_NOERROR(x) \ 111 _SYSCALL_NOERROR(x,x) 112 113 #define SYSCALL(x) \ 114 _SYSCALL(x,x) 115 116 #define PSEUDO_NOERROR(x,y) \ 117 _SYSCALL_NOERROR(x,y); \ 118 rts; \ 119 nop 120 121 #define PSEUDO(x,y) \ 122 _SYSCALL(x,y); \ 123 rts; \ 124 nop 125 126 #define RSYSCALL_NOERROR(x) \ 127 PSEUDO_NOERROR(x,x) 128 129 #define RSYSCALL(x) \ 130 PSEUDO(x,x) 131 132 .globl CERROR 133