aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2019-01-18 12:44:42 -0800
committerTim Newsome <tim@sifive.com>2019-01-18 13:18:15 -0800
commitc296c625214c74e25744ed8c2c0b62b65c90532d (patch)
tree37c7f098e21d96e9b162a6a932e94818f012de8c
parent348f15315e7670fccdc152545399f3d44a24bf7d (diff)
downloadriscv-openocd-c296c625214c74e25744ed8c2c0b62b65c90532d.zip
riscv-openocd-c296c625214c74e25744ed8c2c0b62b65c90532d.tar.gz
riscv-openocd-c296c625214c74e25744ed8c2c0b62b65c90532d.tar.bz2
Halt all SMP harts on halt request.
38/45 tests pass. Change-Id: Ia4fd523139c197020d9277be4bf5f92079520068
-rw-r--r--src/target/riscv/riscv.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 3571e13..4ef417e 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -1226,7 +1226,7 @@ int riscv_openocd_poll(struct target *target)
struct target *t = targets->target;
targets = targets->next;
if (t->state != TARGET_HALTED) {
- if (old_or_new_riscv_halt(t) != ERROR_OK)
+ if (riscv_halt_all_harts(t) != ERROR_OK)
result = ERROR_FAIL;
}
}
@@ -1247,16 +1247,26 @@ int riscv_openocd_poll(struct target *target)
int riscv_openocd_halt(struct target *target)
{
RISCV_INFO(r);
+ int result;
LOG_DEBUG("halting all harts");
- int out = riscv_halt_all_harts(target);
- if (out != ERROR_OK) {
- LOG_ERROR("Unable to halt all harts");
- return out;
+ if (target->smp) {
+ LOG_DEBUG("Halt other targets in this SMP group.");
+ struct target_list *targets = target->head;
+ result = ERROR_OK;
+ while (targets) {
+ struct target *t = targets->target;
+ targets = targets->next;
+ if (t->state != TARGET_HALTED) {
+ if (riscv_halt_all_harts(t) != ERROR_OK)
+ result = ERROR_FAIL;
+ }
+ }
+ } else {
+ result = riscv_halt_all_harts(target);
}
- register_cache_invalidate(target->reg_cache);
if (riscv_rtos_enabled(target)) {
if (r->rtos_hartid != -1) {
LOG_DEBUG("halt requested on RTOS hartid %d", r->rtos_hartid);
@@ -1269,7 +1279,7 @@ int riscv_openocd_halt(struct target *target)
target->state = TARGET_HALTED;
target->debug_reason = DBG_REASON_DBGRQ;
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
- return out;
+ return result;
}
int riscv_openocd_resume(
@@ -1899,7 +1909,9 @@ int riscv_halt_one_hart(struct target *target, int hartid)
return ERROR_OK;
}
- return r->halt_current_hart(target);
+ int result = r->halt_current_hart(target);
+ register_cache_invalidate(target->reg_cache);
+ return result;
}
int riscv_resume_all_harts(struct target *target)