aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2017-02-27 20:17:42 -0800
committerGitHub <noreply@github.com>2017-02-27 20:17:42 -0800
commit8785b256cb13633b0ecd34cd569e73c59f49da21 (patch)
treebf763f1bc2bafc3b97a0c8254dd705e2186a0eb8
parentb4d38d0997ff591be908b56399c18a70074ce477 (diff)
parent7f13e905050ca6a164ac2a25f6686fed765def0d (diff)
downloadriscv-openocd-8785b256cb13633b0ecd34cd569e73c59f49da21.zip
riscv-openocd-8785b256cb13633b0ecd34cd569e73c59f49da21.tar.gz
riscv-openocd-8785b256cb13633b0ecd34cd569e73c59f49da21.tar.bz2
Merge pull request #18 from sifive/halt_correctly
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);