arm_adi_v5: abstract actions during ROM table parsing
[openocd.git] / src / target / arm_adi_v5.c
index 3ac89719ba11a398aba68789c31460371032e0aa..54d04abd62a4309ff965efaff2c6623b26f95891 100644 (file)
@@ -893,6 +893,79 @@ static const char *class_description[16] = {
        [0xF] = "CoreLink, PrimeCell or System component",
 };
 
+#define ARCH_ID(architect, archid) ( \
+       (((architect) << ARM_CS_C9_DEVARCH_ARCHITECT_SHIFT) & ARM_CS_C9_DEVARCH_ARCHITECT_MASK) | \
+       (((archid) << ARM_CS_C9_DEVARCH_ARCHID_SHIFT) & ARM_CS_C9_DEVARCH_ARCHID_MASK) \
+)
+
+static const struct {
+       uint32_t arch_id;
+       const char *description;
+} class0x9_devarch[] = {
+       /* keep same unsorted order as in ARM IHI0029E */
+       { ARCH_ID(ARM_ID, 0x0A00), "RAS architecture" },
+       { ARCH_ID(ARM_ID, 0x1A01), "Instrumentation Trace Macrocell (ITM) architecture" },
+       { ARCH_ID(ARM_ID, 0x1A02), "DWT architecture" },
+       { ARCH_ID(ARM_ID, 0x1A03), "Flash Patch and Breakpoint unit (FPB) architecture" },
+       { ARCH_ID(ARM_ID, 0x2A04), "Processor debug architecture (ARMv8-M)" },
+       { ARCH_ID(ARM_ID, 0x6A05), "Processor debug architecture (ARMv8-R)" },
+       { ARCH_ID(ARM_ID, 0x0A10), "PC sample-based profiling" },
+       { ARCH_ID(ARM_ID, 0x4A13), "Embedded Trace Macrocell (ETM) architecture" },
+       { ARCH_ID(ARM_ID, 0x1A14), "Cross Trigger Interface (CTI) architecture" },
+       { ARCH_ID(ARM_ID, 0x6A15), "Processor debug architecture (v8.0-A)" },
+       { ARCH_ID(ARM_ID, 0x7A15), "Processor debug architecture (v8.1-A)" },
+       { ARCH_ID(ARM_ID, 0x8A15), "Processor debug architecture (v8.2-A)" },
+       { ARCH_ID(ARM_ID, 0x2A16), "Processor Performance Monitor (PMU) architecture" },
+       { ARCH_ID(ARM_ID, 0x0A17), "Memory Access Port v2 architecture" },
+       { ARCH_ID(ARM_ID, 0x0A27), "JTAG Access Port v2 architecture" },
+       { ARCH_ID(ARM_ID, 0x0A31), "Basic trace router" },
+       { ARCH_ID(ARM_ID, 0x0A37), "Power requestor" },
+       { ARCH_ID(ARM_ID, 0x0A47), "Unknown Access Port v2 architecture" },
+       { ARCH_ID(ARM_ID, 0x0A50), "HSSTP architecture" },
+       { ARCH_ID(ARM_ID, 0x0A63), "System Trace Macrocell (STM) architecture" },
+       { ARCH_ID(ARM_ID, 0x0A75), "CoreSight ELA architecture" },
+       { ARCH_ID(ARM_ID, 0x0AF7), "CoreSight ROM architecture" },
+};
+
+#define DEVARCH_ID_MASK         (ARM_CS_C9_DEVARCH_ARCHITECT_MASK | ARM_CS_C9_DEVARCH_ARCHID_MASK)
+#define DEVARCH_ROM_C_0X9       ARCH_ID(ARM_ID, 0x0AF7)
+
+static const char *class0x9_devarch_description(uint32_t devarch)
+{
+       if (!(devarch & ARM_CS_C9_DEVARCH_PRESENT))
+               return "not present";
+
+       for (unsigned int i = 0; i < ARRAY_SIZE(class0x9_devarch); i++)
+               if ((devarch & DEVARCH_ID_MASK) == class0x9_devarch[i].arch_id)
+                       return class0x9_devarch[i].description;
+
+       return "unknown";
+}
+
+static const struct {
+       enum ap_type type;
+       const char *description;
+} ap_types[] = {
+       { AP_TYPE_JTAG_AP,  "JTAG-AP" },
+       { AP_TYPE_COM_AP,   "COM-AP" },
+       { AP_TYPE_AHB3_AP,  "MEM-AP AHB3" },
+       { AP_TYPE_APB_AP,   "MEM-AP APB2 or APB3" },
+       { AP_TYPE_AXI_AP,   "MEM-AP AXI3 or AXI4" },
+       { AP_TYPE_AHB5_AP,  "MEM-AP AHB5" },
+       { AP_TYPE_APB4_AP,  "MEM-AP APB4" },
+       { AP_TYPE_AXI5_AP,  "MEM-AP AXI5" },
+       { AP_TYPE_AHB5H_AP, "MEM-AP AHB5 with enhanced HPROT" },
+};
+
+static const char *ap_type_to_description(enum ap_type type)
+{
+       for (unsigned int i = 0; i < ARRAY_SIZE(ap_types); i++)
+               if (type == ap_types[i].type)
+                       return ap_types[i].description;
+
+       return "Unknown";
+}
+
 /*
  * This function checks the ID for each access port to find the requested Access Port type
  */
@@ -912,29 +985,12 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_a
 
                retval = dap_run(dap);
 
-               /* IDR bits:
-                * 31-28 : Revision
-                * 27-24 : JEDEC bank (0x4 for ARM)
-                * 23-17 : JEDEC code (0x3B for ARM)
-                * 16-13 : Class (0b1000=Mem-AP)
-                * 12-8  : Reserved
-                *  7-4  : AP Variant (non-zero for JTAG-AP)
-                *  3-0  : AP Type (0=JTAG-AP 1=AHB-AP 2=APB-AP 4=AXI-AP)
-                */
-
                /* Reading register for a non-existent AP should not cause an error,
                 * but just to be sure, try to continue searching if an error does happen.
                 */
