1 /* Copyright 2019 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
4 #define METAL_MSTATUS_MIE_SHIFT 8
5 #define METAL_MSTATUS_MPP_M 3
6 #define METAL_MSTATUS_MPP_SHIFT 11
8 #define METAL_MTVEC_MODE_MASK 3
10 /* void _metal_trap(int ecode)
12 * Trigger a machine-mode trap with exception code ecode
15 .type _metal_trap, @function
19 /* Store the instruction which called _metal_trap in mepc */
23 /* Set mcause to the desired exception code */
31 xori t1, t1, METAL_MSTATUS_MIE_SHIFT
35 li t1, METAL_MSTATUS_MPP_M
36 slli t1, t1, METAL_MSTATUS_MPP_SHIFT
46 * Mask the mtvec MODE bits
47 * Exceptions always jump to mtvec.BASE regradless of the vectoring mode.
49 andi t0, t0, METAL_MTVEC_MODE_MASK
56 * For sanity's sake we set up an early trap vector that just does nothing.
57 * If you end up here then there's a bug in the early boot code somewhere.
59 .section .text.metal.init.trapvec
60 .global early_trap_vector