Skip to content

Commit

Permalink
ARC: add private register_get_by_name function
Browse files Browse the repository at this point in the history
In ARC case we have TCL function arc_set_reg_exists to mark register as existing.
In this function register_get_by_name() is called, which currently skips
register, if it is not existing. Thats why we introduce private version without
existance check.

Commit is based on:
zephyrproject-rtos/openocd@5b23e3b

Signed-off-by: Evgeniy Didin <didin@synopsys.com>
  • Loading branch information
EvgeniiDidin committed Jun 20, 2019
1 parent 2c1c26e commit e6f7cf6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/target/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,35 @@ void arc_add_reg_data_type(struct target *target,
list_add_tail(&data_type->list, &arc->reg_data_types);
}

/* ----- Exported functions ------------------------------------------------ */

/**
* Private implementation of register_get_by_name() for ARC that
* doesn't skip not [yet] existing registers. Used in many places
* for iteration through registers and even for marking required registers as
* existing.
*/
struct reg *arc32_register_get_by_name(struct reg_cache *first,
const char *name, bool search_all)
{
unsigned i;
struct reg_cache *cache = first;

while (cache) {
for (i = 0; i < cache->num_regs; i++) {
if (strcmp(cache->reg_list[i].name, name) == 0)
return &(cache->reg_list[i]);
}

if (search_all)
cache = cache->next;
else
break;
}

return NULL;
}


/* Initialize arc_common structure, which passes to openocd target instance */
int arc_init_arch_info(struct target *target, struct arc_common *arc,
Expand Down
4 changes: 4 additions & 0 deletions src/target/arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,8 @@ int arc_add_reg(struct target *target, struct arc_reg_desc *arc_reg,
int arc_build_reg_cache(struct target *target);
int arc_build_bcr_reg_cache(struct target *target);


struct reg *arc32_register_get_by_name(struct reg_cache *first,
const char *name, bool search_all);

#endif /* ARC_H */

0 comments on commit e6f7cf6

Please sign in to comment.