-               if ((retval == ERROR_OK) &&                  /* Register read success */
-                       ((id_val & IDR_JEP106) == IDR_JEP106_ARM) && /* Jedec codes match */
-                       ((id_val & IDR_TYPE) == type_to_find)) {      /* type matches*/
-
+               if (retval == ERROR_OK && (id_val & AP_TYPE_MASK) == type_to_find) {
                        LOG_DEBUG("Found %s at AP index: %d (IDR=0x%08" PRIX32 ")",
-                                               (type_to_find == AP_TYPE_AHB3_AP)  ? "AHB3-AP"  :
-                                               (type_to_find == AP_TYPE_AHB5_AP)  ? "AHB5-AP"  :
-                                               (type_to_find == AP_TYPE_APB_AP)  ? "APB-AP"  :
-                                               (type_to_find == AP_TYPE_AXI_AP)  ? "AXI-AP"  :
-                                               (type_to_find == AP_TYPE_JTAG_AP) ? "JTAG-AP" : "Unknown",
+                                               ap_type_to_description(type_to_find),
                                                ap_num, id_val);
 
                        *ap_out = &dap->ap[ap_num];
@@ -942,12 +998,7 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_a
                }
        }
 
-       LOG_DEBUG("No %s found",
-                               (type_to_find == AP_TYPE_AHB3_AP)  ? "AHB3-AP"  :
-                               (type_to_find == AP_TYPE_AHB5_AP)  ? "AHB5-AP"  :
-                               (type_to_find == AP_TYPE_APB_AP)  ? "APB-AP"  :
-                               (type_to_find == AP_TYPE_AXI_AP)  ? "AXI-AP"  :
-                               (type_to_find == AP_TYPE_JTAG_AP) ? "JTAG-AP" : "Unknown");
+       LOG_DEBUG("No %s found", ap_type_to_description(type_to_find));
        return ERROR_FAIL;
 }
 
@@ -1043,53 +1094,89 @@ int dap_lookup_cs_component(struct adiv5_ap *ap,
        return ERROR_OK;
 }
 
-static int dap_read_part_id(struct adiv5_ap *ap, target_addr_t component_base, uint32_t *cid, uint64_t *pid)
+/** Holds registers and coordinates of a CoreSight component */
+struct cs_component_vals {
+       struct adiv5_ap *ap;
+       target_addr_t component_base;
+       uint64_t pid;
+       uint32_t cid;
+       uint32_t devarch;
+       uint32_t devid;
+       uint32_t devtype_memtype;
+};
+
+/**
+ * Read the CoreSight registers needed during ROM Table Parsing (RTP).
+ *
+ * @param ap             Pointer to AP containing the component.
+ * @param component_base On MEM-AP access method, base address of the component.
+ * @param v              Pointer to the struct holding the value of registers.
+ *
+ * @return ERROR_OK on success, else a fault code.
+ */
+static int rtp_read_cs_regs(struct adiv5_ap *ap, target_addr_t component_base,
+               struct cs_component_vals *v)
 {
        assert(IS_ALIGNED(component_base, ARM_CS_ALIGN));
-       assert(ap && cid && pid);
+       assert(ap && v);
 
        uint32_t cid0, cid1, cid2, cid3;
        uint32_t pid0, pid1, pid2, pid3, pid4;
-       int retval;
+       int retval = ERROR_OK;
 
-       /* IDs are in last 4K section */
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR0, &pid0);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR1, &pid1);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR2, &pid2);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR3, &pid3);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR4, &pid4);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR0, &cid0);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR1, &cid1);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR2, &cid2);
-       if (retval != ERROR_OK)
-               return retval;
-       retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR3, &cid3);
-       if (retval != ERROR_OK)
-               return retval;
+       v->ap = ap;
+       v->component_base = component_base;
 
-       retval = dap_run(ap->dap);
-       if (retval != ERROR_OK)
+       /* sort by offset to gain speed */
+
+       /*
+        * Registers DEVARCH, DEVID and DEVTYPE are valid on Class 0x9 devices
+        * only, but are at offset above 0xf00, so can be read on any device
+        * without triggering error. Read them for eventual use on Class 0x9.
+        */
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_C9_DEVARCH, &v->devarch);
+
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_C9_DEVID, &v->devid);
+
+       /* Same address as ARM_CS_C1_MEMTYPE */
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_C9_DEVTYPE, &v->devtype_memtype);
+
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR4, &pid4);
+
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR0, &pid0);
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR1, &pid1);
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR2, &pid2);
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_PIDR3, &pid3);
+
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR0, &cid0);
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR1, &cid1);
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR2, &cid2);
+       if (retval == ERROR_OK)
+               retval = mem_ap_read_u32(ap, component_base + ARM_CS_CIDR3, &cid3);
+
+       if (retval == ERROR_OK)
+               retval = dap_run(ap->dap);
+       if (retval != ERROR_OK) {
+               LOG_DEBUG("Failed read CoreSight registers");
                return retval;
+       }
 
-       *cid = (cid3 & 0xff) << 24
+       v->cid = (cid3 & 0xff) << 24
                        | (cid2 & 0xff) << 16
                        | (cid1 & 0xff) << 8
                        | (cid0 & 0xff);
-       *pid = (uint64_t)(pid4 & 0xff) << 32
+       v->pid = (uint64_t)(pid4 & 0xff) << 32
                        | (pid3 & 0xff) << 24
                        | (pid2 & 0xff) << 16
                        | (pid1 & 0xff) << 8
