From 2567e5bd1b06024a6f4cadd3e7ca528f5e70eacd Mon Sep 17 00:00:00 2001 From: Nadime Barhoumi Date: Thu, 13 Nov 2025 12:23:39 -0500 Subject: [PATCH 1/2] Make abstractauto register optional in debug module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add --dm-no-abstractauto flag to disable support for the optional abstractauto register. When disabled, writes to the register are ignored and the internal state is kept at 0. Currently, neither riscv-openocd nor openocd support batch reads or writes for debug modules that don’t implement abstractauto, as both assume every debug module provides abstractauto support. However, work is underway to remove this dependency. --- riscv/debug_module.cc | 14 ++++++++++---- riscv/debug_module.h | 1 + spike_main/spike.cc | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/riscv/debug_module.cc b/riscv/debug_module.cc index 7ccac9fe..93010364 100644 --- a/riscv/debug_module.cc +++ b/riscv/debug_module.cc @@ -1101,10 +1101,16 @@ bool debug_module_t::dmi_write(unsigned address, uint32_t value) return true; case DM_ABSTRACTAUTO: - abstractauto.autoexecprogbuf = get_field(value, - DM_ABSTRACTAUTO_AUTOEXECPROGBUF); - abstractauto.autoexecdata = get_field(value, - DM_ABSTRACTAUTO_AUTOEXECDATA); + if (config.support_abstractauto) { + abstractauto.autoexecprogbuf = get_field(value, + DM_ABSTRACTAUTO_AUTOEXECPROGBUF); + abstractauto.autoexecdata = get_field(value, + DM_ABSTRACTAUTO_AUTOEXECDATA); + } + else { + abstractauto.autoexecprogbuf = 0; + abstractauto.autoexecdata = 0; + } return true; case DM_SBCS: sbcs.readonaddr = get_field(value, DM_SBCS_SBREADONADDR); diff --git a/riscv/debug_module.h b/riscv/debug_module.h index b883b3be..831df105 100644 --- a/riscv/debug_module.h +++ b/riscv/debug_module.h @@ -24,6 +24,7 @@ struct debug_module_config_t { bool support_abstract_fpr_access = true; bool support_haltgroups = true; bool support_impebreak = true; + bool support_abstractauto = true; }; struct dmcontrol_t { diff --git a/spike_main/spike.cc b/spike_main/spike.cc index fd180de1..5617a825 100644 --- a/spike_main/spike.cc +++ b/spike_main/spike.cc @@ -84,6 +84,7 @@ static void help(int exit_code = 1) fprintf(stderr, " --dm-no-abstract-fpr Debug module won't support abstract FPR access\n"); fprintf(stderr, " --dm-no-halt-groups Debug module won't support halt groups\n"); fprintf(stderr, " --dm-no-impebreak Debug module won't support implicit ebreak in program buffer\n"); + fprintf(stderr, " --dm-no-abstractauto Debug module won't support the abstractauto register\n"); fprintf(stderr, " --blocksz= Cache block size (B) for CMO operations(powers of 2) [default 64]\n"); fprintf(stderr, " --instructions= Stop after n instructions\n"); @@ -434,6 +435,8 @@ int main(int argc, char** argv) [&](const char UNUSED *s){dm_config.support_abstract_fpr_access = false;}); parser.option(0, "dm-no-halt-groups", 0, [&](const char UNUSED *s){dm_config.support_haltgroups = false;}); + parser.option(0, "dm-no-abstractauto", 0, + [&](const char UNUSED *s){dm_config.support_abstractauto = false;}); parser.option(0, "log-commits", 0, [&](const char UNUSED *s){log_commits = true;}); parser.option(0, "log", 1, From 3ab6f34cd1f05dc9dae026cb9868f17cf2590f76 Mon Sep 17 00:00:00 2001 From: Nadime Barhoumi Date: Fri, 14 Nov 2025 08:37:49 -0500 Subject: [PATCH 2/2] Remove else --- riscv/debug_module.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/riscv/debug_module.cc b/riscv/debug_module.cc index 93010364..410e0b3d 100644 --- a/riscv/debug_module.cc +++ b/riscv/debug_module.cc @@ -1040,8 +1040,6 @@ bool debug_module_t::dmi_write(unsigned address, uint32_t value) dmcontrol.ndmreset = get_field(value, DM_DMCONTROL_NDMRESET); if (config.support_hasel) dmcontrol.hasel = get_field(value, DM_DMCONTROL_HASEL); - else - dmcontrol.hasel = 0; dmcontrol.hartsel = get_field(value, DM_DMCONTROL_HARTSELHI) << DM_DMCONTROL_HARTSELLO_LENGTH; dmcontrol.hartsel |= get_field(value, DM_DMCONTROL_HARTSELLO); @@ -1107,10 +1105,6 @@ bool debug_module_t::dmi_write(unsigned address, uint32_t value) abstractauto.autoexecdata = get_field(value, DM_ABSTRACTAUTO_AUTOEXECDATA); } - else { - abstractauto.autoexecprogbuf = 0; - abstractauto.autoexecdata = 0; - } return true; case DM_SBCS: sbcs.readonaddr = get_field(value, DM_SBCS_SBREADONADDR);