diff options
Diffstat (limited to 'assembly')
| -rw-r--r-- | assembly/extint-test/extint-test.S | 26 |
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 " " |
