1 /*- 2 * Copyright (c) 2015-2016 Ruslan Bukin <br@bsdpad.com> 3 * All rights reserved. 4 * 5 * Portions of this software were developed by SRI International and the 6 * University of Cambridge Computer Laboratory under DARPA/AFRL contract 7 * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. 8 * 9 * Portions of this software were developed by the University of Cambridge 10 * Computer Laboratory as part of the CTSRD Project, with support from the 11 * UK Higher Education Innovation Fund (HEIF). 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35 #include <sys/cdefs.h> 36 __FBSDID("$FreeBSD$"); 37 38 #include <sys/param.h> 39 #include <sys/systm.h> 40 #include <sys/assym.h> 41 #include <sys/proc.h> 42 #include <sys/mbuf.h> 43 #include <sys/vmmeter.h> 44 #include <sys/bus.h> 45 #include <vm/vm.h> 46 #include <vm/vm_param.h> 47 #include <vm/pmap.h> 48 #include <vm/vm_map.h> 49 50 #include <machine/riscvreg.h> 51 #include <machine/frame.h> 52 #include <machine/pcb.h> 53 #include <machine/cpu.h> 54 #include <machine/proc.h> 55 #include <machine/cpufunc.h> 56 #include <machine/pte.h> 57 #include <machine/intr.h> 58 59 ASSYM(KERNBASE, KERNBASE); 60 ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); 61 ASSYM(TDF_ASTPENDING, TDF_ASTPENDING); 62 ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); 63 64 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); 65 ASSYM(PCB_L1ADDR, offsetof(struct pcb, pcb_l1addr)); 66 ASSYM(PCB_SIZE, sizeof(struct pcb)); 67 ASSYM(PCB_RA, offsetof(struct pcb, pcb_ra)); 68 ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); 69 ASSYM(PCB_GP, offsetof(struct pcb, pcb_gp)); 70 ASSYM(PCB_TP, offsetof(struct pcb, pcb_tp)); 71 ASSYM(PCB_T, offsetof(struct pcb, pcb_t)); 72 ASSYM(PCB_S, offsetof(struct pcb, pcb_s)); 73 ASSYM(PCB_A, offsetof(struct pcb, pcb_a)); 74 75 ASSYM(SF_UC, offsetof(struct sigframe, sf_uc)); 76 77 ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); 78 ASSYM(PC_SPTBR, offsetof(struct pcpu, pc_sptbr)); 79 ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); 80 81 ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); 82 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); 83 ASSYM(TD_PROC, offsetof(struct thread, td_proc)); 84 ASSYM(TD_FRAME, offsetof(struct thread, td_frame)); 85 ASSYM(TD_MD, offsetof(struct thread, td_md)); 86 ASSYM(TD_LOCK, offsetof(struct thread, td_lock)); 87 88 ASSYM(TF_SIZE, sizeof(struct trapframe)); 89 ASSYM(TF_RA, offsetof(struct trapframe, tf_ra)); 90 ASSYM(TF_SP, offsetof(struct trapframe, tf_sp)); 91 ASSYM(TF_GP, offsetof(struct trapframe, tf_gp)); 92 ASSYM(TF_TP, offsetof(struct trapframe, tf_tp)); 93 ASSYM(TF_T, offsetof(struct trapframe, tf_t)); 94 ASSYM(TF_S, offsetof(struct trapframe, tf_s)); 95 ASSYM(TF_A, offsetof(struct trapframe, tf_a)); 96 ASSYM(TF_SEPC, offsetof(struct trapframe, tf_sepc)); 97 ASSYM(TF_SBADADDR, offsetof(struct trapframe, tf_sbadaddr)); 98 ASSYM(TF_SCAUSE, offsetof(struct trapframe, tf_scause)); 99 ASSYM(TF_SSTATUS, offsetof(struct trapframe, tf_sstatus)); 100