From e6f7cf6ee8fec8286b025c989064b09f3f90325b Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Thu, 20 Jun 2019 18:17:41 +0300 Subject: [PATCH] ARC: add private register_get_by_name function 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: https://github.com/zephyrproject-rtos/openocd/commit/5b23e3b553a916809ac59967c06278942c37447d Signed-off-by: Evgeniy Didin --- src/target/arc.c | 29 +++++++++++++++++++++++++++++ src/target/arc.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/target/arc.c b/src/target/arc.c index 6dad3f89b..02e861394 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -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, diff --git a/src/target/arc.h b/src/target/arc.h index 5f63ce385..59499c680 100644 --- a/src/target/arc.h +++ b/src/target/arc.h @@ -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 */