18269e767SBrooks Davis /*- 28269e767SBrooks Davis * Copyright (c) 2014 Andrew Turner 38269e767SBrooks Davis * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com> 48269e767SBrooks Davis * All rights reserved. 58269e767SBrooks Davis * 68269e767SBrooks Davis * Portions of this software were developed by SRI International and the 78269e767SBrooks Davis * University of Cambridge Computer Laboratory under DARPA/AFRL contract 88269e767SBrooks Davis * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. 98269e767SBrooks Davis * 108269e767SBrooks Davis * Portions of this software were developed by the University of Cambridge 118269e767SBrooks Davis * Computer Laboratory as part of the CTSRD Project, with support from the 128269e767SBrooks Davis * UK Higher Education Innovation Fund (HEIF). 138269e767SBrooks Davis * 148269e767SBrooks Davis * Redistribution and use in source and binary forms, with or without 158269e767SBrooks Davis * modification, are permitted provided that the following conditions 168269e767SBrooks Davis * are met: 178269e767SBrooks Davis * 1. Redistributions of source code must retain the above copyright 188269e767SBrooks Davis * notice, this list of conditions and the following disclaimer. 198269e767SBrooks Davis * 2. Redistributions in binary form must reproduce the above copyright 208269e767SBrooks Davis * notice, this list of conditions and the following disclaimer in the 218269e767SBrooks Davis * documentation and/or other materials provided with the distribution. 228269e767SBrooks Davis * 238269e767SBrooks Davis * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 248269e767SBrooks Davis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 258269e767SBrooks Davis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 268269e767SBrooks Davis * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 278269e767SBrooks Davis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 288269e767SBrooks Davis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 298269e767SBrooks Davis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 308269e767SBrooks Davis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 318269e767SBrooks Davis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 328269e767SBrooks Davis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 338269e767SBrooks Davis * SUCH DAMAGE. 348269e767SBrooks Davis */ 358269e767SBrooks Davis 368269e767SBrooks Davis #include <sys/syscall.h> 378269e767SBrooks Davis #include <machine/asm.h> 388269e767SBrooks Davis 398269e767SBrooks Davis #define _SYSCALL(name) \ 408269e767SBrooks Davis li t0, SYS_ ## name; \ 418269e767SBrooks Davis ecall 428269e767SBrooks Davis 43*f2177722SBrooks Davis #ifndef _SYSCALL_BODY 448269e767SBrooks Davis #define _SYSCALL_BODY(name) \ 458269e767SBrooks Davis _SYSCALL(name); \ 468269e767SBrooks Davis bnez t0, 1f; \ 478269e767SBrooks Davis ret; \ 488269e767SBrooks Davis 1: la t1, cerror; \ 498269e767SBrooks Davis jr t1 50*f2177722SBrooks Davis #endif 518269e767SBrooks Davis 528269e767SBrooks Davis #define PSEUDO(name) \ 538269e767SBrooks Davis ENTRY(__sys_##name); \ 548269e767SBrooks Davis WEAK_REFERENCE(__sys_##name, _##name); \ 558269e767SBrooks Davis _SYSCALL_BODY(name); \ 568269e767SBrooks Davis END(__sys_##name) 578269e767SBrooks Davis 588269e767SBrooks Davis #define RSYSCALL(name) \ 598269e767SBrooks Davis ENTRY(__sys_##name); \ 608269e767SBrooks Davis WEAK_REFERENCE(__sys_##name, name); \ 618269e767SBrooks Davis WEAK_REFERENCE(__sys_##name, _##name); \ 628269e767SBrooks Davis _SYSCALL_BODY(name); \ 638269e767SBrooks Davis END(__sys_##name) 64