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:
@@ -128,14 +128,11 @@ static int mips_m4k_debug_entry(struct target *target)
|
||||
static struct target *get_mips_m4k(struct target *target, int32_t coreid)
|
||||
{
|
||||
struct target_list *head;
|
||||
struct target *curr;
|
||||
|
||||
head = target->head;
|
||||
while (head) {
|
||||
curr = head->target;
|
||||
foreach_smp_target(head, target->smp_targets) {
|
||||
struct target *curr = head->target;
|
||||
if ((curr->coreid == coreid) && (curr->state == TARGET_HALTED))
|
||||
return curr;
|
||||
head = head->next;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
@@ -144,11 +141,10 @@ static int mips_m4k_halt_smp(struct target *target)
|
||||
{
|
||||
int retval = ERROR_OK;
|
||||
struct target_list *head;
|
||||
struct target *curr;
|
||||
head = target->head;
|
||||
while (head) {
|
||||
|
||||
foreach_smp_target(head, target->smp_targets) {
|
||||
int ret = ERROR_OK;
|
||||
curr = head->target;
|
||||
struct target *curr = head->target;
|
||||
if ((curr != target) && (curr->state != TARGET_HALTED))
|
||||
ret = mips_m4k_halt(curr);
|
||||
|
||||
@@ -156,7 +152,6 @@ static int mips_m4k_halt_smp(struct target *target)
|
||||
LOG_ERROR("halt failed target->coreid: %" PRId32, curr->coreid);
|
||||
retval = ret;
|
||||
}
|
||||
head = head->next;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -414,12 +409,10 @@ static int mips_m4k_restore_smp(struct target *target, uint32_t address, int han
|
||||
{
|
||||
int retval = ERROR_OK;
|
||||
struct target_list *head;
|
||||
struct target *curr;
|
||||
|
||||
head = target->head;
|
||||
while (head) {
|
||||
foreach_smp_target(head, target->smp_targets) {
|
||||
int ret = ERROR_OK;
|
||||
curr = head->target;
|
||||
struct target *curr = head->target;
|
||||
if ((curr != target) && (curr->state != TARGET_RUNNING)) {
|
||||
/* resume current address , not in step mode */
|
||||
ret = mips_m4k_internal_restore(curr, 1, address,
|
||||
@@ -431,7 +424,6 @@ static int mips_m4k_restore_smp(struct target *target, uint32_t address, int han
|
||||
retval = ret;
|
||||
}
|
||||
}
|
||||
head = head->next;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user