forked from auracaster/openocd
target/smp: use a struct list_head to hold the smp targets
Instead of reinventing a simply linked list, reuse the list helper for the list of targets in a smp cluster. Using the existing helper, that implements a double linked list, makes trivial going through the list in reverse order. Change-Id: Ib36ad2955f15cd2a601b0b9e36ca6d948b12d00f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6783 Tested-by: jenkins
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "target/target.h"
|
||||
#include "target/algorithm.h"
|
||||
#include "target/target_type.h"
|
||||
#include <target/smp.h>
|
||||
#include "jtag/jtag.h"
|
||||
#include "target/register.h"
|
||||
#include "target/breakpoints.h"
|
||||
@@ -1232,13 +1233,14 @@ int riscv_halt(struct target *target)
|
||||
|
||||
int result = ERROR_OK;
|
||||
if (target->smp) {
|
||||
for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) {
|
||||
struct target_list *tlist;
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (halt_prep(t) != ERROR_OK)
|
||||
result = ERROR_FAIL;
|
||||
}
|
||||
|
||||
for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) {
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
riscv_info_t *i = riscv_info(t);
|
||||
if (i->prepped) {
|
||||
@@ -1247,7 +1249,7 @@ int riscv_halt(struct target *target)
|
||||
}
|
||||
}
|
||||
|
||||
for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) {
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (halt_finish(t) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
@@ -1469,14 +1471,15 @@ int riscv_resume(
|
||||
LOG_DEBUG("handle_breakpoints=%d", handle_breakpoints);
|
||||
int result = ERROR_OK;
|
||||
if (target->smp && !single_hart) {
|
||||
for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) {
|
||||
struct target_list *tlist;
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (resume_prep(t, current, address, handle_breakpoints,
|
||||
debug_execution) != ERROR_OK)
|
||||
result = ERROR_FAIL;
|
||||
}
|
||||
|
||||
for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) {
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
riscv_info_t *i = riscv_info(t);
|
||||
if (i->prepped) {
|
||||
@@ -1486,7 +1489,7 @@ int riscv_resume(
|
||||
}
|
||||
}
|
||||
|
||||
for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) {
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (resume_finish(t) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
@@ -2180,9 +2183,8 @@ int riscv_openocd_poll(struct target *target)
|
||||
unsigned halts_discovered = 0;
|
||||
unsigned should_remain_halted = 0;
|
||||
unsigned should_resume = 0;
|
||||
unsigned i = 0;
|
||||
for (struct target_list *list = target->head; list;
|
||||
list = list->next, i++) {
|
||||
struct target_list *list;
|
||||
foreach_smp_target(list, target->smp_targets) {
|
||||
struct target *t = list->target;
|
||||
riscv_info_t *r = riscv_info(t);
|
||||
enum riscv_poll_hart out = riscv_poll_hart(t, r->current_hartid);
|
||||
@@ -2242,8 +2244,7 @@ int riscv_openocd_poll(struct target *target)
|
||||
}
|
||||
|
||||
/* Sample memory if any target is running. */
|
||||
for (struct target_list *list = target->head; list;
|
||||
list = list->next, i++) {
|
||||
foreach_smp_target(list, target->smp_targets) {
|
||||
struct target *t = list->target;
|
||||
if (t->state == TARGET_RUNNING) {
|
||||
sample_memory(target);
|
||||
|
||||
Reference in New Issue
Block a user