github.com/usbarmory/tamago@v0.0.0-20240508072735-8612bbe1e454/riscv/exception.s (about) 1 // RISC-V processor support 2 // https://github.com/usbarmory/tamago 3 // 4 // Copyright (c) WithSecure Corporation 5 // https://foundry.withsecure.com 6 // 7 // Use of this source code is governed by the license 8 // that can be found in the LICENSE file. 9 10 #include "csr.h" 11 #include "textflag.h" 12 13 #define stvec 0x105 14 #define sepc 0x141 15 #define scause 0x142 16 17 #define mtvec 0x305 18 #define mepc 0x341 19 #define mcause 0x342 20 21 // func set_stvec(addr uint64) 22 TEXT ·set_stvec(SB),NOSPLIT,$0-8 23 MOV addr+0(FP), T0 24 CSRW (t0, stvec) 25 RET 26 27 // func read_sepc() uint64 28 TEXT ·read_sepc(SB),NOSPLIT,$0-8 29 CSRR (sepc, t0) 30 MOV T0, ret+0(FP) 31 RET 32 33 // func read_scause() uint64 34 TEXT ·read_scause(SB),NOSPLIT,$0-8 35 CSRR (scause, t0) 36 MOV T0, ret+0(FP) 37 RET 38 39 // func set_mtvec(addr uint64) 40 TEXT ·set_mtvec(SB),NOSPLIT,$0-8 41 MOV addr+0(FP), T0 42 CSRW (t0, mtvec) 43 RET 44 45 // func read_mepc() uint64 46 TEXT ·read_mepc(SB),NOSPLIT,$0-8 47 CSRR (mepc, t0) 48 MOV T0, ret+0(FP) 49 RET 50 51 // func read_mcause() uint64 52 TEXT ·read_mcause(SB),NOSPLIT,$0-8 53 CSRR (mcause, t0) 54 MOV T0, ret+0(FP) 55 RET