@@ -1105,22 +1192,12 @@ static int dap_read_part_id(struct adiv5_ap *ap, target_addr_t component_base, u
  * from chip observation (e.g. TI SDTI).
  */
 
-/* The legacy code only used the part number field to identify CoreSight peripherals.
- * This meant that the same part number from two different manufacturers looked the same.
- * It is desirable for all future additions to identify with both part number and JEP106.
- * "ANY_ID" is a wildcard (any JEP106) only to preserve legacy behavior for legacy entries.
- */
-
-#define ANY_ID 0x1000
-
-#define ARM_ID 0x23B
-
-static const struct {
+static const struct dap_part_nums {
        uint16_t designer_id;
        uint16_t part_num;
        const char *type;
        const char *full;
-} dap_partnums[] = {
+} dap_part_nums[] = {
        { ARM_ID, 0x000, "Cortex-M3 SCS",              "(System Control Space)", },
        { ARM_ID, 0x001, "Cortex-M3 ITM",              "(Instrumentation Trace Module)", },
        { ARM_ID, 0x002, "Cortex-M3 DWT",              "(Data Watchpoint and Trace)", },
@@ -1131,9 +1208,12 @@ static const struct {
        { ARM_ID, 0x00c, "Cortex-M4 SCS",              "(System Control Space)", },
        { ARM_ID, 0x00d, "CoreSight ETM11",            "(Embedded Trace)", },
        { ARM_ID, 0x00e, "Cortex-M7 FPB",              "(Flash Patch and Breakpoint)", },
+       { ARM_ID, 0x193, "SoC-600 TSGEN",              "(Timestamp Generator)", },
        { ARM_ID, 0x470, "Cortex-M1 ROM",              "(ROM Table)", },
        { ARM_ID, 0x471, "Cortex-M0 ROM",              "(ROM Table)", },
        { ARM_ID, 0x490, "Cortex-A15 GIC",             "(Generic Interrupt Controller)", },
+       { ARM_ID, 0x492, "Cortex-R52 GICD",            "(Distributor)", },
+       { ARM_ID, 0x493, "Cortex-R52 GICR",            "(Redistributor)", },
        { ARM_ID, 0x4a1, "Cortex-A53 ROM",             "(v8 Memory Map ROM Table)", },
        { ARM_ID, 0x4a2, "Cortex-A57 ROM",             "(ROM Table)", },
        { ARM_ID, 0x4a3, "Cortex-A53 ROM",             "(v7 Memory Map ROM Table)", },
@@ -1142,6 +1222,7 @@ static const struct {
        { ARM_ID, 0x4aa, "Cortex-A35 ROM",             "(v8 Memory Map ROM Table)", },
        { ARM_ID, 0x4af, "Cortex-A15 ROM",             "(ROM Table)", },
        { ARM_ID, 0x4b5, "Cortex-R5 ROM",              "(ROM Table)", },
+       { ARM_ID, 0x4b8, "Cortex-R52 ROM",             "(ROM Table)", },
        { ARM_ID, 0x4c0, "Cortex-M0+ ROM",             "(ROM Table)", },
        { ARM_ID, 0x4c3, "Cortex-M3 ROM",              "(ROM Table)", },
        { ARM_ID, 0x4c4, "Cortex-M4 ROM",              "(ROM Table)", },
@@ -1187,11 +1268,25 @@ static const struct {
        { ARM_ID, 0x9a9, "Cortex-M7 TPIU",             "(Trace Port Interface Unit)", },
        { ARM_ID, 0x9ae, "Cortex-A17 PMU",             "(Performance Monitor Unit)", },
        { ARM_ID, 0x9af, "Cortex-A15 PMU",             "(Performance Monitor Unit)", },
+       { ARM_ID, 0x9b6, "Cortex-R52 PMU/CTI/ETM",     "(Performance Monitor Unit/Cross Trigger/ETM)", },
        { ARM_ID, 0x9b7, "Cortex-R7 PMU",              "(Performance Monitor Unit)", },
        { ARM_ID, 0x9d3, "Cortex-A53 PMU",             "(Performance Monitor Unit)", },
        { ARM_ID, 0x9d7, "Cortex-A57 PMU",             "(Performance Monitor Unit)", },
        { ARM_ID, 0x9d8, "Cortex-A72 PMU",             "(Performance Monitor Unit)", },
        { ARM_ID, 0x9da, "Cortex-A35 PMU/CTI/ETM",     "(Performance Monitor Unit/Cross Trigger/ETM)", },
+       { ARM_ID, 0x9e2, "SoC-600 APB-AP",             "(APB4 Memory Access Port)", },
+       { ARM_ID, 0x9e3, "SoC-600 AHB-AP",             "(AHB5 Memory Access Port)", },
+       { ARM_ID, 0x9e4, "SoC-600 AXI-AP",             "(AXI Memory Access Port)", },
+       { ARM_ID, 0x9e5, "SoC-600 APv1 Adapter",       "(Access Port v1 Adapter)", },
+       { ARM_ID, 0x9e6, "SoC-600 JTAG-AP",            "(JTAG Access Port)", },
+       { ARM_ID, 0x9e7, "SoC-600 TPIU",               "(Trace Port Interface Unit)", },
+       { ARM_ID, 0x9e8, "SoC-600 TMC ETR/ETS",        "(Embedded Trace Router/Streamer)", },
+       { ARM_ID, 0x9e9, "SoC-600 TMC ETB",            "(Embedded Trace Buffer)", },
+       { ARM_ID, 0x9ea, "SoC-600 TMC ETF",            "(Embedded Trace FIFO)", },
+       { ARM_ID, 0x9eb, "SoC-600 ATB Funnel",         "(Trace Funnel)", },
+       { ARM_ID, 0x9ec, "SoC-600 ATB Replicator",     "(Trace Replicator)", },
+       { ARM_ID, 0x9ed, "SoC-600 CTI",                "(Cross Trigger)", },
+       { ARM_ID, 0x9ee, "SoC-600 CATU",               "(Address Translation Unit)", },
        { ARM_ID, 0xc05, "Cortex-A5 Debug",            "(Debug Unit)", },
        { ARM_ID, 0xc07, "Cortex-A7 Debug",            "(Debug Unit)", },
        { ARM_ID, 0xc08, "Cortex-A8 Debug",            "(Debug Unit)", },
@@ -1206,6 +1301,11 @@ static const struct {
        { ARM_ID, 0xd07, "Cortex-A57 Debug",           "(Debug Unit)", },
        { ARM_ID, 0xd08, "Cortex-A72 Debug",           "(Debug Unit)", },
        { ARM_ID, 0xd0b, "Cortex-A76 Debug",           "(Debug Unit)", },
+       { ARM_ID, 0xd0c, "Neoverse N1",                "(Debug Unit)", },
+       { ARM_ID, 0xd13, "Cortex-R52 Debug",           "(Debug Unit)", },
+       { ARM_ID, 0xd49, "Neoverse N2",                "(Debug Unit)", },
+       { 0x017,  0x120, "TI SDTI",                    "(System Debug Trace Interface)", }, /* from OMAP3 memmap */
+       { 0x017,  0x343, "TI DAPCTL",                  "", }, /* from OMAP3 memmap */
        { 0x017,  0x9af, "MSP432 ROM",                 "(ROM Table)" },
        { 0x01f,  0xcd0, "Atmel CPU with DSU",         "(CPU)" },
        { 0x041,  0x1db, "XMC4500 ROM",                "(ROM Table)" },
@@ -1222,335 +1322,554 @@ static const struct {
        { 0x1eb,  0x211, "Tegra 210 ROM",              "(ROM Table)", },
        { 0x1eb,  0x302, "Denver Debug",               "(Debug Unit)", },
        { 0x1eb,  0x402, "Denver PMU",                 "(Performance Monitor Unit)", },
-       /* legacy comment: 0x113: what? */
-       { ANY_ID, 0x120, "TI SDTI",                    "(System Debug Trace Interface)", }, /* from OMAP3 memmap */
-       { ANY_ID, 0x343, "TI DAPCTL",                  "", }, /* from OMAP3 memmap */
 };
 
-static int dap_rom_display(struct command_invocation *cmd,
-                               struct adiv5_ap *ap, target_addr_t dbgbase, int depth)
+static const struct dap_part_nums *pidr_to_part_num(unsigned int designer_id, unsigned int part_num)
 {
-       int retval;
-       uint64_t pid;
-       uint32_t cid;
-       char tabs[16] = "";
-
-       if (depth > 16) {
-               command_print(cmd, "\tTables too deep");
-               return ERROR_FAIL;
-       }
+       static const struct dap_part_nums unknown = {
+               .type = "Unrecognized",
+               .full = "",
+       };
 
-       if (depth)
-               snprintf(tabs, sizeof(tabs), "[L%02d] ", depth);
+       for (unsigned int i = 0; i < ARRAY_SIZE(dap_part_nums); i++)
+               if (dap_part_nums[i].designer_id == designer_id && dap_part_nums[i].part_num == part_num)
+                       return &dap_part_nums[i];
 
-       target_addr_t base_addr = dbgbase & 0xFFFFFFFFFFFFF000ull;
-       command_print(cmd, "\t\tComponent base address " TARGET_ADDR_FMT, base_addr);
+       return &unknown;
+}
 
-       retval = dap_read_part_id(ap, base_addr, &cid, &pid);
-       if (retval != ERROR_OK) {
-               command_print(cmd, "\t\tCan't read component, the corresponding core might be turned off");
-               return ERROR_OK; /* Don't abort recursion */
+static int dap_devtype_display(struct command_invocation *cmd, uint32_t devtype)
+{
+       const char *major = "Reserved", *subtype = "Reserved";
+       const unsigned int minor = (devtype & ARM_CS_C9_DEVTYPE_SUB_MASK) >> ARM_CS_C9_DEVTYPE_SUB_SHIFT;
+       const unsigned int devtype_major = (devtype & ARM_CS_C9_DEVTYPE_MAJOR_MASK) >> ARM_CS_C9_DEVTYPE_MAJOR_SHIFT;
+       switch (devtype_major) {
+       case 0:
+               major = "Miscellaneous";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 4:
+                       subtype = "Validation component";
+                       break;
+               }
+               break;
+       case 1:
+               major = "Trace Sink";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 1:
+                       subtype = "Port";
+                       break;
+               case 2:
+                       subtype = "Buffer";
+                       break;
+               case 3:
+                       subtype = "Router";
+                       break;
+               }
+               break;
+       case 2:
+               major = "Trace Link";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 1:
+                       subtype = "Funnel, router";
+                       break;
+               case 2:
+                       subtype = "Filter";
+                       break;
+               case 3:
+                       subtype = "FIFO, buffer";
+                       break;
+               }
+               break;
+       case 3:
+               major = "Trace Source";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 1:
+                       subtype = "Processor";
+                       break;
+               case 2:
+                       subtype = "DSP";
+                       break;
+               case 3:
+                       subtype = "Engine/Coprocessor";
+                       break;
+               case 4:
+                       subtype = "Bus";
+                       break;
+               case 6:
+                       subtype = "Software";
+                       break;
+               }
+               break;
+       case 4:
+               major = "Debug Control";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 1:
+                       subtype = "Trigger Matrix";
+                       break;
+               case 2:
+                       subtype = "Debug Auth";
+                       break;
+               case 3:
+                       subtype = "Power Requestor";
+                       break;
+               }
+               break;
+       case 5:
+               major = "Debug Logic";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 1:
+                       subtype = "Processor";
+                       break;
+               case 2:
+                       subtype = "DSP";
+                       break;
+               case 3:
+                       subtype = "Engine/Coprocessor";
+                       break;
+               case 4:
+                       subtype = "Bus";
+                       break;
+               case 5:
+                       subtype = "Memory";
+                       break;
+               }
+               break;
+       case 6:
+               major = "Performance Monitor";
+               switch (minor) {
+               case 0:
+                       subtype = "other";
+                       break;
+               case 1:
+                       subtype = "Processor";
+                       break;
+               case 2:
+                       subtype = "DSP";
+                       break;
+               case 3:
+                       subtype = "Engine/Coprocessor";
+                       break;
+               case 4:
+                       subtype = "Bus";
+                       break;
+               case 5:
+                       subtype = "Memory";
+                       break;
+               }
+               break;
        }
+       command_print(cmd, "\t\tType is 0x%02x, %s, %s",
+                       devtype & ARM_CS_C9_DEVTYPE_MASK,
+                       major, subtype);
+       return ERROR_OK;
+}
 
-       if (!is_valid_arm_cs_cidr(cid)) {
-               command_print(cmd, "\t\tInvalid CID 0x%08" PRIx32, cid);
-               return ERROR_OK; /* Don't abort recursion */
-       }
+/**
+ * Actions/operations to be executed while parsing ROM tables.
+ */
+struct rtp_ops {
+       /**
+        * Executed at the start of a new MEM-AP, typically to print the MEM-AP header.
+        * @param retval    Error encountered while reading AP.
+        * @param ap        Pointer to AP.
+        * @param dbgbase   Value of MEM-AP Debug Base Address register.
+        * @param apid      Value of MEM-AP IDR Identification Register.
+        * @param priv      Pointer to private data.
+        * @return          ERROR_OK on success, else a fault code.
+        */
+       int (*mem_ap_header)(int retval, struct adiv5_ap *ap, uint64_t dbgbase,
+                       uint32_t apid, void *priv);
+       /**
+        * Executed when a CoreSight component is parsed, typically to print
+        * information on the component.
+        * @param retval    Error encountered while reading component's registers.
+        * @param v         Pointer to a container of the component's registers.
+        * @param depth     The current depth level of ROM table.
+        * @param priv      Pointer to private data.
+        * @return          ERROR_OK on success, else a fault code.
+        */
+       int (*cs_component)(int retval, struct cs_component_vals *v, int depth, void *priv);
+       /**
+        * Executed for each entry of a ROM table, typically to print the entry
+        * and information about validity or end-of-table mark.
+        * @param retval    Error encountered while reading the ROM table entry.
+        * @param depth     The current depth level of ROM table.
+        * @param offset    The offset of the entry in the ROM table.
+        * @param romentry  The value of the ROM table entry.
+        * @param priv      Pointer to private data.
+        * @return          ERROR_OK on success, else a fault code.
+        */
+       int (*rom_table_entry)(int retval, int depth, unsigned int offset, uint32_t romentry,
+                       void *priv);
+       /**
+        * Private data
+        */
+       void *priv;
+};
 
-       /* component may take multiple 4K pages */
-       uint32_t size = ARM_CS_PIDR_SIZE(pid);
-       if (size > 0)
-               command_print(cmd, "\t\tStart address " TARGET_ADDR_FMT, base_addr - 0x1000 * size);
+/**
+ * Wrapper around struct rtp_ops::mem_ap_header.
+ * Input parameter @a retval is propagated.
+ */
+static int rtp_ops_mem_ap_header(const struct rtp_ops *ops,
+               int retval, struct adiv5_ap *ap, uint64_t dbgbase, uint32_t apid)
+{
+       if (!ops->mem_ap_header)
+               return retval;
 
-       command_print(cmd, "\t\tPeripheral ID 0x%010" PRIx64, pid);
+       int retval1 = ops->mem_ap_header(retval, ap, dbgbase, apid, ops->priv);
+       if (retval != ERROR_OK)
+               return retval;
+       return retval1;
+}
 
-       uint8_t class = (cid & ARM_CS_CIDR_CLASS_MASK) >> ARM_CS_CIDR_CLASS_SHIFT;
-       uint16_t part_num = ARM_CS_PIDR_PART(pid);
-       uint16_t designer_id = ARM_CS_PIDR_DESIGNER(pid);
+/**
+ * Wrapper around struct rtp_ops::cs_component.
+ * Input parameter @a retval is propagated.
+ */
+static int rtp_ops_cs_component(const struct rtp_ops *ops,
+               int retval, struct cs_component_vals *v, int depth)
+{
+       if (!ops->cs_component)
+               return retval;
 
-       if (pid & ARM_CS_PIDR_JEDEC) {
-               /* JEP106 code */
-               command_print(cmd, "\t\tDesigner is 0x%03" PRIx16 ", %s",
-                               designer_id, jep106_manufacturer(designer_id));
-       } else {
-               /* Legacy ASCII ID, clear invalid bits */
-               designer_id &= 0x7f;
-               command_print(cmd, "\t\tDesigner ASCII code 0x%02" PRIx16 ", %s",
-                               designer_id, designer_id == 0x41 ? "ARM" : "<unknown>");
-       }
+       int retval1 = ops->cs_component(retval, v, depth, ops->priv);
+       if (retval != ERROR_OK)
+               return retval;
+       return retval1;
+}
 
-       /* default values to be overwritten upon finding a match */
-       const char *type = "Unrecognized";
-       const char *full = "";
+/**
+ * Wrapper around struct rtp_ops::rom_table_entry.
+ * Input parameter @a retval is propagated.
+ */
+static int rtp_ops_rom_table_entry(const struct rtp_ops *ops,
+               int retval, int depth, unsigned int offset, uint32_t romentry)
+{
+       if (!ops->rom_table_entry)
+               return retval;
 
-       /* search dap_partnums[] array for a match */
-       for (unsigned entry = 0; entry < ARRAY_SIZE(dap_partnums); entry++) {
+       int retval1 = ops->rom_table_entry(retval, depth, offset, romentry, ops->priv);
+       if (retval != ERROR_OK)
+               return retval;
+       return retval1;
+}
 
-               if ((dap_partnums[entry].designer_id != designer_id) && (dap_partnums[entry].designer_id != ANY_ID))
-                       continue;
+/* Broken ROM tables can have circular references. Stop after a while */
+#define ROM_TABLE_MAX_DEPTH (16)
 
-               if (dap_partnums[entry].part_num != part_num)
-                       continue;
+static int rtp_cs_component(const struct rtp_ops *ops,
+               struct adiv5_ap *ap, target_addr_t dbgbase, int depth);
 
-               type = dap_partnums[entry].type;
-               full = dap_partnums[entry].full;
-               break;
-       }
+static int rtp_rom_loop(const struct rtp_ops *ops,
+               struct adiv5_ap *ap, target_addr_t base_address, int depth,
+               unsigned int max_entries)
+{
+       assert(IS_ALIGNED(base_address, ARM_CS_ALIGN));
 
-       command_print(cmd, "\t\tPart is 0x%" PRIx16", %s %s", part_num, type, full);
-       command_print(cmd, "\t\tComponent class is 0x%" PRIx8 ", %s", class, class_description[class]);
+       unsigned int offset = 0;
+       while (max_entries--) {
+               uint32_t romentry;
+               unsigned int saved_offset = offset;
 
-       if (class == ARM_CS_CLASS_0X1_ROM_TABLE) {
-               uint32_t memtype;
-               retval = mem_ap_read_atomic_u32(ap, base_addr + ARM_CS_C1_MEMTYPE, &memtype);
+               int retval = mem_ap_read_atomic_u32(ap, base_address + offset, &romentry);
+               offset += 4;
                if (retval != ERROR_OK)
-                       return retval;
-
-               if (memtype & ARM_CS_C1_MEMTYPE_SYSMEM_MASK)
-                       command_print(cmd, "\t\tMEMTYPE system memory present on bus");
-               else
-                       command_print(cmd, "\t\tMEMTYPE system memory not present: dedicated debug bus");
-
-               /* Read ROM table entries from base address until we get 0x00000000 or reach the reserved area */
-               for (uint16_t entry_offset = 0; entry_offset < 0xF00; entry_offset += 4) {
-                       uint32_t romentry;
-                       retval = mem_ap_read_atomic_u32(ap, base_addr | entry_offset, &romentry);
-                       if (retval != ERROR_OK)
-                               return retval;
-                       command_print(cmd, "\t%sROMTABLE[0x%x] = 0x%" PRIx32 "",
-                                       tabs, entry_offset, romentry);
-                       if (romentry & ARM_CS_ROMENTRY_PRESENT) {
-                               /* Recurse. "romentry" is signed */
-                               retval = dap_rom_display(cmd, ap, base_addr + (int32_t)(romentry & ARM_CS_ROMENTRY_OFFSET_MASK),
-                                                                                depth + 1);
-                               if (retval != ERROR_OK)
-                                       return retval;
-                       } else if (romentry != 0) {
-                               command_print(cmd, "\t\tComponent not present");
-                       } else {
-                               command_print(cmd, "\t%s\tEnd of ROM table", tabs);
-                               break;
-                       }
-               }
-       } else if (class == ARM_CS_CLASS_0X9_CS_COMPONENT) {
-               const char *major = "Reserved", *subtype = "Reserved";
+                       LOG_DEBUG("Failed read ROM table entry");
 
-               uint32_t devtype;
-               retval = mem_ap_read_atomic_u32(ap, base_addr + ARM_CS_C9_DEVTYPE, &devtype);
+               retval = rtp_ops_rom_table_entry(ops, retval, depth, saved_offset, romentry);
                if (retval != ERROR_OK)
                        return retval;
-               unsigned int minor = (devtype & ARM_CS_C9_DEVTYPE_SUB_MASK) >> ARM_CS_C9_DEVTYPE_SUB_SHIFT;
-               unsigned int devtype_major = (devtype & ARM_CS_C9_DEVTYPE_MAJOR_MASK) >> ARM_CS_C9_DEVTYPE_MAJOR_SHIFT;
-               switch (devtype_major) {
-               case 0:
-                       major = "Miscellaneous";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 4:
-                               subtype = "Validation component";
-                               break;
-                       }
-                       break;
-               case 1:
-                       major = "Trace Sink";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 1:
-                               subtype = "Port";
-                               break;
-                       case 2:
-                               subtype = "Buffer";
-                               break;
-                       case 3:
-                               subtype = "Router";
-                               break;
-                       }
-                       break;
-               case 2:
-                       major = "Trace Link";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 1:
-                               subtype = "Funnel, router";
-                               break;
-                       case 2:
-                               subtype = "Filter";
-                               break;
-                       case 3:
-                               subtype = "FIFO, buffer";
-                               break;
-                       }
-                       break;
-               case 3:
-                       major = "Trace Source";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 1:
-                               subtype = "Processor";
-                               break;
-                       case 2:
-                               subtype = "DSP";
-                               break;
-                       case 3:
-                               subtype = "Engine/Coprocessor";
-                               break;
-                       case 4:
-                               subtype = "Bus";
-                               break;
-                       case 6:
-                               subtype = "Software";
-                               break;
-                       }
-                       break;
-               case 4:
-                       major = "Debug Control";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 1:
-                               subtype = "Trigger Matrix";
-                               break;
-                       case 2:
-                               subtype = "Debug Auth";
-                               break;
-                       case 3:
-                               subtype = "Power Requestor";
-                               break;
-                       }
-                       break;
-               case 5:
-                       major = "Debug Logic";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 1:
-                               subtype = "Processor";
-                               break;
-                       case 2:
-                               subtype = "DSP";
-                               break;
-                       case 3:
-                               subtype = "Engine/Coprocessor";
-                               break;
-                       case 4:
-                               subtype = "Bus";
-                               break;
-                       case 5:
-                               subtype = "Memory";
-                               break;
-                       }
-                       break;
-               case 6:
-                       major = "Performance Monitor";
-                       switch (minor) {
-                       case 0:
-                               subtype = "other";
-                               break;
-                       case 1:
-                               subtype = "Processor";
-                               break;
-                       case 2:
-                               subtype = "DSP";
-                               break;
-                       case 3:
-                               subtype = "Engine/Coprocessor";
-                               break;
-                       case 4:
-                               subtype = "Bus";
-                               break;
-                       case 5:
-                               subtype = "Memory";
-                               break;
-                       }
+
+               if (romentry == 0) {
+                       /* End of ROM table */
                        break;
                }
