12fe8fb19SBen Gras /*- 22fe8fb19SBen Gras * Copyright (c) 1990 The Regents of the University of California. 32fe8fb19SBen Gras * All rights reserved. 42fe8fb19SBen Gras * 52fe8fb19SBen Gras * This code is derived from software contributed to Berkeley by 62fe8fb19SBen Gras * William Jolitz. 72fe8fb19SBen Gras * 82fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without 92fe8fb19SBen Gras * modification, are permitted provided that the following conditions 102fe8fb19SBen Gras * are met: 112fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright 122fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer. 132fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 142fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the 152fe8fb19SBen Gras * documentation and/or other materials provided with the distribution. 162fe8fb19SBen Gras * 3. Neither the name of the University nor the names of its contributors 172fe8fb19SBen Gras * may be used to endorse or promote products derived from this software 182fe8fb19SBen Gras * without specific prior written permission. 192fe8fb19SBen Gras * 202fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 212fe8fb19SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 222fe8fb19SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 232fe8fb19SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 242fe8fb19SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 252fe8fb19SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 262fe8fb19SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 272fe8fb19SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 282fe8fb19SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 292fe8fb19SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 302fe8fb19SBen Gras * SUCH DAMAGE. 312fe8fb19SBen Gras * 322fe8fb19SBen Gras * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 33*84d9c625SLionel Sambuc * $NetBSD: SYS.h,v 1.11 2013/09/12 15:36:15 joerg Exp $ 342fe8fb19SBen Gras */ 352fe8fb19SBen Gras 362fe8fb19SBen Gras #include <machine/asm.h> 372fe8fb19SBen Gras #include <sys/syscall.h> 382fe8fb19SBen Gras 392fe8fb19SBen Gras #ifdef __STDC__ 40e415d488SLionel Sambuc #define IMMEDIATE # 412fe8fb19SBen Gras #define SYSTRAP(x) \ 422fe8fb19SBen Gras mov.l 903f, r0; \ 43e415d488SLionel Sambuc trapa IMMEDIATE 0x80; \ 442fe8fb19SBen Gras bra 904f; \ 452fe8fb19SBen Gras nop; \ 462fe8fb19SBen Gras .align 2; \ 472fe8fb19SBen Gras 903: .long (SYS_ ## x); \ 482fe8fb19SBen Gras 904: 492fe8fb19SBen Gras #else 502fe8fb19SBen Gras #define SYSTRAP(x) \ 512fe8fb19SBen Gras mov.l 903f, r0; \ 522fe8fb19SBen Gras trapa #0x80; \ 532fe8fb19SBen Gras bra 904f; \ 542fe8fb19SBen Gras nop; \ 552fe8fb19SBen Gras .align 2; \ 562fe8fb19SBen Gras 903: .long (SYS_/**/x); \ 572fe8fb19SBen Gras 904: 582fe8fb19SBen Gras #endif 592fe8fb19SBen Gras 602fe8fb19SBen Gras #define _SYSCALL_NOERROR(x,y) \ 612fe8fb19SBen Gras ENTRY(x); \ 622fe8fb19SBen Gras SYSTRAP(y) 632fe8fb19SBen Gras 64*84d9c625SLionel Sambuc #ifdef __PIC__ 652fe8fb19SBen Gras 662fe8fb19SBen Gras #define JUMP_CERROR \ 672fe8fb19SBen Gras mov r0, r4; \ 682fe8fb19SBen Gras mov.l 912f, r1; \ 692fe8fb19SBen Gras mova 912f, r0; \ 702fe8fb19SBen Gras mov.l 913f, r2; \ 712fe8fb19SBen Gras add r1, r0; \ 722fe8fb19SBen Gras mov.l @(r0, r2), r3; \ 732fe8fb19SBen Gras jmp @r3; \ 742fe8fb19SBen Gras nop; \ 752fe8fb19SBen Gras .align 2; \ 762fe8fb19SBen Gras 912: .long _GLOBAL_OFFSET_TABLE_; \ 772fe8fb19SBen Gras 913: .long PIC_GOT(cerror) 782fe8fb19SBen Gras 79*84d9c625SLionel Sambuc #else /* !__PIC__ */ 802fe8fb19SBen Gras 812fe8fb19SBen Gras #define JUMP_CERROR \ 822fe8fb19SBen Gras mov.l 912f, r3; \ 832fe8fb19SBen Gras jmp @r3; \ 842fe8fb19SBen Gras mov r0, r4; \ 852fe8fb19SBen Gras .align 2; \ 862fe8fb19SBen Gras 912: .long cerror 872fe8fb19SBen Gras 88*84d9c625SLionel Sambuc #endif /* !__PIC__ */ 892fe8fb19SBen Gras 902fe8fb19SBen Gras #define _SYSCALL(x,y) \ 912fe8fb19SBen Gras .text; \ 922fe8fb19SBen Gras 911: JUMP_CERROR; \ 932fe8fb19SBen Gras _SYSCALL_NOERROR(x,y); \ 942fe8fb19SBen Gras bf 911b 952fe8fb19SBen Gras 962fe8fb19SBen Gras #define SYSCALL_NOERROR(x) \ 972fe8fb19SBen Gras _SYSCALL_NOERROR(x,x) 982fe8fb19SBen Gras 992fe8fb19SBen Gras #define SYSCALL(x) \ 1002fe8fb19SBen Gras _SYSCALL(x,x) 1012fe8fb19SBen Gras 1022fe8fb19SBen Gras #define PSEUDO_NOERROR(x,y) \ 1032fe8fb19SBen Gras _SYSCALL_NOERROR(x,y); \ 1042fe8fb19SBen Gras rts; \ 1052fe8fb19SBen Gras nop 1062fe8fb19SBen Gras 1072fe8fb19SBen Gras #define PSEUDO(x,y) \ 1082fe8fb19SBen Gras _SYSCALL(x,y); \ 1092fe8fb19SBen Gras rts; \ 1102fe8fb19SBen Gras nop 1112fe8fb19SBen Gras 1122fe8fb19SBen Gras #define RSYSCALL_NOERROR(x) \ 1132fe8fb19SBen Gras PSEUDO_NOERROR(x,x) 1142fe8fb19SBen Gras 1152fe8fb19SBen Gras #define RSYSCALL(x) \ 1162fe8fb19SBen Gras PSEUDO(x,x) 1172fe8fb19SBen Gras 1182fe8fb19SBen Gras #ifdef WEAK_ALIAS 1192fe8fb19SBen Gras #define WSYSCALL(weak,strong) \ 1202fe8fb19SBen Gras WEAK_ALIAS(weak,strong); \ 1212fe8fb19SBen Gras PSEUDO(strong,weak) 1222fe8fb19SBen Gras #else 1232fe8fb19SBen Gras #define WSYSCALL(weak,strong) \ 1242fe8fb19SBen Gras PSEUDO(weak,weak) 1252fe8fb19SBen Gras #endif 1262fe8fb19SBen Gras 1272fe8fb19SBen Gras .globl cerror 128