From 982a1f13deb19926bd2f7c280d65d976a1c4ffa1 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 15 Nov 2026 13:20:48 -0600 Subject: Add ability to clear statistics in rrxing2, also fix a possible spurious interrupt --- assembly/rrxing2/rrxing2.S | 6 +++--- assembly/rrxing2/ui.S | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'assembly/rrxing2') diff --git a/assembly/rrxing2/rrxing2.S b/assembly/rrxing2/rrxing2.S index ba8dac9..6f0ce33 100644 --- a/assembly/rrxing2/rrxing2.S +++ b/assembly/rrxing2/rrxing2.S @@ -87,11 +87,11 @@ ecall # Read the next digilines message la t0,channelbuf ld t1,0(t0) li t3,0x65746564 # 'dete' -bne t1,t3,1f # not the detector +bne t1,t3,3f # not the detector li t3,0x00ffffff and t2,t2,t3 li t3,0x00007463 # 'ct\0\0' -bne t2,t3,1f # not the detector +bne t2,t3,3f # not the detector la t0,traincounter lw t1,0(t0) @@ -146,7 +146,7 @@ lw t0,0(t0) # Load the pointer jalr ra,t0,0 # And call that function 1: -li a7,133 +3: li a7,133 ecall # Check if there are more messages to process bnez a0,handler_digilines j handler_epilogue diff --git a/assembly/rrxing2/ui.S b/assembly/rrxing2/ui.S index 3096105..09dca9e 100644 --- a/assembly/rrxing2/ui.S +++ b/assembly/rrxing2/ui.S @@ -736,6 +736,21 @@ bne a0,t0,1f la t1,uipage li t0,8 sb t0,0(t1) # User entered '0', go to diagnostics (page 8) +1: li t0,'c' +bne a0,t0,1f +li t0,-1 +csrw mcountinhibit,t0 # User entered 'c', mask all possible counters so that this can be done more or less atomically +la t0,traincounter +sb x0,0(t0) # Reset train counter +csrw mcycle,x0 # Reset cycle +csrw mcycleh,x0 +csrw minstret,x0 # Reset instret +csrw minstreth,x0 +csrr t0,mie +bexti t0,t0,7 # Check if timer interrupt is enabled +bnez t0,2f # Don't reset the time if it is +sd x0,2(gp) # If not, then the time is OK to reset +2: csrw mcountinhibit,x0 # Unmask counters 1: ret .align 2 @@ -855,7 +870,7 @@ uilighttest: .asciz "\nROAD SIGNAL TEST\n1: Off | 2: Red\n3: Yellow | 4: Green\n uisignaltest: .asciz "\nRAIL SIGNAL TEST\n1: Off | 2: Red\n3: Yellow | 4: Green\n5: Flash Red\n6: Flash Yellow\n0: Back" uibelltest: .asciz "\nBELL TEST\n1: Off\n2: On\n\n\n0: Back" uigatetest: .asciz "\nGATE TEST\n1: Up\n2: Down\n\n\n0: Back" -uistatistics: .asciz "\nSTATISTICS\n cycle: XXXXXXXX\n time: XXXXXXXX\ninstret: XXXXXXXX\n trains: XXXXXXXX\n0: Back" +uistatistics: .asciz "\nSTATISTICS\n cycle: XXXXXXXX\n time: XXXXXXXX\ninstret: XXXXXXXX\n trains: XXXXXXXX\n0: Back | c: Clear" uiabout1: .asciz "\nABOUT\nRailroad Crossing 2\nfor RVController\n\n\n1: Next | 0: Exit" uiabout2: .asciz "\nA product of\nScheiße & Broken\nSignalling Systems,\na Cheapie Systems\ncompany\n1: Next | 0: Exit" uiabout3: .asciz "\nThis is free and\nunencumbered\nsoftware released\ninto the public\ndomain\n1: Next | 0: Exit" -- cgit v1.2.3