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 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/assym.h> 39 #include <sys/proc.h> 40 #include <sys/mbuf.h> 41 #include <sys/vmmeter.h> 42 #include <sys/bus.h> 43 #include <vm/vm.h> 44 #include <vm/vm_param.h> 45 #include <vm/pmap.h> 46 #include <vm/vm_map.h> 47 48 #include <machine/riscvreg.h> 49 #include <machine/frame.h> 50 #include <machine/pcb.h> 51 #include <machine/cpu.h> 52 #include <machine/proc.h> 53 #include <machine/cpufunc.h> 54 #include <machine/pte.h> 55 #include <machine/intr.h> 56 #include <machine/machdep.h> 57 #include <machine/vmparam.h> 58 59 ASSYM(KERNBASE, KERNBASE); 60 ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); 61 ASSYM(VM_MAX_KERNEL_ADDRESS, VM_MAX_KERNEL_ADDRESS); 62 ASSYM(VM_EARLY_DTB_ADDRESS, VM_EARLY_DTB_ADDRESS); 63 ASSYM(PMAP_MAPDEV_EARLY_SIZE, PMAP_MAPDEV_EARLY_SIZE); 64 65 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); 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_S, offsetof(struct pcb, pcb_s)); 72 ASSYM(PCB_X, offsetof(struct pcb, pcb_x)); 73 ASSYM(PCB_FCSR, offsetof(struct pcb, pcb_fcsr)); 74 75 ASSYM(SF_UC, offsetof(struct sigframe, sf_uc)); 76 77 ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); 78 ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); 79 80 ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); 81 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); 82 ASSYM(TD_AST, offsetof(struct thread, td_ast)); 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, roundup2(sizeof(struct trapframe), STACKALIGNBYTES + 1)); 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_STVAL, offsetof(struct trapframe, tf_stval)); 98 ASSYM(TF_SCAUSE, offsetof(struct trapframe, tf_scause)); 99 ASSYM(TF_SSTATUS, offsetof(struct trapframe, tf_sstatus)); 100 101 ASSYM(RISCV_BOOTPARAMS_SIZE, sizeof(struct riscv_bootparams)); 102 ASSYM(RISCV_BOOTPARAMS_KERN_L1PT, offsetof(struct riscv_bootparams, kern_l1pt)); 103 ASSYM(RISCV_BOOTPARAMS_KERN_PHYS, offsetof(struct riscv_bootparams, kern_phys)); 104 ASSYM(RISCV_BOOTPARAMS_KERN_STACK, offsetof(struct riscv_bootparams, 105 kern_stack)); 106 ASSYM(RISCV_BOOTPARAMS_DTBP_VIRT, offsetof(struct riscv_bootparams, dtbp_virt)); 107 ASSYM(RISCV_BOOTPARAMS_DTBP_PHYS, offsetof(struct riscv_bootparams, dtbp_phys)); 108 ASSYM(RISCV_BOOTPARAMS_MODULEP, offsetof(struct riscv_bootparams, modulep)); 109