18d7e7a98SRuslan Bukin /*- 2157654d0SRuslan Bukin * Copyright (c) 2015-2018 Ruslan Bukin <br@bsdpad.com> 38d7e7a98SRuslan Bukin * All rights reserved. 48d7e7a98SRuslan Bukin * 58d7e7a98SRuslan Bukin * Portions of this software were developed by SRI International and the 68d7e7a98SRuslan Bukin * University of Cambridge Computer Laboratory under DARPA/AFRL contract 78d7e7a98SRuslan Bukin * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. 88d7e7a98SRuslan Bukin * 98d7e7a98SRuslan Bukin * Portions of this software were developed by the University of Cambridge 108d7e7a98SRuslan Bukin * Computer Laboratory as part of the CTSRD Project, with support from the 118d7e7a98SRuslan Bukin * UK Higher Education Innovation Fund (HEIF). 128d7e7a98SRuslan Bukin * 138d7e7a98SRuslan Bukin * Redistribution and use in source and binary forms, with or without 148d7e7a98SRuslan Bukin * modification, are permitted provided that the following conditions 158d7e7a98SRuslan Bukin * are met: 168d7e7a98SRuslan Bukin * 1. Redistributions of source code must retain the above copyright 178d7e7a98SRuslan Bukin * notice, this list of conditions and the following disclaimer. 188d7e7a98SRuslan Bukin * 2. Redistributions in binary form must reproduce the above copyright 198d7e7a98SRuslan Bukin * notice, this list of conditions and the following disclaimer in the 208d7e7a98SRuslan Bukin * documentation and/or other materials provided with the distribution. 218d7e7a98SRuslan Bukin * 228d7e7a98SRuslan Bukin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 238d7e7a98SRuslan Bukin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 248d7e7a98SRuslan Bukin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 258d7e7a98SRuslan Bukin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 268d7e7a98SRuslan Bukin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 278d7e7a98SRuslan Bukin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 288d7e7a98SRuslan Bukin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 298d7e7a98SRuslan Bukin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 308d7e7a98SRuslan Bukin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 318d7e7a98SRuslan Bukin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 328d7e7a98SRuslan Bukin * SUCH DAMAGE. 338d7e7a98SRuslan Bukin */ 348d7e7a98SRuslan Bukin 358d7e7a98SRuslan Bukin #ifndef _MACHINE_ASM_H_ 368d7e7a98SRuslan Bukin #define _MACHINE_ASM_H_ 378d7e7a98SRuslan Bukin 388d7e7a98SRuslan Bukin #undef __FBSDID 398d7e7a98SRuslan Bukin #if !defined(lint) && !defined(STRIP_FBSDID) 408d7e7a98SRuslan Bukin #define __FBSDID(s) .ident s 418d7e7a98SRuslan Bukin #else 428d7e7a98SRuslan Bukin #define __FBSDID(s) /* nothing */ 438d7e7a98SRuslan Bukin #endif /* not lint and not STRIP_FBSDID */ 448d7e7a98SRuslan Bukin 458d7e7a98SRuslan Bukin #define _C_LABEL(x) x 468d7e7a98SRuslan Bukin 478d7e7a98SRuslan Bukin #define ENTRY(sym) \ 48acf87920SAlex Richardson .text; .globl sym; .type sym,@function; .align 4; sym: .cfi_startproc; 49acf87920SAlex Richardson #define END(sym) .cfi_endproc; .size sym, . - sym 508d7e7a98SRuslan Bukin 518d7e7a98SRuslan Bukin #define EENTRY(sym) \ 528d7e7a98SRuslan Bukin .globl sym; sym: 538d7e7a98SRuslan Bukin #define EEND(sym) 548d7e7a98SRuslan Bukin 558d7e7a98SRuslan Bukin #define WEAK_REFERENCE(sym, alias) \ 568d7e7a98SRuslan Bukin .weak alias; \ 578d7e7a98SRuslan Bukin .set alias,sym 588d7e7a98SRuslan Bukin 598d7e7a98SRuslan Bukin #define SET_FAULT_HANDLER(handler, tmp) \ 606ae48dd8SMitchell Horne ld tmp, PC_CURTHREAD(tp); \ 618d7e7a98SRuslan Bukin ld tmp, TD_PCB(tmp); /* Load the pcb */ \ 628d7e7a98SRuslan Bukin sd handler, PCB_ONFAULT(tmp) /* Set the handler */ 638d7e7a98SRuslan Bukin 64157654d0SRuslan Bukin #define ENTER_USER_ACCESS(tmp) \ 65157654d0SRuslan Bukin li tmp, SSTATUS_SUM; \ 66157654d0SRuslan Bukin csrs sstatus, tmp 67157654d0SRuslan Bukin 68157654d0SRuslan Bukin #define EXIT_USER_ACCESS(tmp) \ 69157654d0SRuslan Bukin li tmp, SSTATUS_SUM; \ 70157654d0SRuslan Bukin csrc sstatus, tmp 71157654d0SRuslan Bukin 72*e9fa3991SMitchell Horne #define SBI_CALL(ext, func) \ 73*e9fa3991SMitchell Horne li a7, ext; \ 74*e9fa3991SMitchell Horne li a6, func; \ 75*e9fa3991SMitchell Horne ecall 76*e9fa3991SMitchell Horne 778d7e7a98SRuslan Bukin #endif /* _MACHINE_ASM_H_ */ 78