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:
@@ -4152,7 +4152,7 @@ static int stlink_dap_reinit_interface(void)
|
||||
stlink_dap_handle->reconnect_pending = false;
|
||||
/* on new FW, calling mode-leave closes all the opened AP; reopen them! */
|
||||
if (stlink_dap_handle->version.flags & STLINK_F_HAS_AP_INIT)
|
||||
for (int apsel = 0; apsel <= DP_APSEL_MAX; apsel++)
|
||||
for (unsigned int apsel = 0; apsel <= DP_APSEL_MAX; apsel++)
|
||||
if (test_bit(apsel, opened_ap)) {
|
||||
clear_bit(apsel, opened_ap);
|
||||
stlink_dap_open_ap(apsel);
|
||||
@@ -4348,7 +4348,7 @@ static int stlink_usb_misc_rw_segment(void *handle, const struct dap_queue *q, u
|
||||
|
||||
LOG_DEBUG("Queue: %u commands in %u items", len, items);
|
||||
|
||||
int ap_num = DP_APSEL_INVALID;
|
||||
uint32_t ap_num = DP_APSEL_INVALID;
|
||||
unsigned int cmd_index = 0;
|
||||
unsigned int val_index = ALIGN_UP(items, 4);
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
@@ -4497,7 +4497,7 @@ static int stlink_usb_count_misc_rw_queue(void *handle, const struct dap_queue *
|
||||
{
|
||||
struct stlink_usb_handle_s *h = handle;
|
||||
unsigned int i, items = 0;
|
||||
int ap_num = DP_APSEL_INVALID;
|
||||
uint32_t ap_num = DP_APSEL_INVALID;
|
||||
unsigned int misc_max_items = (h->version.stlink == 2) ? STLINK_V2_RW_MISC_SIZE : STLINK_V3_RW_MISC_SIZE;
|
||||
|
||||
if (!(h->version.flags & STLINK_F_HAS_RW_MISC))
|
||||
@@ -4864,9 +4864,10 @@ static int stlink_dap_op_queue_ap_write(struct adiv5_ap *ap, unsigned int reg,
|
||||
q->ap_w.reg = reg;
|
||||
q->ap_w.ap = ap;
|
||||
q->ap_w.data = data;
|
||||
if (reg == ADIV5_MEM_AP_REG_CSW && ap->csw_default != last_csw_default[ap->ap_num]) {
|
||||
uint8_t ap_num = ap->ap_num;
|
||||
if (reg == ADIV5_MEM_AP_REG_CSW && ap->csw_default != last_csw_default[ap_num]) {
|
||||
q->ap_w.changes_csw_default = true;
|
||||
last_csw_default[ap->ap_num] = ap->csw_default;
|
||||
last_csw_default[ap_num] = ap->csw_default;
|
||||
} else {
|
||||
q->ap_w.changes_csw_default = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user