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:
Antonio Borneo
2021-12-16 01:59:14 +01:00
parent 5ab74bde06
commit 16cc853bcf
16 changed files with 136 additions and 178 deletions

View File

@@ -333,15 +333,14 @@ static int aarch64_wait_halt_one(struct target *target)
static int aarch64_prepare_halt_smp(struct target *target, bool exc_target, struct target **p_first)
{
int retval = ERROR_OK;
struct target_list *head = target->head;
struct target_list *head;
struct target *first = NULL;
LOG_DEBUG("target %s exc %i", target_name(target), exc_target);
while (head) {
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
struct armv8_common *armv8 = target_to_armv8(curr);
head = head->next;
if (exc_target && curr == target)
continue;
@@ -430,7 +429,7 @@ static int aarch64_halt_smp(struct target *target, bool exc_target)
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->head) {
foreach_smp_target(head, target->smp_targets) {
int halted;
curr = head->target;
@@ -480,7 +479,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
}
/* poll all targets in the group, but skip the target that serves GDB */
foreach_smp_target(head, target->head) {
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
/* skip calling context */
if (curr == target)
@@ -745,7 +744,7 @@ static int aarch64_prep_restart_smp(struct target *target, int handle_breakpoint
struct target *first = NULL;
uint64_t address;
foreach_smp_target(head, target->head) {
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
/* skip calling target */
@@ -800,7 +799,7 @@ static int aarch64_step_restart_smp(struct target *target)
struct target *curr = target;
bool all_resumed = true;
foreach_smp_target(head, target->head) {
foreach_smp_target(head, target->smp_targets) {
uint32_t prsr;
int resumed;
@@ -888,7 +887,7 @@ static int aarch64_resume(struct target *target, int current,
struct target_list *head;
bool all_resumed = true;
foreach_smp_target(head, target->head) {
foreach_smp_target(head, target->smp_targets) {
uint32_t prsr;
int resumed;