arm_adi_v5: let dap_lookup_cs_component() to get AP dbgbase

Simplify the code in cortex_a and aarch64 by moving the call to
dap_get_debugbase() inside dap_lookup_cs_component().

This has the further effects:
- dap_get_debugbase() is not referenced outside arm_adi_v5.c and
  becomes static;
- dap_lookup_cs_component() looses one parameter;
- the coreid parameter 'idx' is passed as value;
- the caller in aarch64 don't have and don't print the irrelevant
  value of AP register APID;
- fixes the debug message in the caller in aarch64 to print the
  coreid value instead of always zero.

Change-Id: Ic7f0f643fdf067c059c8f2455a02ff18a3fed054
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6823
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2022-01-15 18:34:21 +01:00
parent 7351330a0f
commit 613f1c6abb
4 changed files with 24 additions and 28 deletions

View File

@@ -1002,7 +1002,7 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_a
return ERROR_FAIL;
}
int dap_get_debugbase(struct adiv5_ap *ap,
static int dap_get_debugbase(struct adiv5_ap *ap,
target_addr_t *dbgbase, uint32_t *apid)
{
struct adiv5_dap *dap = ap->dap;
@@ -1038,7 +1038,7 @@ int dap_get_debugbase(struct adiv5_ap *ap,
return ERROR_OK;
}
int dap_lookup_cs_component(struct adiv5_ap *ap,
static int _dap_lookup_cs_component(struct adiv5_ap *ap,
target_addr_t dbgbase, uint8_t type, target_addr_t *addr, int32_t *idx)
{
uint32_t romentry, entry_offset = 0, devtype;
@@ -1066,7 +1066,7 @@ int dap_lookup_cs_component(struct adiv5_ap *ap,
}
unsigned int class = (c_cid1 & ARM_CS_CIDR1_CLASS_MASK) >> ARM_CS_CIDR1_CLASS_SHIFT;
if (class == ARM_CS_CLASS_0X1_ROM_TABLE) {
retval = dap_lookup_cs_component(ap, component_base,
retval = _dap_lookup_cs_component(ap, component_base,
type, addr, idx);
if (retval == ERROR_OK)
break;
@@ -1094,6 +1094,20 @@ int dap_lookup_cs_component(struct adiv5_ap *ap,
return ERROR_OK;
}
int dap_lookup_cs_component(struct adiv5_ap *ap, uint8_t type,
target_addr_t *addr, int32_t core_id)
{
int32_t idx = core_id;
target_addr_t dbgbase;
uint32_t apid;
int retval = dap_get_debugbase(ap, &dbgbase, &apid);
if (retval != ERROR_OK)
return retval;
return _dap_lookup_cs_component(ap, dbgbase, type, addr, &idx);
}
/** Holds registers and coordinates of a CoreSight component */
struct cs_component_vals {
struct adiv5_ap *ap;