summaryrefslogtreecommitdiff
path: root/assembly/rrxing2
diff options
context:
space:
mode:
Diffstat (limited to 'assembly/rrxing2')
-rw-r--r--assembly/rrxing2/rrxing2.S19
1 files changed, 18 insertions, 1 deletions
diff --git a/assembly/rrxing2/rrxing2.S b/assembly/rrxing2/rrxing2.S
index c94edc0..bb2c4dc 100644
--- a/assembly/rrxing2/rrxing2.S
+++ b/assembly/rrxing2/rrxing2.S
@@ -8,6 +8,9 @@ j _start
.include "util.S"
_start:
+la t0,nmihandler
+csrw 0xbc0,t0 # Set up RNMI handler
+csrsi mnstatus,8 # Turn on NMIE
li t0,0x400
csrs mseccfg,t0 # Turn on MLPE (enable Zicfilp)
li sp,0x10000 # Set up stack pointer
@@ -187,6 +190,19 @@ ecall # Tell the user
li a7,10
ecall # Then halt
+.align 2
+nmihandler:
+li a7,4
+la a0,uinmi
+ecall # Display NMI message
+
+csrr a0,mncause # Read what the cause was
+li a7,1
+ecall # Tell the user
+
+li a7,10
+ecall # Then halt
+
states: .word destate0,destate1,destate2,destate3,destate4,destate5,destate6,0,0,0,0,0,0,0,0,0
.word ukstate0,ukstate1,ukstate2,ukstate3,ukstate4,ukstate5,ukstate6,ukstate7,0,0,0,0,0,0,0,0
.word usstate0,usstate1,usstate2,usstate3,usstate4,0,0,0,0,0,0,0,0,0,0,0
@@ -364,7 +380,8 @@ activetime: .byte 15
extensiontime: .byte 25
traincounter: .word 0
-uiunimplementedtrap: .asciz "Unimplemented trap!\nmcause: "
+uiunimplementedtrap: .asciz "\nUnimplemented trap!\nmcause: "
+uinmi: .asciz "\nUnexpected NMI!\nmncause: "
channelbuf: .skip 16
msgbuf: .skip 16
lightchannel: .asciz "light"