summaryrefslogtreecommitdiff
path: root/assembly/extint-test
diff options
context:
space:
mode:
authorcheapie <cheapiephp@gmail.com>2026-10-30 09:09:20 -0500
committercheapie <cheapiephp@gmail.com>2026-10-30 09:09:20 -0500
commita16b984f06ca52be0785073ee2c21fcae301fff3 (patch)
tree78dd6761af6088d27e791a533bcb73a974cb3c89 /assembly/extint-test
parent1feb4eefe87b555a64d51e08eca7315b30521345 (diff)
downloadrvcontroller-a16b984f06ca52be0785073ee2c21fcae301fff3.tar
rvcontroller-a16b984f06ca52be0785073ee2c21fcae301fff3.tar.gz
rvcontroller-a16b984f06ca52be0785073ee2c21fcae301fff3.tar.bz2
rvcontroller-a16b984f06ca52be0785073ee2c21fcae301fff3.tar.xz
rvcontroller-a16b984f06ca52be0785073ee2c21fcae301fff3.zip
Add console interrupt support
Diffstat (limited to 'assembly/extint-test')
-rw-r--r--assembly/extint-test/extint-test.S26
1 files changed, 24 insertions, 2 deletions
diff --git a/assembly/extint-test/extint-test.S b/assembly/extint-test/extint-test.S
index c1b872d..68a218c 100644
--- a/assembly/extint-test/extint-test.S
+++ b/assembly/extint-test/extint-test.S
@@ -4,8 +4,8 @@ la t0,handler
csrw mtvec,t0 # Set up trap handler
li t0,0x400
csrc mstatush,t0 # Turn off MDT
-li t0,0x30000
-csrw mie,t0 # Mask all interrupts except mesecons/digilines
+li t0,0x70000
+csrw mie,t0 # Mask all interrupts except mesecons/digilines/console
csrw mip,zero # Clear any pending interrupts
csrsi mstatus,0x8 # Turn on MIE to enable interrupts
@@ -43,12 +43,16 @@ sw x30,120(x31) # and write that back out too
csrr t0,mcause # Read why the trap occurred
+
li t1,0x80000010 # Interrupt 16 = mesecons
beq t0,t1,handler_mesecons
li t1,0x80000011 # Interrupt 17 = digilines
beq t0,t1,handler_digilines
+li t1,0x80000012 # Interrupt 18 = console
+beq t0,t1,handler_console
+
j handler_other # Something else
handler_mesecons:
@@ -100,6 +104,23 @@ ecall # Clear out any other digilines messages
j handler_epilogue
+handler_console:
+li a7,4
+la a0,consolemsg
+ecall # Show that this was a console event
+
+li a7,132
+ecall # Read the first character from the input buffer
+li a7,11
+ecall # And print it
+li a0,'\n'
+ecall # Followed by a line feed
+
+li a7,131
+ecall # Discard the rest
+
+j handler_epilogue
+
handler_other:
li a7,4
la a0,unimplementedmsg
@@ -140,6 +161,7 @@ waitingmsg: .asciz "Waiting...\n"
meseconsmsg: .asciz "Mesecons event!\nInput value: "
digilinesmsg: .asciz "Digilines event!\nChannel:\n"
digilinesmsg2: .asciz "\nMessage:\n"
+consolemsg: .asciz "Console event!\nFirst char: "
unimplementedmsg: .asciz "Unimplemented trap!\nmcause: "
channelbuf: .asciz " "
msgbuf: .asciz " "