This is an automated email from Gerrit.

"Daniel Goehring <[email protected]>" just uploaded a new patch 
set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9251

-- gerrit

commit ab6d45e8e6b4b7d135d0eee59fa67f2afb8094a1
Author: Daniel Goehring <[email protected]>
Date:   Mon Jul 14 16:04:32 2025 -0600

    target/arm: add nested AP config file option support
    
    Add configuration file target support for a nested AP parameter.
    
    For systems with nested access ports, this additional target
    creation parameter specifies the top-level access port which
    connects to a secondary access port in a configuration file.
    
    Change-Id: Ib1f1270dbfc01a071092573c47a9373997a721fc
    Signed-off-by: Daniel Goehring <[email protected]>

diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index def4faa75a..77e3202927 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -2447,6 +2447,7 @@ int dap_lookup_cs_component(struct adiv5_ap *ap, uint8_t 
type,
 enum adiv5_cfg_param {
        CFG_DAP,
        CFG_AP_NUM,
+       CFG_AP_NUM_GATEWAY,
        CFG_BASEADDR,
        CFG_CTIBASE, /* DEPRECATED */
 };
@@ -2454,15 +2455,16 @@ enum adiv5_cfg_param {
 static const struct jim_nvp nvp_config_opts[] = {
        { .name = "-dap",       .value = CFG_DAP },
        { .name = "-ap-num",    .value = CFG_AP_NUM },
+       { .name = "-ap-num-gateway", .value = CFG_AP_NUM_GATEWAY },
        { .name = "-baseaddr",  .value = CFG_BASEADDR },
        { .name = "-ctibase",   .value = CFG_CTIBASE }, /* DEPRECATED */
        { .name = NULL, .value = -1 }
 };
 
 static int adiv5_jim_spot_configure(struct jim_getopt_info *goi,
-               struct adiv5_dap **dap_p, uint64_t *ap_num_p, uint32_t *base_p)
+               struct adiv5_dap **dap_p, uint64_t *ap_num_p, uint64_t 
*ap_num_gateway_p, uint32_t *base_p)
 {
-       assert(dap_p && ap_num_p);
+       assert(dap_p && ap_num_p && ap_num_gateway_p);
 
        if (!goi->argc)
                return JIM_OK;
@@ -2539,6 +2541,30 @@ static int adiv5_jim_spot_configure(struct 
jim_getopt_info *goi,
                }
                break;
 
+       case CFG_AP_NUM_GATEWAY:
+               if (goi->is_configure) {
+                       /* jim_wide is a signed 64 bits int, ap_num_gateway is 
unsigned with max 52 bits */
+                       jim_wide ap_num_gateway;
+                       e = jim_getopt_wide(goi, &ap_num_gateway);
+                       if (e != JIM_OK)
+                               return e;
+                       /* we still don't know dap->adi_version */
+                       if (ap_num_gateway < 0 || (ap_num_gateway > 
DP_APSEL_MAX && (ap_num_gateway & 0xfff))) {
+                               Jim_SetResultString(goi->interp, "Invalid 
AP_GATEWAY number!", -1);
+                               return JIM_ERR;
+                       }
+                       *ap_num_gateway_p = ap_num_gateway;
+               } else {
+                       if (goi->argc)
+                               goto err_no_param;
+                       if (*ap_num_gateway_p == DP_APSEL_INVALID) {
+                               Jim_SetResultString(goi->interp, "AP_GATEWAY 
number not configured", -1);
+                               return JIM_ERR;
+                       }
+                       Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, 
*ap_num_gateway_p));
+               }
+               break;
+
        case CFG_CTIBASE:
                LOG_WARNING("DEPRECATED! use \'-baseaddr' not \'-ctibase\'");
                /* fall through */
@@ -2578,6 +2604,7 @@ int adiv5_jim_configure_ext(struct target *target, struct 
jim_getopt_info *goi,
                                return JIM_ERR;
                        }
                        pc->ap_num = DP_APSEL_INVALID;
+                       pc->ap_num_gateway = DP_APSEL_INVALID;
                        target->private_config = pc;
                }
        }
@@ -2585,7 +2612,7 @@ int adiv5_jim_configure_ext(struct target *target, struct 
jim_getopt_info *goi,
        if (optional == ADI_CONFIGURE_DAP_COMPULSORY)
                target->has_dap = true;
 
-       e = adiv5_jim_spot_configure(goi, &pc->dap, &pc->ap_num, NULL);
+       e = adiv5_jim_spot_configure(goi, &pc->dap, &pc->ap_num, 
&pc->ap_num_gateway, NULL);
        if (e != JIM_OK)
                return e;
 
@@ -2623,13 +2650,14 @@ int adiv5_verify_config(struct adiv5_private_config *pc)
 int adiv5_jim_mem_ap_spot_configure(struct adiv5_mem_ap_spot *cfg,
                struct jim_getopt_info *goi)
 {
-       return adiv5_jim_spot_configure(goi, &cfg->dap, &cfg->ap_num, 
&cfg->base);
+       return adiv5_jim_spot_configure(goi, &cfg->dap, &cfg->ap_num, 
&cfg->ap_num_gateway, &cfg->base);
 }
 
 int adiv5_mem_ap_spot_init(struct adiv5_mem_ap_spot *p)
 {
        p->dap = NULL;
        p->ap_num = DP_APSEL_INVALID;
+       p->ap_num_gateway = DP_APSEL_INVALID;
        p->base = 0;
        return ERROR_OK;
 }
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 72a29faff2..27fa5a2784 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -791,6 +791,7 @@ extern int dap_cleanup_all(void);
 
 struct adiv5_private_config {
        uint64_t ap_num;
+       uint64_t ap_num_gateway;
        struct adiv5_dap *dap;
 };
 
@@ -809,6 +810,7 @@ extern int adiv5_jim_configure(struct target *target, 
struct jim_getopt_info *go
 struct adiv5_mem_ap_spot {
        struct adiv5_dap *dap;
        uint64_t ap_num;
+       uint64_t ap_num_gateway;
        uint32_t base;
 };
 

-- 

Reply via email to