target/riscv: Share single-target and SMP resume code.
Change-Id: I416d8cc4c8c5ca0337c1f7e392b6b4fa3d75757f Signed-off-by: Tim Newsome <tim@sifive.com>
This commit is contained in:
parent
5832b983f5
commit
d3bffe3d86
|
@ -1604,18 +1604,33 @@ int riscv_resume(
|
|||
{
|
||||
LOG_DEBUG("handle_breakpoints=%d", handle_breakpoints);
|
||||
int result = ERROR_OK;
|
||||
|
||||
struct list_head *targets;
|
||||
|
||||
LIST_HEAD(single_target_list);
|
||||
struct target_list single_target_entry = {
|
||||
.lh = {NULL, NULL},
|
||||
.target = target
|
||||
};
|
||||
|
||||
if (target->smp && !single_hart) {
|
||||
targets = target->smp_targets;
|
||||
} else {
|
||||
/* Make a list that just contains a single target, so we can
|
||||
* share code below. */
|
||||
list_add(&single_target_entry.lh, &single_target_list);
|
||||
targets = &single_target_list;
|
||||
}
|
||||
|
||||
struct target_list *tlist;
|
||||
foreach_smp_target_direction(resume_order == RO_NORMAL,
|
||||
tlist, target->smp_targets) {
|
||||
foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (resume_prep(t, current, address, handle_breakpoints,
|
||||
debug_execution) != ERROR_OK)
|
||||
result = ERROR_FAIL;
|
||||
}
|
||||
|
||||
foreach_smp_target_direction(resume_order == RO_NORMAL,
|
||||
tlist, target->smp_targets) {
|
||||
foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) {
|
||||
struct target *t = tlist->target;
|
||||
riscv_info_t *i = riscv_info(t);
|
||||
if (i->prepped) {
|
||||
|
@ -1625,24 +1640,12 @@ int riscv_resume(
|
|||
}
|
||||
}
|
||||
|
||||
foreach_smp_target_direction(resume_order == RO_NORMAL,
|
||||
tlist, target->smp_targets) {
|
||||
foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (resume_finish(t, debug_execution) != ERROR_OK)
|
||||
result = ERROR_FAIL;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (resume_prep(target, current, address, handle_breakpoints,
|
||||
debug_execution) != ERROR_OK)
|
||||
result = ERROR_FAIL;
|
||||
if (resume_go(target, current, address, handle_breakpoints,
|
||||
debug_execution) != ERROR_OK)
|
||||
result = ERROR_FAIL;
|
||||
if (resume_finish(target, debug_execution) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue