Added cleaner handling of unexamined harts
This commit is contained in:
parent
c1c46fbcad
commit
c428ed72a4
|
@ -535,7 +535,7 @@ static void riscv_deinit_target(struct target *target)
|
||||||
LOG_TARGET_DEBUG(target, "riscv_deinit_target()");
|
LOG_TARGET_DEBUG(target, "riscv_deinit_target()");
|
||||||
|
|
||||||
/* No need to deinit a target that has not been examined */
|
/* No need to deinit a target that has not been examined */
|
||||||
if (!target->examined)
|
if (!target_was_examined(target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct riscv_info *info = target->arch_info;
|
struct riscv_info *info = target->arch_info;
|
||||||
|
@ -1930,27 +1930,25 @@ int riscv_halt(struct target *target)
|
||||||
struct target_list *tlist;
|
struct target_list *tlist;
|
||||||
foreach_smp_target(tlist, target->smp_targets) {
|
foreach_smp_target(tlist, target->smp_targets) {
|
||||||
struct target *t = tlist->target;
|
struct target *t = tlist->target;
|
||||||
if (t->examined) {
|
if (target_was_examined(t))
|
||||||
if (halt_prep(t) != ERROR_OK)
|
if (halt_prep(t) != ERROR_OK)
|
||||||
result = ERROR_FAIL;
|
result = ERROR_FAIL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach_smp_target(tlist, target->smp_targets) {
|
foreach_smp_target(tlist, target->smp_targets) {
|
||||||
struct target *t = tlist->target;
|
struct target *t = tlist->target;
|
||||||
struct riscv_info *i = riscv_info(t);
|
struct riscv_info *i = riscv_info(t);
|
||||||
if (t->examined && i->prepped) {
|
if (target_was_examined(t))
|
||||||
if (halt_go(t) != ERROR_OK)
|
if (i->prepped)
|
||||||
result = ERROR_FAIL;
|
if (halt_go(t) != ERROR_OK)
|
||||||
}
|
result = ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach_smp_target(tlist, target->smp_targets) {
|
foreach_smp_target(tlist, target->smp_targets) {
|
||||||
struct target *t = tlist->target;
|
struct target *t = tlist->target;
|
||||||
if (t->examined) {
|
if (target_was_examined(t))
|
||||||
if (halt_finish(t) != ERROR_OK)
|
if (halt_finish(t) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -3214,11 +3212,6 @@ int riscv_openocd_poll(struct target *target)
|
||||||
if (!target_was_examined(t))
|
if (!target_was_examined(t))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (target->defer_examine) {
|
|
||||||
target->examined = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum riscv_next_action next_action;
|
enum riscv_next_action next_action;
|
||||||
if (riscv_poll_hart(t, &next_action) != ERROR_OK)
|
if (riscv_poll_hart(t, &next_action) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
|
|
|
@ -676,6 +676,7 @@ int target_examine_one(struct target *target)
|
||||||
|
|
||||||
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_START);
|
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_START);
|
||||||
|
|
||||||
|
bool defer_state = target->defer_examine;
|
||||||
int retval = target->type->examine(target);
|
int retval = target->type->examine(target);
|
||||||
if (retval != ERROR_OK) {
|
if (retval != ERROR_OK) {
|
||||||
LOG_TARGET_ERROR(target, "Examination failed");
|
LOG_TARGET_ERROR(target, "Examination failed");
|
||||||
|
@ -685,9 +686,14 @@ int target_examine_one(struct target *target)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_USER("[%s] Target successfully examined.", target_name(target));
|
if (target->defer_examine) {
|
||||||
if (!target->defer_examine)
|
LOG_USER("[%s] Target unavailable for full examination.", target_name(target));
|
||||||
|
target->defer_examine = defer_state;
|
||||||
|
target_reset_examined(target);
|
||||||
|
} else {
|
||||||
|
LOG_USER("[%s] Target successfully examined.", target_name(target));
|
||||||
target_set_examined(target);
|
target_set_examined(target);
|
||||||
|
}
|
||||||
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
|
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
|
||||||
|
|
||||||
LOG_TARGET_INFO(target, "Examination succeed");
|
LOG_TARGET_INFO(target, "Examination succeed");
|
||||||
|
@ -2979,7 +2985,7 @@ static int handle_target(void *priv)
|
||||||
* schedule for now+polling_interval, the next poll won't
|
* schedule for now+polling_interval, the next poll won't
|
||||||
* actually happen until a polling_interval later. */
|
* actually happen until a polling_interval later. */
|
||||||
bool poll_needed = timeval_ms() + polling_interval / 2 >= target->backoff.next_attempt;
|
bool poll_needed = timeval_ms() + polling_interval / 2 >= target->backoff.next_attempt;
|
||||||
if (!target->examined || !target->tap->enabled || power_dropout || srst_asserted || !poll_needed)
|
if (!target->tap->enabled || power_dropout || srst_asserted || !poll_needed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* polling may fail silently until the target has been examined */
|
/* polling may fail silently until the target has been examined */
|
||||||
|
@ -5262,13 +5268,18 @@ COMMAND_HANDLER(handle_target_examine)
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool defer_state = target->defer_examine;
|
||||||
int retval = target->type->examine(target);
|
int retval = target->type->examine(target);
|
||||||
if (retval != ERROR_OK) {
|
if (retval != ERROR_OK) {
|
||||||
target_reset_examined(target);
|
target_reset_examined(target);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target->defer_examine)
|
if (target->defer_examine) {
|
||||||
|
LOG_INFO("Unable to do full examination of %s", target_name(target));
|
||||||
|
target->defer_examine = defer_state;
|
||||||
|
target_reset_examined(target);
|
||||||
|
} else
|
||||||
target_set_examined(target);
|
target_set_examined(target);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
Loading…
Reference in New Issue