Halt the target again if it was reset while halted

Change-Id: I59707e7b2e1646c312d4eb8e96e9d7dfd1e128c2
This commit is contained in:
Tim Newsome 2018-03-20 12:34:17 -07:00
parent 40e0c5b976
commit e5591c2584
1 changed files with 11 additions and 3 deletions

View File

@ -2570,9 +2570,17 @@ static bool riscv013_is_halted(struct target *target)
int hartid = riscv_current_hartid(target);
LOG_INFO("Hart %d unexpectedly reset!", hartid);
/* TODO: Can we make this more obvious to eg. a gdb user? */
dmi_write(target, DMI_DMCONTROL,
set_field(DMI_DMCONTROL_DMACTIVE | DMI_DMCONTROL_ACKHAVERESET,
hartsel_mask(target), hartid));
uint32_t dmcontrol = DMI_DMCONTROL_DMACTIVE |
DMI_DMCONTROL_ACKHAVERESET;
dmcontrol = set_field(dmcontrol, hartsel_mask(target), hartid);
/* If we had been halted when we reset, request another halt. If we
* ended up running out of reset, then the user will (hopefully) get a
* message that a reset happened, that the target is running, and then
* that it is halted again once the request goes through.
*/
if (target->state == TARGET_HALTED)
dmcontrol |= DMI_DMCONTROL_HALTREQ;
dmi_write(target, DMI_DMCONTROL, dmcontrol);
}
return get_field(dmstatus, DMI_DMSTATUS_ALLHALTED);
}