This patch implements "dap_lookup_cs_component()", which allows to lookup CS component by it's identification.
Signed-off-by: Marek Vasut <marek.va...@gmail.com> --- src/target/arm_adi_v5.c | 31 +++++++++++++++++++++++++++++++ src/target/arm_adi_v5.h | 4 ++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index 4c54308..8f41e36 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1038,6 +1038,37 @@ int dap_get_debugbase(struct adiv5_dap *dap, int apsel, return ERROR_OK; } +int dap_lookup_cs_component(struct adiv5_dap *dap, uint32_t apsel, + uint32_t dbgbase, uint8_t type, uint32_t *addr) +{ + uint32_t romentry, entry_offset = 0, component_base, devtype; + int retval; + + do + { + retval = mem_ap_read_atomic_u32(dap, (dbgbase&0xFFFFF000) | + entry_offset, &romentry); + if (retval != ERROR_OK) + return retval; + + component_base = (dbgbase & 0xFFFFF000) + + (romentry & 0xFFFFF000); + + if (romentry & 0x1) { + retval = mem_ap_read_atomic_u32(dap, + (component_base & 0xfffff000) | 0xfcc, + &devtype); + if ((devtype & 0xff) == type) { + *addr = component_base; + return ERROR_OK; + } + } + entry_offset += 4; + } while (romentry > 0); + return ERROR_FAIL; + +} + static int dap_info_command(struct command_context *cmd_ctx, struct adiv5_dap *dap, int apsel) { diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index c499755..5fb38cf 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -390,6 +390,10 @@ int ahbap_debugport_init(struct adiv5_dap *swjdp); int dap_get_debugbase(struct adiv5_dap *dap, int apsel, uint32_t *dbgbase, uint32_t *apid); +/* Lookup CoreSight component */ +int dap_lookup_cs_component(struct adiv5_dap *dap, uint32_t apsel, + uint32_t dbgbase, uint8_t type, uint32_t *addr); + struct target; /* Put debug link into SWD mode */ -- 1.7.2.3 _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development