aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMegan Wachs <megan@sifive.com>2017-02-27 18:53:50 -0800
committerMegan Wachs <megan@sifive.com>2017-02-27 18:53:50 -0800
commit7f13e905050ca6a164ac2a25f6686fed765def0d (patch)
treebf763f1bc2bafc3b97a0c8254dd705e2186a0eb8
parentb4d38d0997ff591be908b56399c18a70074ce477 (diff)
downloadriscv-openocd-7f13e905050ca6a164ac2a25f6686fed765def0d.zip
riscv-openocd-7f13e905050ca6a164ac2a25f6686fed765def0d.tar.gz
riscv-openocd-7f13e905050ca6a164ac2a25f6686fed765def0d.tar.bz2
riscv: Ensure that hart is halted before attempting to examine it.
-rw-r--r--src/target/riscv/riscv-013.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index cee486e..d617992 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1539,7 +1539,7 @@ static int examine(struct target *target)
LOG_DEBUG(" authbusy=%d", get_field(dmcontrol, DMI_DMCONTROL_AUTHBUSY));
LOG_DEBUG(" version=%d", get_field(dmcontrol, DMI_DMCONTROL_VERSION));
- unsigned hartstatus = DMI_DMCONTROL_HARTSTATUS;
+ unsigned hartstatus = get_field(dmcontrol, DMI_DMCONTROL_HARTSTATUS);
if (!get_field(dmcontrol, DMI_DMCONTROL_DMACTIVE)) {
LOG_ERROR("Debug Module did not become active. dmcontrol=0x%x",
@@ -1570,7 +1570,7 @@ static int examine(struct target *target)
LOG_DEBUG(" datacount=%d", info->datacount);
uint32_t accesscs = dmi_read(target, DMI_PROGBUFCS);
- info->progsize = get_field(abstractcs, DMI_PROGBUFCS_PROGSIZE);
+ info->progsize = get_field(accesscs, DMI_PROGBUFCS_PROGSIZE);
LOG_DEBUG("accesscs=0x%x", accesscs);
LOG_DEBUG(" progsize=%d", info->progsize);
@@ -1606,6 +1606,7 @@ static int examine(struct target *target)
}
if (hartstatus == 1) {
+ LOG_DEBUG("Hart currently running. Requesting halt.\n");
dmi_write(target, DMI_DMCONTROL, DMI_DMCONTROL_HALTREQ |
DMI_DMCONTROL_DMACTIVE);
for (unsigned i = 0; i < 256; i++) {
@@ -1644,6 +1645,7 @@ static int examine(struct target *target)
}
if (hartstatus == 1) {
+ LOG_DEBUG("Resuming hart.\n");
// Resume if the hart had been running.
dmi_write(target, DMI_DMCONTROL, DMI_DMCONTROL_DMACTIVE |
DMI_DMCONTROL_RESUMEREQ);