-               command_print(cmd, "\t\tType is 0x%02x, %s, %s",
-                               devtype & ARM_CS_C9_DEVTYPE_MASK,
-                               major, subtype);
-               /* REVISIT also show ARM_CS_C9_DEVID */
+
+               if (!(romentry & ARM_CS_ROMENTRY_PRESENT))
+                       continue;
+
+               /* Recurse. "romentry" is signed */
+               target_addr_t component_base = base_address + (int32_t)(romentry & ARM_CS_ROMENTRY_OFFSET_MASK);
+               retval = rtp_cs_component(ops, ap, component_base, depth + 1);
+               if (retval != ERROR_OK) {
+                       /* TODO: do we need to send an ABORT before continuing? */
+                       LOG_DEBUG("Ignore error parsing CoreSight component");
+                       continue;
+               }
+       }
+
+       return ERROR_OK;
+}
+
+static int rtp_cs_component(const struct rtp_ops *ops,
+               struct adiv5_ap *ap, target_addr_t base_address, int depth)
+{
+       struct cs_component_vals v;
+       int retval;
+
+       assert(IS_ALIGNED(base_address, ARM_CS_ALIGN));
+
+       if (depth > ROM_TABLE_MAX_DEPTH)
+               retval = ERROR_FAIL;
+       else
+               retval = rtp_read_cs_regs(ap, base_address, &v);
+
+       retval = rtp_ops_cs_component(ops, retval, &v, depth);
+       if (retval != ERROR_OK)
+               return ERROR_OK; /* Don't abort recursion */
+
+       if (!is_valid_arm_cs_cidr(v.cid))
+               return ERROR_OK; /* Don't abort recursion */
+
+       const unsigned int class = ARM_CS_CIDR_CLASS(v.cid);
+
+       if (class == ARM_CS_CLASS_0X1_ROM_TABLE)
+               return rtp_rom_loop(ops, ap, base_address, depth, 960);
+
+       if (class == ARM_CS_CLASS_0X9_CS_COMPONENT) {
+               if ((v.devarch & ARM_CS_C9_DEVARCH_PRESENT) == 0)
+                       return ERROR_OK;
+
+               /* quit if not ROM table */
+               if ((v.devarch & DEVARCH_ID_MASK) != DEVARCH_ROM_C_0X9)
+                       return ERROR_OK;
+
+               return rtp_rom_loop(ops, ap, base_address, depth, 512);
        }
 
+       /* Class other than 0x1 and 0x9 */
        return ERROR_OK;
 }
 
