aboutsummaryrefslogtreecommitdiff
path: root/debug_rom
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-06-09 10:18:32 -0700
committerAndrew Waterman <waterman@eecs.berkeley.edu>2016-06-09 10:18:32 -0700
commit1ec78cfedd16abb0095f9e77f2700af24522345d (patch)
tree6044dc36db88506a73efdb9ae4f55683f966d820 /debug_rom
parentf82d42cdefb72f23a5a98b7d93413caec7bf5c8d (diff)
downloadriscv-isa-sim-1ec78cfedd16abb0095f9e77f2700af24522345d.zip
riscv-isa-sim-1ec78cfedd16abb0095f9e77f2700af24522345d.tar.gz
riscv-isa-sim-1ec78cfedd16abb0095f9e77f2700af24522345d.tar.bz2
Fix 2 bugs in Debug ROM: (#52)
1. Debug ROM wasn't actually writing 0xffffffff to the last word in Debug RAM after an exception happened. 2. Fix a race where debug interrupts were cleared before that write would have happened, so a debugger (gdbserver.cc in this case) might get the wrong idea about whether an exception happened or not. Why wasn't this wreaking havoc before?
Diffstat (limited to 'debug_rom')
-rwxr-xr-xdebug_rom/debug_rom.S12
-rw-r--r--debug_rom/debug_rom.h10
2 files changed, 12 insertions, 10 deletions
diff --git a/debug_rom/debug_rom.S b/debug_rom/debug_rom.S
index 9e83098..b0be7fc 100755
--- a/debug_rom/debug_rom.S
+++ b/debug_rom/debug_rom.S
@@ -30,9 +30,6 @@ exception:
_resume:
li s0, 0
_resume2:
- # Clear debug interrupt.
- csrr s1, CSR_MHARTID
- sw s1, CLEARDEBINT(zero)
fence
# Restore s1.
@@ -40,21 +37,26 @@ _resume2:
bltz s1, restore_not_32
restore_32:
lw s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 4)(zero)
- j check_halt
+ j finish_restore
restore_not_32:
slli s1, s1, 1
bltz s1, restore_128
restore_64:
ld s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 8)(zero)
- j check_halt
+ j finish_restore
restore_128:
nop #lq s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 16)(zero)
+finish_restore:
# s0 contains ~0 if we got here through an exception, and 0 otherwise.
# Store this to the last word in Debug RAM so the debugger can tell if
# an exception occurred.
sw s0, (DEBUG_RAM + DEBUG_RAM_SIZE - 4)(zero)
+ # Clear debug interrupt.
+ csrr s0, CSR_MHARTID
+ sw s0, CLEARDEBINT(zero)
+
check_halt:
csrr s0, CSR_DCSR
andi s0, s0, DCSR_HALT
diff --git a/debug_rom/debug_rom.h b/debug_rom/debug_rom.h
index a929a27..b4ee2dd 100644
--- a/debug_rom/debug_rom.h
+++ b/debug_rom/debug_rom.h
@@ -1,10 +1,10 @@
static const unsigned char debug_rom_raw[] = {
0x6f, 0x00, 0x00, 0x06, 0x6f, 0x00, 0xc0, 0x00, 0x13, 0x04, 0xf0, 0xff,
- 0x6f, 0x00, 0x80, 0x00, 0x13, 0x04, 0x00, 0x00, 0xf3, 0x24, 0x40, 0xf1,
- 0x23, 0x20, 0x90, 0x10, 0x0f, 0x00, 0xf0, 0x0f, 0xf3, 0x24, 0x00, 0xf1,
- 0x63, 0xc6, 0x04, 0x00, 0x83, 0x24, 0xc0, 0x43, 0x6f, 0x00, 0xc0, 0x01,
- 0x93, 0x94, 0x14, 0x00, 0x63, 0xc6, 0x04, 0x00, 0x83, 0x34, 0x80, 0x43,
- 0x6f, 0x00, 0xc0, 0x00, 0x13, 0x00, 0x00, 0x00, 0x23, 0x2e, 0x80, 0x42,
+ 0x6f, 0x00, 0x80, 0x00, 0x13, 0x04, 0x00, 0x00, 0x0f, 0x00, 0xf0, 0x0f,
+ 0xf3, 0x24, 0x00, 0xf1, 0x63, 0xc6, 0x04, 0x00, 0x83, 0x24, 0xc0, 0x43,
+ 0x6f, 0x00, 0x80, 0x01, 0x93, 0x94, 0x14, 0x00, 0x63, 0xc6, 0x04, 0x00,
+ 0x83, 0x34, 0x80, 0x43, 0x6f, 0x00, 0x80, 0x00, 0x13, 0x00, 0x00, 0x00,
+ 0x23, 0x2e, 0x80, 0x42, 0x73, 0x24, 0x40, 0xf1, 0x23, 0x20, 0x80, 0x10,
0x73, 0x24, 0x00, 0x7b, 0x13, 0x74, 0x84, 0x00, 0x63, 0x04, 0x04, 0x00,
0x6f, 0x00, 0x80, 0x05, 0x73, 0x24, 0x20, 0x7b, 0x73, 0x00, 0x20, 0x7b,
0x73, 0x10, 0x24, 0x7b, 0x73, 0x24, 0x00, 0x7b, 0x13, 0x74, 0x04, 0x1c,