target: remove `target_number`
Change-Id: Id36e5ad2967303483392fd2670630289ecde2553 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7998 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
This commit is contained in:
parent
53e67c37ab
commit
be5cfdc86b
|
@ -298,23 +298,6 @@ const char *target_reset_mode_name(enum target_reset_mode reset_mode)
|
|||
return cp;
|
||||
}
|
||||
|
||||
/* determine the number of the new target */
|
||||
static int new_target_number(void)
|
||||
{
|
||||
struct target *t;
|
||||
int x;
|
||||
|
||||
/* number is 0 based */
|
||||
x = -1;
|
||||
t = all_targets;
|
||||
while (t) {
|
||||
if (x < t->target_number)
|
||||
x = t->target_number;
|
||||
t = t->next;
|
||||
}
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
static void append_to_list_all_targets(struct target *target)
|
||||
{
|
||||
struct target **t = &all_targets;
|
||||
|
@ -450,7 +433,7 @@ void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_
|
|||
target_buffer_set_u16(target, &buffer[i * 2], srcbuf[i]);
|
||||
}
|
||||
|
||||
/* return a pointer to a configured target; id is name or number */
|
||||
/* return a pointer to a configured target; id is name or index in all_targets */
|
||||
struct target *get_target(const char *id)
|
||||
{
|
||||
struct target *target;
|
||||
|
@ -463,36 +446,17 @@ struct target *get_target(const char *id)
|
|||
return target;
|
||||
}
|
||||
|
||||
/* It's OK to remove this fallback sometime after August 2010 or so */
|
||||
|
||||
/* no match, try as number */
|
||||
unsigned num;
|
||||
if (parse_uint(id, &num) != ERROR_OK)
|
||||
/* try as index */
|
||||
unsigned int index, counter;
|
||||
if (parse_uint(id, &index) != ERROR_OK)
|
||||
return NULL;
|
||||
|
||||
for (target = all_targets; target; target = target->next) {
|
||||
if (target->target_number == (int)num) {
|
||||
LOG_WARNING("use '%s' as target identifier, not '%u'",
|
||||
target_name(target), num);
|
||||
for (target = all_targets, counter = index;
|
||||
target && counter;
|
||||
target = target->next, --counter)
|
||||
;
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* returns a pointer to the n-th configured target */
|
||||
struct target *get_target_by_num(int num)
|
||||
{
|
||||
struct target *target = all_targets;
|
||||
|
||||
while (target) {
|
||||
if (target->target_number == num)
|
||||
return target;
|
||||
target = target->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct target *get_current_target(struct command_context *cmd_ctx)
|
||||
|
@ -2843,10 +2807,10 @@ COMMAND_HANDLER(handle_targets_command)
|
|||
}
|
||||
}
|
||||
|
||||
struct target *target = all_targets;
|
||||
unsigned int index = 0;
|
||||
command_print(CMD, " TargetName Type Endian TapName State ");
|
||||
command_print(CMD, "-- ------------------ ---------- ------ ------------------ ------------");
|
||||
while (target) {
|
||||
for (struct target *target = all_targets; target; target = target->next, ++index) {
|
||||
const char *state;
|
||||
char marker = ' ';
|
||||
|
||||
|
@ -2861,7 +2825,7 @@ COMMAND_HANDLER(handle_targets_command)
|
|||
/* keep columns lined up to match the headers above */
|
||||
command_print(CMD,
|
||||
"%2d%c %-18s %-10s %-6s %-18s %s",
|
||||
target->target_number,
|
||||
index,
|
||||
marker,
|
||||
target_name(target),
|
||||
target_type_name(target),
|
||||
|
@ -2869,7 +2833,6 @@ COMMAND_HANDLER(handle_targets_command)
|
|||
target->endianness)->name,
|
||||
target->tap->dotted_name,
|
||||
state);
|
||||
target = target->next;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
@ -5063,8 +5026,7 @@ void target_handle_event(struct target *target, enum target_event e)
|
|||
|
||||
for (teap = target->event_action; teap; teap = teap->next) {
|
||||
if (teap->event == e) {
|
||||
LOG_DEBUG("target(%d): %s (%s) event: %d (%s) action: %s",
|
||||
target->target_number,
|
||||
LOG_DEBUG("target: %s (%s) event: %d (%s) action: %s",
|
||||
target_name(target),
|
||||
target_type_name(target),
|
||||
e,
|
||||
|
@ -5849,8 +5811,7 @@ COMMAND_HANDLER(handle_target_event_list)
|
|||
struct target *target = get_current_target(CMD_CTX);
|
||||
struct target_event_action *teap = target->event_action;
|
||||
|
||||
command_print(CMD, "Event actions for target (%d) %s\n",
|
||||
target->target_number,
|
||||
command_print(CMD, "Event actions for target %s\n",
|
||||
target_name(target));
|
||||
command_print(CMD, "%-25s | Body", "Event");
|
||||
command_print(CMD, "------------------------- | "
|
||||
|
@ -6189,9 +6150,6 @@ static int target_create(struct jim_getopt_info *goi)
|
|||
/* set empty smp cluster */
|
||||
target->smp_targets = &empty_smp_targets;
|
||||
|
||||
/* set target number */
|
||||
target->target_number = new_target_number();
|
||||
|
||||
/* allocate memory for each unique target type */
|
||||
target->type = malloc(sizeof(struct target_type));
|
||||
if (!target->type) {
|
||||
|
|
|
@ -115,7 +115,6 @@ enum target_register_class {
|
|||
struct target {
|
||||
struct target_type *type; /* target type definition (name, access functions) */
|
||||
char *cmd_name; /* tcl Name of target */
|
||||
int target_number; /* DO NOT USE! field to be removed in 2010 */
|
||||
struct jtag_tap *tap; /* where on the jtag chain is this */
|
||||
int32_t coreid; /* which device on the TAP? */
|
||||
|
||||
|
@ -412,7 +411,6 @@ int target_call_timer_callbacks_now(void);
|
|||
*/
|
||||
int64_t target_timer_next_event(void);
|
||||
|
||||
struct target *get_target_by_num(int num);
|
||||
struct target *get_current_target(struct command_context *cmd_ctx);
|
||||
struct target *get_current_target_or_null(struct command_context *cmd_ctx);
|
||||
struct target *get_target(const char *id);
|
||||
|
|
|
@ -1096,7 +1096,7 @@ int xtensa_assert_reset(struct target *target)
|
|||
{
|
||||
struct xtensa *xtensa = target_to_xtensa(target);
|
||||
|
||||
LOG_TARGET_DEBUG(target, "target_number=%i, begin", target->target_number);
|
||||
LOG_TARGET_DEBUG(target, " begin");
|
||||
xtensa_queue_pwr_reg_write(xtensa,
|
||||
XDMREG_PWRCTL,
|
||||
PWRCTL_JTAGDEBUGUSE(xtensa) | PWRCTL_DEBUGWAKEUP(xtensa) | PWRCTL_MEMWAKEUP(xtensa) |
|
||||
|
|
Loading…
Reference in New Issue