Fix jim_target_smp for smp rtos target
If multiple targets are specified as -rtos <rtos_type>, the rtos_update_threads was called only if the last target was specified as rtos, which is inconsistent with other checks of whether or not smp target is an rtos one. Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Change-Id: Ie52bc6b6c8f841d31b9590fcbc44e985d3cba0eb Reviewed-on: https://review.openocd.org/c/openocd/+/7244 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
4fe3997294
commit
04887d3b68
|
@ -6433,16 +6433,52 @@ static int jim_target_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||||
return JIM_OK;
|
return JIM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct target_list *
|
||||||
|
__attribute__((warn_unused_result))
|
||||||
|
create_target_list_node(Jim_Obj *const name) {
|
||||||
|
int len;
|
||||||
|
const char *targetname = Jim_GetString(name, &len);
|
||||||
|
struct target *target = get_target(targetname);
|
||||||
|
LOG_DEBUG("%s ", targetname);
|
||||||
|
if (!target)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
struct target_list *new = malloc(sizeof(struct target_list));
|
||||||
|
if (!new) {
|
||||||
|
LOG_ERROR("Out of memory");
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
new->target = target;
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_target_with_common_rtos_type(struct list_head *lh, struct target **result)
|
||||||
|
{
|
||||||
|
struct target *target = NULL;
|
||||||
|
struct target_list *curr;
|
||||||
|
foreach_smp_target(curr, lh) {
|
||||||
|
struct rtos *curr_rtos = curr->target->rtos;
|
||||||
|
if (curr_rtos) {
|
||||||
|
if (target && target->rtos && target->rtos->type != curr_rtos->type) {
|
||||||
|
LOG_ERROR("Different rtos types in members of one smp target!");
|
||||||
|
return JIM_ERR;
|
||||||
|
}
|
||||||
|
target = curr->target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*result = target;
|
||||||
|
return JIM_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
const char *targetname;
|
|
||||||
int retval, len;
|
|
||||||
static int smp_group = 1;
|
static int smp_group = 1;
|
||||||
struct target *target = NULL;
|
|
||||||
struct target_list *head, *new;
|
|
||||||
|
|
||||||
retval = 0;
|
if (argc == 1) {
|
||||||
|
LOG_DEBUG("Empty SMP target");
|
||||||
|
return JIM_OK;
|
||||||
|
}
|
||||||
LOG_DEBUG("%d", argc);
|
LOG_DEBUG("%d", argc);
|
||||||
/* argv[1] = target to associate in smp
|
/* argv[1] = target to associate in smp
|
||||||
* argv[2] = target to associate in smp
|
* argv[2] = target to associate in smp
|
||||||
|
@ -6456,27 +6492,24 @@ static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||||
}
|
}
|
||||||
INIT_LIST_HEAD(lh);
|
INIT_LIST_HEAD(lh);
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
|
struct target_list *new = create_target_list_node(argv[i]);
|
||||||
targetname = Jim_GetString(argv[i], &len);
|
if (new)
|
||||||
target = get_target(targetname);
|
|
||||||
LOG_DEBUG("%s ", targetname);
|
|
||||||
if (target) {
|
|
||||||
new = malloc(sizeof(struct target_list));
|
|
||||||
new->target = target;
|
|
||||||
list_add_tail(&new->lh, lh);
|
list_add_tail(&new->lh, lh);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* now parse the list of cpu and put the target in smp mode*/
|
/* now parse the list of cpu and put the target in smp mode*/
|
||||||
foreach_smp_target(head, lh) {
|
struct target_list *curr;
|
||||||
target = head->target;
|
foreach_smp_target(curr, lh) {
|
||||||
|
struct target *target = curr->target;
|
||||||
target->smp = smp_group;
|
target->smp = smp_group;
|
||||||
target->smp_targets = lh;
|
target->smp_targets = lh;
|
||||||
}
|
}
|
||||||
smp_group++;
|
smp_group++;
|
||||||
|
|
||||||
if (target && target->rtos)
|
struct target *rtos_target;
|
||||||
retval = rtos_smp_init(target);
|
int retval = get_target_with_common_rtos_type(lh, &rtos_target);
|
||||||
|
if (retval == JIM_OK && rtos_target)
|
||||||
|
retval = rtos_smp_init(rtos_target);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue