From 7613da4d26dbaaf9063540187a4a880cb3c0b3e9 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 28 Sep 2023 09:07:56 -0700 Subject: [PATCH 1/2] debug: Halted harts can also be unavailable. --- riscv/debug_module.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/riscv/debug_module.cc b/riscv/debug_module.cc index 4a7a802ef5..026f4b3d9b 100644 --- a/riscv/debug_module.cc +++ b/riscv/debug_module.cc @@ -413,14 +413,14 @@ bool debug_module_t::dmi_read(unsigned address, uint32_t *value) dmstatus.allresumeack = false; } auto hart = sim->get_harts().at(hart_id); - if (hart_state[hart_id].halted) { - dmstatus.allrunning = false; - dmstatus.anyhalted = true; - dmstatus.allunavail = false; - } else if (!hart_available(hart_id)) { + if (!hart_available(hart_id)) { dmstatus.allrunning = false; dmstatus.allhalted = false; dmstatus.anyunavail = true; + } else if (hart_state[hart_id].halted) { + dmstatus.allrunning = false; + dmstatus.anyhalted = true; + dmstatus.allunavail = false; } else { dmstatus.allhalted = false; dmstatus.anyrunning = true; From 77e9aaef19f528d8ced2301fe39eb941a9fdc3e2 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 28 Sep 2023 09:08:25 -0700 Subject: [PATCH 2/2] debug: Abstract commands fail on unavailable harts. --- riscv/debug_module.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/riscv/debug_module.cc b/riscv/debug_module.cc index 026f4b3d9b..e9aef1a822 100644 --- a/riscv/debug_module.cc +++ b/riscv/debug_module.cc @@ -579,6 +579,10 @@ bool debug_module_t::perform_abstract_command() abstractcs.cmderr = CMDERR_BUSY; return true; } + if (!hart_available(dmcontrol.hartsel)) { + abstractcs.cmderr = CMDERR_HALTRESUME; + return true; + } if ((command >> 24) == 0) { // register access