adiv6: use struct adiv5_ap->ap_num to contain the AP base address

ADIv5 DAP can only have 256 AP, while ADIv6 can provide till
2**40 (1,099,511,627,776) AP per DAP.

Reuse the field ap_num in struct adiv5_ap, currently used on ADIv5
to hold the ADIv5 AP number (apsel), to contain the ADIv6 AP base
address.

Convert struct adiv5_ap->ap_num to 64 bit and initialize it to
DP_APSEL_INVALID for unused AP.
Restrict dap_find_get_ap() to ADIv5 only. To be enhanced.
On ADIv6, let dap_get_ap() return an already allocated AP, or
allocate and return an unused AP.
Add function is_ap_num_valid() and use it.

Change-Id: Ib2fe8c7ec0d08393cd91c29fdac5d632dfc1e438
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6461
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2021-08-14 23:56:12 +02:00
parent 72fb88613f
commit 3f4bc6ce7f
9 changed files with 156 additions and 73 deletions

View File

@@ -50,7 +50,7 @@ static void dap_instance_init(struct adiv5_dap *dap)
/* Set up with safe defaults */
for (i = 0; i <= DP_APSEL_MAX; i++) {
dap->ap[i].dap = dap;
dap->ap[i].ap_num = i;
dap->ap[i].ap_num = DP_APSEL_INVALID;
/* memaccess_tck max is 255 */
dap->ap[i].memaccess_tck = 255;
/* Number of bits for tar autoincrement, impl. dep. at least 10 */
@@ -459,7 +459,7 @@ COMMAND_HANDLER(handle_dap_info_command)
struct target *target = get_current_target(CMD_CTX);
struct arm *arm = target_to_arm(target);
struct adiv5_dap *dap = arm->dap;
uint32_t apsel;
uint64_t apsel;
if (!dap) {
LOG_ERROR("DAP instance not available. Probably a HLA target...");
@@ -471,8 +471,8 @@ COMMAND_HANDLER(handle_dap_info_command)
apsel = dap->apsel;
break;
case 1:
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
if (apsel > DP_APSEL_MAX)
COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], apsel);
if (!is_ap_num_valid(dap, apsel))
return ERROR_COMMAND_SYNTAX_ERROR;
break;
default: