target/riscv: Ensure to handle all triggered a halt events
If all current halted states are due to a halt group, then a new "triggered a halt" event has occurred.
This commit is contained in:
parent
f51900b4a2
commit
21d836aaac
|
@ -3743,6 +3743,7 @@ int riscv_openocd_poll(struct target *target)
|
||||||
unsigned int should_resume = 0;
|
unsigned int should_resume = 0;
|
||||||
unsigned int halted = 0;
|
unsigned int halted = 0;
|
||||||
unsigned int running = 0;
|
unsigned int running = 0;
|
||||||
|
unsigned int cause_groups = 0;
|
||||||
struct target_list *entry;
|
struct target_list *entry;
|
||||||
foreach_smp_target(entry, targets) {
|
foreach_smp_target(entry, targets) {
|
||||||
struct target *t = entry->target;
|
struct target *t = entry->target;
|
||||||
|
@ -3790,6 +3791,22 @@ int riscv_openocd_poll(struct target *target)
|
||||||
LOG_TARGET_DEBUG(target, "resume all");
|
LOG_TARGET_DEBUG(target, "resume all");
|
||||||
riscv_resume(target, true, 0, 0, 0, false);
|
riscv_resume(target, true, 0, 0, 0, false);
|
||||||
} else if (halted && running) {
|
} else if (halted && running) {
|
||||||
|
foreach_smp_target(entry, targets)
|
||||||
|
{
|
||||||
|
struct target *t = entry->target;
|
||||||
|
if (t->state == TARGET_HALTED) {
|
||||||
|
riscv_reg_t dcsr;
|
||||||
|
if (riscv_reg_get(t, &dcsr, GDB_REGNO_DCSR) != ERROR_OK)
|
||||||
|
return ERROR_FAIL;
|
||||||
|
if (get_field(dcsr, CSR_DCSR_CAUSE) == CSR_DCSR_CAUSE_GROUP)
|
||||||
|
cause_groups++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (halted == cause_groups)
|
||||||
|
return ERROR_OK;
|
||||||
|
|
||||||
LOG_TARGET_DEBUG(target, "halt all; halted=%d",
|
LOG_TARGET_DEBUG(target, "halt all; halted=%d",
|
||||||
halted);
|
halted);
|
||||||
riscv_halt(target);
|
riscv_halt(target);
|
||||||
|
|
Loading…
Reference in New Issue