-int dap_info_command(struct command_invocation *cmd,
-               struct adiv5_ap *ap)
+static int rtp_ap(const struct rtp_ops *ops, struct adiv5_ap *ap)
 {
        int retval;
        uint32_t apid;
        target_addr_t dbgbase;
-       target_addr_t dbgaddr;
-       uint8_t mem_ap;
+       target_addr_t invalid_entry;
 
        /* Now we read ROM table ID registers, ref. ARM IHI 0029B sec  */
        retval = dap_get_debugbase(ap, &dbgbase, &apid);
+       retval = rtp_ops_mem_ap_header(ops, retval, ap, dbgbase, apid);
        if (retval != ERROR_OK)
                return retval;
 
+       if (apid == 0)
+               return ERROR_FAIL;
+
+       /* NOTE: a MEM-AP may have a single CoreSight component that's
+        * not a ROM table ... or have no such components at all.
+        */
+       const unsigned int class = (apid & AP_REG_IDR_CLASS_MASK) >> AP_REG_IDR_CLASS_SHIFT;
+
+       if (class == AP_REG_IDR_CLASS_MEM_AP) {
+               if (is_64bit_ap(ap))
+                       invalid_entry = 0xFFFFFFFFFFFFFFFFull;
+               else
+                       invalid_entry = 0xFFFFFFFFul;
+
+               if (dbgbase != invalid_entry && (dbgbase & 0x3) != 0x2)
+                       rtp_cs_component(ops, ap, dbgbase & 0xFFFFFFFFFFFFF000ull, 0);
+       }
+
+       return ERROR_OK;
+}
+
+/* Actions for command "dap info" */
+
+static int dap_info_mem_ap_header(int retval, struct adiv5_ap *ap,
+               target_addr_t dbgbase, uint32_t apid, void *priv)
+{
+       struct command_invocation *cmd = priv;
+       target_addr_t invalid_entry;
+
+       if (retval != ERROR_OK) {
+               command_print(cmd, "\t\tCan't read MEM-AP, the corresponding core might be turned off");
+               return retval;
+       }
+
        command_print(cmd, "AP ID register 0x%8.8" PRIx32, apid);
        if (apid == 0) {
                command_print(cmd, "No AP found at this ap 0x%x", ap->ap_num);
                return ERROR_FAIL;
        }
 
-       switch (apid & (IDR_JEP106 | IDR_TYPE)) {
-       case IDR_JEP106_ARM | AP_TYPE_JTAG_AP:
-               command_print(cmd, "\tType is JTAG-AP");
-               break;
-       case IDR_JEP106_ARM | AP_TYPE_AHB3_AP:
-               command_print(cmd, "\tType is MEM-AP AHB3");
-               break;
-       case IDR_JEP106_ARM | AP_TYPE_AHB5_AP:
-               command_print(cmd, "\tType is MEM-AP AHB5");
-               break;
-       case IDR_JEP106_ARM | AP_TYPE_APB_AP:
-               command_print(cmd, "\tType is MEM-AP APB");
-               break;
-       case IDR_JEP106_ARM | AP_TYPE_AXI_AP:
-               command_print(cmd, "\tType is MEM-AP AXI");
-               break;
-       default:
-               command_print(cmd, "\tUnknown AP type");
-               break;
-       }
+       command_print(cmd, "\tType is %s", ap_type_to_description(apid & AP_TYPE_MASK));
 
        /* NOTE: a MEM-AP may have a single CoreSight component that's
         * not a ROM table ... or have no such components at all.
         */
-       mem_ap = (apid & IDR_CLASS) == AP_CLASS_MEM_AP;
-       if (mem_ap) {
+       const unsigned int class = (apid & AP_REG_IDR_CLASS_MASK) >> AP_REG_IDR_CLASS_SHIFT;
+
+       if (class == AP_REG_IDR_CLASS_MEM_AP) {
                if (is_64bit_ap(ap))
-                       dbgaddr = 0xFFFFFFFFFFFFFFFFull;
+                       invalid_entry = 0xFFFFFFFFFFFFFFFFull;
                else
-                       dbgaddr = 0xFFFFFFFFul;
+                       invalid_entry = 0xFFFFFFFFul;
 
                command_print(cmd, "MEM-AP BASE " TARGET_ADDR_FMT, dbgbase);
 
-               if (dbgbase == dbgaddr || (dbgbase & 0x3) == 0x2) {
+               if (dbgbase == invalid_entry || (dbgbase & 0x3) == 0x2) {
                        command_print(cmd, "\tNo ROM table present");
                } else {
                        if (dbgbase & 0x01)
                                command_print(cmd, "\tValid ROM table present");
                        else
                                command_print(cmd, "\tROM table in legacy format");
+               }
+       }
+
+       return ERROR_OK;
+}
+
+static int dap_info_cs_component(int retval, struct cs_component_vals *v, int depth, void *priv)
+{
+       struct command_invocation *cmd = priv;
+
+       if (depth > ROM_TABLE_MAX_DEPTH) {
+               command_print(cmd, "\tTables too deep");
+               return ERROR_FAIL;
+       }
+
+       command_print(cmd, "\t\tComponent base address " TARGET_ADDR_FMT, v->component_base);
+
+       if (retval != ERROR_OK) {
+               command_print(cmd, "\t\tCan't read component, the corresponding core might be turned off");
+               return retval;
+       }
+
+       if (!is_valid_arm_cs_cidr(v->cid)) {
+               command_print(cmd, "\t\tInvalid CID 0x%08" PRIx32, v->cid);
+               return ERROR_OK; /* Don't abort recursion */
+       }
+
+       /* component may take multiple 4K pages */
+       uint32_t size = ARM_CS_PIDR_SIZE(v->pid);
+       if (size > 0)
+               command_print(cmd, "\t\tStart address " TARGET_ADDR_FMT, v->component_base - 0x1000 * size);
+
+       command_print(cmd, "\t\tPeripheral ID 0x%010" PRIx64, v->pid);
+
+       const unsigned int part_num = ARM_CS_PIDR_PART(v->pid);
+       unsigned int designer_id = ARM_CS_PIDR_DESIGNER(v->pid);
+
+       if (v->pid & ARM_CS_PIDR_JEDEC) {
+               /* JEP106 code */
+               command_print(cmd, "\t\tDesigner is 0x%03x, %s",
+                               designer_id, jep106_manufacturer(designer_id));
+       } else {
+               /* Legacy ASCII ID, clear invalid bits */
+               designer_id &= 0x7f;
+               command_print(cmd, "\t\tDesigner ASCII code 0x%02x, %s",
+                               designer_id, designer_id == 0x41 ? "ARM" : "<unknown>");
+       }
+
+       const struct dap_part_nums *partnum = pidr_to_part_num(designer_id, part_num);
+       command_print(cmd, "\t\tPart is 0x%03x, %s %s", part_num, partnum->type, partnum->full);
+
+       const unsigned int class = ARM_CS_CIDR_CLASS(v->cid);
+       command_print(cmd, "\t\tComponent class is 0x%x, %s", class, class_description[class]);
+
+       if (class == ARM_CS_CLASS_0X1_ROM_TABLE) {
+               if (v->devtype_memtype & ARM_CS_C1_MEMTYPE_SYSMEM_MASK)
+                       command_print(cmd, "\t\tMEMTYPE system memory present on bus");
+               else
+                       command_print(cmd, "\t\tMEMTYPE system memory not present: dedicated debug bus");
+               return ERROR_OK;
+       }
+
+       if (class == ARM_CS_CLASS_0X9_CS_COMPONENT) {
+               dap_devtype_display(cmd, v->devtype_memtype);
+
+               /* REVISIT also show ARM_CS_C9_DEVID */
+
+               if ((v->devarch & ARM_CS_C9_DEVARCH_PRESENT) == 0)
+                       return ERROR_OK;
+
+               unsigned int architect_id = ARM_CS_C9_DEVARCH_ARCHITECT(v->devarch);
+               unsigned int revision = ARM_CS_C9_DEVARCH_REVISION(v->devarch);
+               command_print(cmd, "\t\tDev Arch is 0x%08" PRIx32 ", %s \"%s\" rev.%u", v->devarch,
+                               jep106_manufacturer(architect_id), class0x9_devarch_description(v->devarch),
+                               revision);
+
+               if ((v->devarch & DEVARCH_ID_MASK) == DEVARCH_ROM_C_0X9) {
+                       command_print(cmd, "\t\tType is ROM table");
 
-                       dap_rom_display(cmd, ap, dbgbase & 0xFFFFFFFFFFFFF000ull, 0);
+                       if (v->devid & ARM_CS_C9_DEVID_SYSMEM_MASK)
+                               command_print(cmd, "\t\tMEMTYPE system memory present on bus");
+                       else
+                               command_print(cmd, "\t\tMEMTYPE system memory not present: dedicated debug bus");
                }
+               return ERROR_OK;
        }
 
+       /* Class other than 0x1 and 0x9 */
        return ERROR_OK;
 }
 
+static int dap_info_rom_table_entry(int retval, int depth,
+               unsigned int offset, uint32_t romentry, void *priv)
+{
+       struct command_invocation *cmd = priv;
+       char tabs[16] = "";
+
+       if (depth)
+               snprintf(tabs, sizeof(tabs), "[L%02d] ", depth);
+
+       if (retval != ERROR_OK) {
+               command_print(cmd, "\t%sROMTABLE[0x%x] Read error", tabs, offset);
+               command_print(cmd, "\t\tUnable to continue");
+               command_print(cmd, "\t%s\tStop parsing of ROM table", tabs);
+               return retval;
+       }
+
+       command_print(cmd, "\t%sROMTABLE[0x%x] = 0x%08" PRIx32,
+                       tabs, offset, romentry);
+
+       if (romentry == 0) {
+               command_print(cmd, "\t%s\tEnd of ROM table", tabs);
+               return ERROR_OK;
+       }
+
+       if (!(romentry & ARM_CS_ROMENTRY_PRESENT)) {
+               command_print(cmd, "\t\tComponent not present");
+               return ERROR_OK;
+       }
+
+       return ERROR_OK;
+}
+
+int dap_info_command(struct command_invocation *cmd, struct adiv5_ap *ap)
+{
+       struct rtp_ops dap_info_ops = {
+               .mem_ap_header   = dap_info_mem_ap_header,
+               .cs_component    = dap_info_cs_component,
+               .rom_table_entry = dap_info_rom_table_entry,
+               .priv            = cmd,
+       };
+
+       return rtp_ap(&dap_info_ops, ap);
+}
+
 enum adiv5_cfg_param {
        CFG_DAP,
        CFG_AP_NUM,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)