85 return tar_autoincr_block - ((tar_autoincr_block - 1) & address);
247 address & 0xFFFFFFFFFFFFFFF0ull);
299 address & 0xFFFFFFFFFFFFFFF0ull);
347 bool addrinc,
bool pack,
unsigned int *this_size)
376 if (!addrinc ||
size >= 4
390 uint32_t csw_readback;
399 bool size_supported = ((csw_readback &
CSW_SIZE_MASK) == csw_size);
401 size_supported ?
"supported" :
"not supported");
403 if (size_supported) {
423 *this_size = pack ? 4 :
size;
447 bool addrinc,
bool pack,
unsigned int *this_size)
451 addrinc, pack, this_size);
456 addrinc,
false, this_size);
507 LOG_ERROR(
"Write more than 32 bits not supported with ti_be_32_quirks");
519 unsigned int this_size;
521 size, address ^ ti_be_addr_xor,
522 addrinc, pack && nbytes >= 4, &this_size);
528 uint32_t drw_byte_idx = address;
532 uint32_t outvalue = 0;
539 uint32_t high = *
buffer++;
540 outvalue |=
low << 8 * (drw_byte_idx++ & 3);
541 outvalue |= high << 8 * (drw_byte_idx++ & 3);
542 outvalue |=
low << 8 * (drw_byte_idx++ & 3);
543 outvalue |= high << 8 * (drw_byte_idx & 3);
549 uint32_t data = *
buffer++;
551 outvalue |= data << 8;
552 outvalue |= data << 16;
553 outvalue |= data << 24;
557 unsigned int drw_bytes =
MIN(this_size, 4);
559 outvalue |= (uint32_t)*
buffer++ <<
560 8 * ((drw_byte_idx++ & 3) ^ ti_be_lane_xor);
573 address += this_size;
585 LOG_ERROR(
"Failed to write memory and, additionally, failed to find out where");
620 LOG_ERROR(
"Read more than 32 bits not supported with ti_be_32_quirks");
630 uint32_t *read_buf = calloc(
count,
MAX(
sizeof(uint32_t),
size));
633 uint32_t *read_ptr = read_buf;
635 LOG_ERROR(
"Failed to allocate read buffer");
643 unsigned int this_size;
646 addrinc, nbytes >= 4, &this_size);
660 address += this_size;
682 if (nbytes > tar - address)
683 nbytes = tar - address;
685 LOG_ERROR(
"Failed to read memory and, additionally, failed to find out where");
695 unsigned int this_size =
MIN(
size, 4);
697 if (size < 4 && addrinc && ap->packed_transfers_supported && nbytes >= 4
704 *
buffer++ = *read_ptr >> 8 * ((address++ & 3) ^ ti_be_lane_xor);
705 *
buffer++ = *read_ptr >> 8 * ((address++ & 3) ^ ti_be_lane_xor);
708 *
buffer++ = *read_ptr >> 8 * ((address++ & 3) ^ ti_be_lane_xor);
711 *
buffer++ = *read_ptr >> 8 * ((address++ & 3) ^ ti_be_lane_xor);
749 #define DAP_POWER_DOMAIN_TIMEOUT (10)
934 LOG_DEBUG(
"MEM_AP CFG: large data %d, long address %d, big-endian %d",
985 [0x0] =
"Generic verification component",
994 [0x9] =
"CoreSight component",
996 [0xB] =
"Peripheral Test Block",
998 [0xD] =
"OptimoDE DESS",
999 [0xE] =
"Generic IP component",
1000 [0xF] =
"CoreLink, PrimeCell or System component",
1003 #define ARCH_ID(architect, archid) ( \
1004 (((architect) << ARM_CS_C9_DEVARCH_ARCHITECT_SHIFT) & ARM_CS_C9_DEVARCH_ARCHITECT_MASK) | \
1005 (((archid) << ARM_CS_C9_DEVARCH_ARCHID_SHIFT) & ARM_CS_C9_DEVARCH_ARCHID_MASK) \
1008 static const struct {
1014 {
ARCH_ID(
ARM_ID, 0x1A01),
"Instrumentation Trace Macrocell (ITM) architecture" },
1016 {
ARCH_ID(
ARM_ID, 0x1A03),
"Flash Patch and Breakpoint unit (FPB) architecture" },
1017 {
ARCH_ID(
ARM_ID, 0x2A04),
"Processor debug architecture (ARMv8-M)" },
1018 {
ARCH_ID(
ARM_ID, 0x6A05),
"Processor debug architecture (ARMv8-R)" },
1020 {
ARCH_ID(
ARM_ID, 0x4A13),
"Embedded Trace Macrocell (ETM) architecture" },
1021 {
ARCH_ID(
ARM_ID, 0x1A14),
"Cross Trigger Interface (CTI) architecture" },
1022 {
ARCH_ID(
ARM_ID, 0x6A15),
"Processor debug architecture (v8.0-A)" },
1023 {
ARCH_ID(
ARM_ID, 0x7A15),
"Processor debug architecture (v8.1-A)" },
1024 {
ARCH_ID(
ARM_ID, 0x8A15),
"Processor debug architecture (v8.2-A)" },
1025 {
ARCH_ID(
ARM_ID, 0x2A16),
"Processor Performance Monitor (PMU) architecture" },
1026 {
ARCH_ID(
ARM_ID, 0x0A17),
"Memory Access Port v2 architecture" },
1027 {
ARCH_ID(
ARM_ID, 0x0A27),
"JTAG Access Port v2 architecture" },
1030 {
ARCH_ID(
ARM_ID, 0x0A47),
"Unknown Access Port v2 architecture" },
1032 {
ARCH_ID(
ARM_ID, 0x0A63),
"System Trace Macrocell (STM) architecture" },
1037 #define DEVARCH_ID_MASK (ARM_CS_C9_DEVARCH_ARCHITECT_MASK | ARM_CS_C9_DEVARCH_ARCHID_MASK)
1038 #define DEVARCH_MEM_AP ARCH_ID(ARM_ID, 0x0A17)
1039 #define DEVARCH_ROM_C_0X9 ARCH_ID(ARM_ID, 0x0AF7)
1040 #define DEVARCH_UNKNOWN_V2 ARCH_ID(ARM_ID, 0x0A47)
1045 return "not present";
1054 static const struct {
1092 if (ap_num & 0x0fffULL)
1094 if (dap->
asize != 0)
1095 if (ap_num & ((~0ULL) << dap->
asize))
1111 LOG_DEBUG(
"On ADIv6 we cannot scan all the possible AP");
1116 for (
unsigned int ap_num = 0; ap_num <=
DP_APSEL_MAX; ap_num++) {
1122 uint32_t id_val = 0;
1136 LOG_DEBUG(
"Found %s at AP index: %d (IDR=0x%08" PRIX32
")",
1212 LOG_ERROR(
"BUG: refcount AP#0x%" PRIx64
" put underflow", ap->
ap_num);
1235 uint32_t baseptr_upper, baseptr_lower;
1261 *dbgbase = (((
target_addr_t)baseptr_upper) << 32) | baseptr_lower;
1268 uint32_t baseptr_lower, baseptr_upper = 0;
1271 if (dap->
asize > 32) {
1286 baseptr_lower &= ~0x0fff;
1287 *baseptr = (((uint64_t)baseptr_upper) << 32) | baseptr_lower;
1328 uint64_t component_base,
unsigned int reg, uint32_t *value)
1353 uint32_t cid0, cid1, cid2, cid3;
1354 uint32_t pid0, pid1, pid2, pid3, pid4;
1402 LOG_DEBUG(
"Failed read CoreSight registers");
1406 v->
cid = (cid3 & 0xff) << 24
1407 | (cid2 & 0xff) << 16
1408 | (cid1 & 0xff) << 8
1410 v->
pid = (uint64_t)(pid4 & 0xff) << 32
1411 | (pid3 & 0xff) << 24
1412 | (pid2 & 0xff) << 16
1413 | (pid1 & 0xff) << 8
1432 {
ARM_ID, 0x000,
"Cortex-M3 SCS",
"(System Control Space)", },
1433 {
ARM_ID, 0x001,
"Cortex-M3 ITM",
"(Instrumentation Trace Module)", },
1434 {
ARM_ID, 0x002,
"Cortex-M3 DWT",
"(Data Watchpoint and Trace)", },
1435 {
ARM_ID, 0x003,
"Cortex-M3 FPB",
"(Flash Patch and Breakpoint)", },
1436 {
ARM_ID, 0x008,
"Cortex-M0 SCS",
"(System Control Space)", },
1437 {
ARM_ID, 0x00a,
"Cortex-M0 DWT",
"(Data Watchpoint and Trace)", },
1438 {
ARM_ID, 0x00b,
"Cortex-M0 BPU",
"(Breakpoint Unit)", },
1439 {
ARM_ID, 0x00c,
"Cortex-M4 SCS",
"(System Control Space)", },
1440 {
ARM_ID, 0x00d,
"CoreSight ETM11",
"(Embedded Trace)", },
1441 {
ARM_ID, 0x00e,
"Cortex-M7 FPB",
"(Flash Patch and Breakpoint)", },
1442 {
ARM_ID, 0x193,
"SoC-600 TSGEN",
"(Timestamp Generator)", },
1443 {
ARM_ID, 0x470,
"Cortex-M1 ROM",
"(ROM Table)", },
1444 {
ARM_ID, 0x471,
"Cortex-M0 ROM",
"(ROM Table)", },
1445 {
ARM_ID, 0x490,
"Cortex-A15 GIC",
"(Generic Interrupt Controller)", },
1446 {
ARM_ID, 0x492,
"Cortex-R52 GICD",
"(Distributor)", },
1447 {
ARM_ID, 0x493,
"Cortex-R52 GICR",
"(Redistributor)", },
1448 {
ARM_ID, 0x4a1,
"Cortex-A53 ROM",
"(v8 Memory Map ROM Table)", },
1449 {
ARM_ID, 0x4a2,
"Cortex-A57 ROM",
"(ROM Table)", },
1450 {
ARM_ID, 0x4a3,
"Cortex-A53 ROM",
"(v7 Memory Map ROM Table)", },
1451 {
ARM_ID, 0x4a4,
"Cortex-A72 ROM",
"(ROM Table)", },
1452 {
ARM_ID, 0x4a9,
"Cortex-A9 ROM",
"(ROM Table)", },
1453 {
ARM_ID, 0x4aa,
"Cortex-A35 ROM",
"(v8 Memory Map ROM Table)", },
1454 {
ARM_ID, 0x4af,
"Cortex-A15 ROM",
"(ROM Table)", },
1455 {
ARM_ID, 0x4b5,
"Cortex-R5 ROM",
"(ROM Table)", },
1456 {
ARM_ID, 0x4b8,
"Cortex-R52 ROM",
"(ROM Table)", },
1457 {
ARM_ID, 0x4bd,
"Cortex-R52+ ROM",
"(ROM Table)", },
1458 {
ARM_ID, 0x4c0,
"Cortex-M0+ ROM",
"(ROM Table)", },
1459 {
ARM_ID, 0x4c3,
"Cortex-M3 ROM",
"(ROM Table)", },
1460 {
ARM_ID, 0x4c4,
"Cortex-M4 ROM",
"(ROM Table)", },
1461 {
ARM_ID, 0x4c7,
"Cortex-M7 PPB ROM",
"(Private Peripheral Bus ROM Table)", },
1462 {
ARM_ID, 0x4c8,
"Cortex-M7 ROM",
"(ROM Table)", },
1463 {
ARM_ID, 0x4c9,
"STAR ROM",
"(ROM Table)", },
1464 {
ARM_ID, 0x4e0,
"Cortex-A35 ROM",
"(v7 Memory Map ROM Table)", },
1465 {
ARM_ID, 0x4e4,
"Cortex-A76 ROM",
"(ROM Table)", },
1466 {
ARM_ID, 0x906,
"CoreSight CTI",
"(Cross Trigger)", },
1467 {
ARM_ID, 0x907,
"CoreSight ETB",
"(Trace Buffer)", },
1468 {
ARM_ID, 0x908,
"CoreSight CSTF",
"(Trace Funnel)", },
1469 {
ARM_ID, 0x909,
"CoreSight ATBR",
"(Advanced Trace Bus Replicator)", },
1470 {
ARM_ID, 0x910,
"CoreSight ETM9",
"(Embedded Trace)", },
1471 {
ARM_ID, 0x912,
"CoreSight TPIU",
"(Trace Port Interface Unit)", },
1472 {
ARM_ID, 0x913,
"CoreSight ITM",
"(Instrumentation Trace Macrocell)", },
1473 {
ARM_ID, 0x914,
"CoreSight SWO",
"(Single Wire Output)", },
1474 {
ARM_ID, 0x917,
"CoreSight HTM",
"(AHB Trace Macrocell)", },
1475 {
ARM_ID, 0x920,
"CoreSight ETM11",
"(Embedded Trace)", },
1476 {
ARM_ID, 0x921,
"Cortex-A8 ETM",
"(Embedded Trace)", },
1477 {
ARM_ID, 0x922,
"Cortex-A8 CTI",
"(Cross Trigger)", },
1478 {
ARM_ID, 0x923,
"Cortex-M3 TPIU",
"(Trace Port Interface Unit)", },
1479 {
ARM_ID, 0x924,
"Cortex-M3 ETM",
"(Embedded Trace)", },
1480 {
ARM_ID, 0x925,
"Cortex-M4 ETM",
"(Embedded Trace)", },
1481 {
ARM_ID, 0x930,
"Cortex-R4 ETM",
"(Embedded Trace)", },
1482 {
ARM_ID, 0x931,
"Cortex-R5 ETM",
"(Embedded Trace)", },
1483 {
ARM_ID, 0x932,
"CoreSight MTB-M0+",
"(Micro Trace Buffer)", },
1484 {
ARM_ID, 0x941,
"CoreSight TPIU-Lite",
"(Trace Port Interface Unit)", },
1485 {
ARM_ID, 0x950,
"Cortex-A9 PTM",
"(Program Trace Macrocell)", },
1486 {
ARM_ID, 0x955,
"Cortex-A5 ETM",
"(Embedded Trace)", },
1487 {
ARM_ID, 0x95a,
"Cortex-A72 ETM",
"(Embedded Trace)", },
1488 {
ARM_ID, 0x95b,
"Cortex-A17 PTM",
"(Program Trace Macrocell)", },
1489 {
ARM_ID, 0x95d,
"Cortex-A53 ETM",
"(Embedded Trace)", },
1490 {
ARM_ID, 0x95e,
"Cortex-A57 ETM",
"(Embedded Trace)", },
1491 {
ARM_ID, 0x95f,
"Cortex-A15 PTM",
"(Program Trace Macrocell)", },
1492 {
ARM_ID, 0x961,
"CoreSight TMC",
"(Trace Memory Controller)", },
1493 {
ARM_ID, 0x962,
"CoreSight STM",
"(System Trace Macrocell)", },
1494 {
ARM_ID, 0x975,
"Cortex-M7 ETM",
"(Embedded Trace)", },
1495 {
ARM_ID, 0x9a0,
"CoreSight PMU",
"(Performance Monitoring Unit)", },
1496 {
ARM_ID, 0x9a1,
"Cortex-M4 TPIU",
"(Trace Port Interface Unit)", },
1497 {
ARM_ID, 0x9a4,
"CoreSight GPR",
"(Granular Power Requester)", },
1498 {
ARM_ID, 0x9a5,
"Cortex-A5 PMU",
"(Performance Monitor Unit)", },
1499 {
ARM_ID, 0x9a7,
"Cortex-A7 PMU",
"(Performance Monitor Unit)", },
1500 {
ARM_ID, 0x9a8,
"Cortex-A53 CTI",
"(Cross Trigger)", },
1501 {
ARM_ID, 0x9a9,
"Cortex-M7 TPIU",
"(Trace Port Interface Unit)", },
1502 {
ARM_ID, 0x9ae,
"Cortex-A17 PMU",
"(Performance Monitor Unit)", },
1503 {
ARM_ID, 0x9af,
"Cortex-A15 PMU",
"(Performance Monitor Unit)", },
1504 {
ARM_ID, 0x9b6,
"Cortex-R52 PMU/CTI/ETM",
"(Performance Monitor Unit/Cross Trigger/ETM)", },
1505 {
ARM_ID, 0x9bb,
"Cortex-R52+ PMU/CTI/ETM",
"(Performance Monitor Unit/Cross Trigger/ETM)", },
1506 {
ARM_ID, 0x9b7,
"Cortex-R7 PMU",
"(Performance Monitor Unit)", },
1507 {
ARM_ID, 0x9d3,
"Cortex-A53 PMU",
"(Performance Monitor Unit)", },
1508 {
ARM_ID, 0x9d7,
"Cortex-A57 PMU",
"(Performance Monitor Unit)", },
1509 {
ARM_ID, 0x9d8,
"Cortex-A72 PMU",
"(Performance Monitor Unit)", },
1510 {
ARM_ID, 0x9da,
"Cortex-A35 PMU/CTI/ETM",
"(Performance Monitor Unit/Cross Trigger/ETM)", },
1511 {
ARM_ID, 0x9e2,
"SoC-600 APB-AP",
"(APB4 Memory Access Port)", },
1512 {
ARM_ID, 0x9e3,
"SoC-600 AHB-AP",
"(AHB5 Memory Access Port)", },
1513 {
ARM_ID, 0x9e4,
"SoC-600 AXI-AP",
"(AXI Memory Access Port)", },
1514 {
ARM_ID, 0x9e5,
"SoC-600 APv1 Adapter",
"(Access Port v1 Adapter)", },
1515 {
ARM_ID, 0x9e6,
"SoC-600 JTAG-AP",
"(JTAG Access Port)", },
1516 {
ARM_ID, 0x9e7,
"SoC-600 TPIU",
"(Trace Port Interface Unit)", },
1517 {
ARM_ID, 0x9e8,
"SoC-600 TMC ETR/ETS",
"(Embedded Trace Router/Streamer)", },
1518 {
ARM_ID, 0x9e9,
"SoC-600 TMC ETB",
"(Embedded Trace Buffer)", },
1519 {
ARM_ID, 0x9ea,
"SoC-600 TMC ETF",
"(Embedded Trace FIFO)", },
1520 {
ARM_ID, 0x9eb,
"SoC-600 ATB Funnel",
"(Trace Funnel)", },
1521 {
ARM_ID, 0x9ec,
"SoC-600 ATB Replicator",
"(Trace Replicator)", },
1522 {
ARM_ID, 0x9ed,
"SoC-600 CTI",
"(Cross Trigger)", },
1523 {
ARM_ID, 0x9ee,
"SoC-600 CATU",
"(Address Translation Unit)", },
1524 {
ARM_ID, 0xc05,
"Cortex-A5 Debug",
"(Debug Unit)", },
1525 {
ARM_ID, 0xc07,
"Cortex-A7 Debug",
"(Debug Unit)", },
1526 {
ARM_ID, 0xc08,
"Cortex-A8 Debug",
"(Debug Unit)", },
1527 {
ARM_ID, 0xc09,
"Cortex-A9 Debug",
"(Debug Unit)", },
1528 {
ARM_ID, 0xc0e,
"Cortex-A17 Debug",
"(Debug Unit)", },
1529 {
ARM_ID, 0xc0f,
"Cortex-A15 Debug",
"(Debug Unit)", },
1530 {
ARM_ID, 0xc14,
"Cortex-R4 Debug",
"(Debug Unit)", },
1531 {
ARM_ID, 0xc15,
"Cortex-R5 Debug",
"(Debug Unit)", },
1532 {
ARM_ID, 0xc17,
"Cortex-R7 Debug",
"(Debug Unit)", },
1533 {
ARM_ID, 0xd03,
"Cortex-A53 Debug",
"(Debug Unit)", },
1534 {
ARM_ID, 0xd04,
"Cortex-A35 Debug",
"(Debug Unit)", },
1535 {
ARM_ID, 0xd05,
"Cortex-A55 Debug",
"(Debug Unit)", },
1536 {
ARM_ID, 0xd07,
"Cortex-A57 Debug",
"(Debug Unit)", },
1537 {
ARM_ID, 0xd08,
"Cortex-A72 Debug",
"(Debug Unit)", },
1538 {
ARM_ID, 0xd0b,
"Cortex-A76 Debug",
"(Debug Unit)", },
1539 {
ARM_ID, 0xd0c,
"Neoverse N1",
"(Debug Unit)", },
1540 {
ARM_ID, 0xd13,
"Cortex-R52 Debug",
"(Debug Unit)", },
1541 {
ARM_ID, 0xd16,
"Cortex-R52+ Debug",
"(Debug Unit)", },
1542 {
ARM_ID, 0xd21,
"STAR Debug",
"(Debug Unit)", },
1543 {
ARM_ID, 0xd22,
"Cortex-M55 Debug",
"(Debug Unit)", },
1544 {
ARM_ID, 0xd43,
"Cortex-A65AE Debug",
"(Debug Unit)", },
1545 {
ARM_ID, 0xd49,
"Neoverse N2",
"(Debug Unit)", },
1546 { 0x017, 0x120,
"TI SDTI",
"(System Debug Trace Interface)", },
1547 { 0x017, 0x343,
"TI DAPCTL",
"", },
1548 { 0x017, 0x9af,
"MSP432 ROM",
"(ROM Table)" },
1549 { 0x01f, 0xcd0,
"Atmel CPU with DSU",
"(CPU)" },
1550 { 0x041, 0x1db,
"XMC4500 ROM",
"(ROM Table)" },
1551 { 0x041, 0x1df,
"XMC4700/4800 ROM",
"(ROM Table)" },
1552 { 0x041, 0x1ed,
"XMC1000 ROM",
"(ROM Table)" },
1553 { 0x065, 0x000,
"SHARC+/Blackfin+",
"", },
1554 { 0x070, 0x440,
"Qualcomm QDSS Component v1",
"(Qualcomm Designed CoreSight Component v1)", },
1555 { 0x0bf, 0x100,
"Brahma-B53 Debug",
"(Debug Unit)", },
1556 { 0x0bf, 0x9d3,
"Brahma-B53 PMU",
"(Performance Monitor Unit)", },
1557 { 0x0bf, 0x4a1,
"Brahma-B53 ROM",
"(ROM Table)", },
1558 { 0x0bf, 0x721,
"Brahma-B53 ROM",
"(ROM Table)", },
1559 { 0x1eb, 0x181,
"Tegra 186 ROM",
"(ROM Table)", },
1560 { 0x1eb, 0x202,
"Denver ETM",
"(Denver Embedded Trace)", },
1561 { 0x1eb, 0x211,
"Tegra 210 ROM",
"(ROM Table)", },
1562 { 0x1eb, 0x302,
"Denver Debug",
"(Debug Unit)", },
1563 { 0x1eb, 0x402,
"Denver PMU",
"(Performance Monitor Unit)", },
1564 { 0x575, 0x132,
"STAR SCS",
"(System Control Space)", },
1565 { 0x575, 0x4d2,
"Cortex-M52 ROM",
"(ROM Table)", },
1566 { 0x575, 0xd24,
"Cortex-M52 Debug",
"(Debug Unit)", },
1572 .
type =
"Unrecognized",
1585 const char *major =
"Reserved", *subtype =
"Reserved";
1588 switch (devtype_major) {
1590 major =
"Miscellaneous";
1596 subtype =
"Validation component";
1601 major =
"Trace Sink";
1618 major =
"Trace Link";
1624 subtype =
"Funnel, router";
1630 subtype =
"FIFO, buffer";
1635 major =
"Trace Source";
1641 subtype =
"Processor";
1647 subtype =
"Engine/Coprocessor";
1653 subtype =
"Software";
1658 major =
"Debug Control";
1664 subtype =
"Trigger Matrix";
1667 subtype =
"Debug Auth";
1670 subtype =
"Power Requestor";
1675 major =
"Debug Logic";
1681 subtype =
"Processor";
1687 subtype =
"Engine/Coprocessor";
1698 major =
"Performance Monitor";
1704 subtype =
"Processor";
1710 subtype =
"Engine/Coprocessor";
1750 uint32_t apid,
int depth,
void *
priv);
1796 int retval,
struct adiv5_ap *
ap, uint64_t dbgbase, uint32_t apid,
int depth)
1828 int retval,
int depth,
unsigned int offset, uint64_t romentry)
1840 #define ROM_TABLE_MAX_DEPTH (16)
1848 #define CORESIGHT_COMPONENT_FOUND (1)
1856 unsigned int width,
unsigned int max_entries)
1865 while (max_entries--) {
1867 uint32_t romentry_low, romentry_high;
1869 unsigned int saved_offset =
offset;
1880 LOG_DEBUG(
"Failed read ROM table entry");
1885 romentry = (((uint64_t)romentry_high) << 32) | romentry_low;
1889 romentry = romentry_low;
1899 if (romentry == 0) {
1911 LOG_DEBUG(
"Wrong AP # 0x%" PRIx64, component_base);
1914 retval =
rtp_ap(ops, next_ap, depth + 1);
1924 LOG_DEBUG(
"Ignore error parsing CoreSight component");
2031 invalid_entry = 0xFFFFFFFFFFFFFFFFull;
2033 invalid_entry = 0xFFFFFFFFul;
2035 if (dbgbase != invalid_entry && (dbgbase & 0x3) != 0x2) {
2037 dbgbase & 0xFFFFFFFFFFFFF000ull,
NULL, depth);
2069 command_print(
cmd,
"\t\tCan't read MEM-AP, the corresponding core might be turned off");
2079 snprintf(tabs,
sizeof(tabs),
"\t[L%02d] ", depth);
2096 invalid_entry = 0xFFFFFFFFFFFFFFFFull;
2098 invalid_entry = 0xFFFFFFFFul;
2102 if (dbgbase == invalid_entry || (dbgbase & 0x3) == 0x2) {
2128 command_print(
cmd,
"\t\tCan't read component, the corresponding core might be turned off");
2153 designer_id &= 0x7f;
2155 designer_id, designer_id == 0x41 ?
"ARM" :
"<unknown>");
2168 command_print(
cmd,
"\t\tMEMTYPE system memory not present: dedicated debug bus");
2192 command_print(
cmd,
"\t\tMEMTYPE system memory not present: dedicated debug bus");
2202 unsigned int offset, uint64_t romentry,
void *
priv)
2208 snprintf(tabs,
sizeof(tabs),
"[L%02d] ", depth);
2220 if (romentry == 0) {
2235 struct rtp_ops dap_info_ops = {
2243 return rtp_ap(&dap_info_ops, ap, 0);
2294 struct rtp_ops dap_lookup_cs_component_ops = {
2296 .mem_ap_header =
NULL,
2298 .rom_table_entry =
NULL,
2302 int retval =
rtp_ap(&dap_lookup_cs_component_ops, ap, 0);
2306 LOG_DEBUG(
"CS lookup ended in AP # 0x%" PRIx64
". Ignore it", lookup.
ap_num);
2314 LOG_DEBUG(
"CS lookup error %d", retval);
2333 { .name =
NULL, .value = -1 }
2337 struct adiv5_dap **dap_p, uint64_t *ap_num_p, uint32_t *base_p)
2339 assert(dap_p && ap_num_p);
2344 Jim_SetEmptyResult(goi->
interp);
2350 return JIM_CONTINUE;
2354 return JIM_CONTINUE;
2370 Jim_SetResultString(goi->
interp,
"DAP name invalid!", -1);
2373 if (*dap_p && *dap_p != dap) {
2374 Jim_SetResultString(goi->
interp,
2375 "DAP assignment cannot be changed!", -1);
2383 Jim_SetResultString(goi->
interp,
"DAP not configured", -1);
2398 if (ap_num < 0 || (ap_num >
DP_APSEL_MAX && (ap_num & 0xfff))) {
2399 Jim_SetResultString(goi->
interp,
"Invalid AP number!", -1);
2407 Jim_SetResultString(goi->
interp,
"AP number not configured", -1);
2410 Jim_SetResult(goi->
interp, Jim_NewIntObj(goi->
interp, *ap_num_p));
2415 LOG_WARNING(
"DEPRECATED! use \'-baseaddr' not \'-ctibase\'");
2423 *base_p = (uint32_t)base;
2427 Jim_SetResult(goi->
interp, Jim_NewIntObj(goi->
interp, *base_p));
2435 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"NO PARAMS");
2467 Jim_SetResultString(goi->
interp,
2468 "-chain-position and -dap configparams are mutually exclusive!", -1);
2519 if (!strcmp(
CMD_ARGV[0],
"root")) {
2556 uint32_t baseaddr_lower, baseaddr_upper;
2607 baseaddr = (((
target_addr_t)baseaddr_upper) << 32) | baseaddr_lower;
2679 uint32_t csw_val, csw_mask;
2692 if (strcmp(
CMD_ARGV[0],
"default") == 0)
2698 LOG_ERROR(
"CSW value cannot include 'Size' and 'AddrInc' bit-fields");
2712 LOG_ERROR(
"CSW mask cannot include 'Size' and 'AddrInc' bit-fields");
2778 uint32_t
reg, value;
2781 if (CMD_ARGC < 2 || CMD_ARGC > 3)
2792 if (
reg >= 4096 || (
reg & 3)) {
2793 command_print(
CMD,
"Invalid reg value (should be less than 4096 and 4 bytes aligned)");
2797 if (
reg >= 256 || (
reg & 3)) {
2798 command_print(
CMD,
"Invalid reg value (should be less than 256 and 4 bytes aligned)");
2859 uint32_t
reg, value;
2862 if (CMD_ARGC < 1 || CMD_ARGC > 2)
2866 if (
reg >= 256 || (
reg & 3)) {
2867 command_print(
CMD,
"Invalid reg value (should be less than 256 and 4 bytes aligned)");
2893 "TI BE-32 quirks mode");
2900 "Nuvoton NPCX quirks mode");
2906 .handler = handle_dap_info_command,
2908 .help =
"display ROM table for specified MEM-AP (default currently selected AP) "
2909 "or the ADIv6 root ROM table",
2910 .usage =
"[ap_num | 'root']",
2914 .handler = dap_apsel_command,
2916 .help =
"Set the currently selected AP (default 0) "
2917 "and display the result",
2918 .usage =
"[ap_num]",
2922 .handler = dap_apcsw_command,
2924 .help =
"Set CSW default bits",
2925 .usage =
"[value [mask]]",
2930 .handler = dap_apid_command,
2932 .help =
"return ID register from AP "
2933 "(default currently selected AP)",
2934 .usage =
"[ap_num]",
2938 .handler = dap_apreg_command,
2940 .help =
"read/write a register from AP "
2941 "(reg is byte address of a word register, like 0 4 8...)",
2942 .usage =
"ap_num reg [value]",
2946 .handler = dap_dpreg_command,
2948 .help =
"read/write a register from DP "
2949 "(reg is byte address (bank << 4 | reg) of a word register, like 0 4 8...)",
2950 .usage =
"reg [value]",
2954 .handler = dap_baseaddr_command,
2956 .help =
"return debug base address from MEM-AP "
2957 "(default currently selected AP)",
2958 .usage =
"[ap_num]",
2961 .name =
"memaccess",
2962 .handler = dap_memaccess_command,
2964 .help =
"set/get number of extra tck for MEM-AP memory "
2965 "bus access [0-255]",
2966 .usage =
"[cycles]",
2969 .name =
"ti_be_32_quirks",
2970 .handler = dap_ti_be_32_quirks_command,
2972 .help =
"set/get quirks mode for TI TMS450/TMS570 processors",
2973 .usage =
"[enable]",
2976 .name =
"nu_npcx_quirks",
2977 .handler = dap_nu_npcx_quirks_command,
2979 .help =
"set/get quirks mode for Nuvoton NPCX controllers",
2980 .usage =
"[enable]",
Holds the interface to ARM cores.
struct adiv5_ap * dap_get_config_ap(struct adiv5_dap *dap, uint64_t ap_num)
static int mem_ap_write(struct adiv5_ap *ap, const uint8_t *buffer, uint32_t size, uint32_t count, target_addr_t address, bool addrinc)
Synchronous write of a block of memory, using a specific access size.
static int dap_info_mem_ap_header(int retval, struct adiv5_ap *ap, target_addr_t dbgbase, uint32_t apid, int depth, void *priv)
int mem_ap_read_buf(struct adiv5_ap *ap, uint8_t *buffer, uint32_t size, uint32_t count, target_addr_t address)
static int dap_info_ap_header(struct adiv5_ap *ap, int depth, void *priv)
static int dap_queue_read_reg(enum coresight_access_mode mode, struct adiv5_ap *ap, uint64_t component_base, unsigned int reg, uint32_t *value)
Helper to read CoreSight component's registers, either on the bus behind a MEM-AP or directly in the ...
static const char * class_description[16]
static int rtp_ap(const struct rtp_ops *ops, struct adiv5_ap *ap, int depth)
static const struct jim_nvp nvp_config_opts[]
COMMAND_HANDLER(handle_dap_info_command)
int dap_lookup_cs_component(struct adiv5_ap *ap, uint8_t type, target_addr_t *addr, int32_t core_id)
static int rtp_rom_loop(enum coresight_access_mode mode, const struct rtp_ops *ops, struct adiv5_ap *ap, target_addr_t base_address, int depth, unsigned int width, unsigned int max_entries)
int mem_ap_read_buf_noincr(struct adiv5_ap *ap, uint8_t *buffer, uint32_t size, uint32_t count, target_addr_t address)
static uint32_t max_tar_block_size(uint32_t tar_autoincr_block, target_addr_t address)
static int mem_ap_setup_tar(struct adiv5_ap *ap, target_addr_t tar)
int adiv5_verify_config(struct adiv5_private_config *pc)
#define DEVARCH_UNKNOWN_V2
static int mem_ap_setup_transfer(struct adiv5_ap *ap, uint32_t csw, target_addr_t tar)
Queue transactions setting up transfer parameters for the currently selected MEM-AP.
int dap_info_command(struct command_invocation *cmd, struct adiv5_ap *ap)
int mem_ap_read_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t *value)
Asynchronous (queued) read of a word from memory or a system register.
static const char * ap_type_to_description(enum ap_type type)
int adiv5_mem_ap_spot_init(struct adiv5_mem_ap_spot *p)
static int dap_info_cs_component(int retval, struct cs_component_vals *v, int depth, void *priv)
static bool is_ap_in_use(struct adiv5_ap *ap)
int mem_ap_write_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t value)
Asynchronous (queued) write of a word to memory or a system register.
bool is_ap_num_valid(struct adiv5_dap *dap, uint64_t ap_num)
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)
int adiv6_dap_read_baseptr(struct command_invocation *cmd, struct adiv5_dap *dap, uint64_t *baseptr)
static const char * class0x9_devarch_description(uint32_t devarch)
static int dap_info_rom_table_entry(int retval, int depth, unsigned int offset, uint64_t romentry, void *priv)
int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
int dap_find_get_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_ap **ap_out)
static int mem_ap_read_tar(struct adiv5_ap *ap, target_addr_t *tar)
int mem_ap_write_buf_noincr(struct adiv5_ap *ap, const uint8_t *buffer, uint32_t size, uint32_t count, target_addr_t address)
int dap_to_jtag(struct adiv5_dap *dap)
Put the debug link into JTAG mode, if the target supports it.
static int rtp_ops_rom_table_entry(const struct rtp_ops *ops, int retval, int depth, unsigned int offset, uint64_t romentry)
Wrapper around struct rtp_ops::rom_table_entry.
int adiv5_jim_configure_ext(struct target *target, struct jim_getopt_info *goi, struct adiv5_private_config *pc, enum adiv5_configure_dap_optional optional)
int dap_dp_init_or_reconnect(struct adiv5_dap *dap)
Initialize a DAP or do reconnect if DAP is not accessible.
static int dap_get_debugbase(struct adiv5_ap *ap, target_addr_t *dbgbase, uint32_t *apid)
int dap_dp_init(struct adiv5_dap *dap)
Initialize a DAP.
#define ROM_TABLE_MAX_DEPTH
static int mem_ap_setup_transfer_verify_size_packing(struct adiv5_ap *ap, unsigned int size, target_addr_t address, bool addrinc, bool pack, unsigned int *this_size)
Queue transactions setting up transfer parameters for the currently selected MEM-AP.
static int mem_ap_setup_csw(struct adiv5_ap *ap, uint32_t csw)
int mem_ap_read_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t *value)
Synchronous read of a word from memory or a system register.
int dap_to_swd(struct adiv5_dap *dap)
Put the debug link into SWD mode, if the target supports it.
#define DAP_POWER_DOMAIN_TIMEOUT
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
int dap_put_ap(struct adiv5_ap *ap)
int mem_ap_init(struct adiv5_ap *ap)
Initialize a DAP.
static int rtp_ops_mem_ap_header(const struct rtp_ops *ops, int retval, struct adiv5_ap *ap, uint64_t dbgbase, uint32_t apid, int depth)
Wrapper around struct rtp_ops::mem_ap_header.
coresight_access_mode
Method to access the CoreSight component.
int mem_ap_write_buf(struct adiv5_ap *ap, const uint8_t *buffer, uint32_t size, uint32_t count, target_addr_t address)
static const struct @62 ap_types[]
static int dap_devtype_display(struct command_invocation *cmd, uint32_t devtype)
static int rtp_ops_ap_header(const struct rtp_ops *ops, struct adiv5_ap *ap, int depth)
Wrapper around struct rtp_ops::ap_header.
static int mem_ap_read(struct adiv5_ap *ap, uint8_t *buffer, uint32_t size, uint32_t count, target_addr_t adr, bool addrinc)
Synchronous read of a block of memory, using a specific access size.
#define ARCH_ID(architect, archid)
void dap_invalidate_cache(struct adiv5_dap *dap)
Invalidate cached DP select and cached TAR and CSW of all APs.
static int dap_lookup_cs_component_cs_component(int retval, struct cs_component_vals *v, int depth, void *priv)
static int rtp_ops_cs_component(const struct rtp_ops *ops, int retval, struct cs_component_vals *v, int depth)
Wrapper around struct rtp_ops::cs_component.
#define DEVARCH_ROM_C_0X9
static const struct dap_part_nums * pidr_to_part_num(unsigned int designer_id, unsigned int part_num)
static void mem_ap_update_tar_cache(struct adiv5_ap *ap)
const struct command_registration dap_instance_commands[]
static int rtp_read_cs_regs(enum coresight_access_mode mode, struct adiv5_ap *ap, target_addr_t component_base, struct cs_component_vals *v)
Read the CoreSight registers needed during ROM Table Parsing (RTP).
#define CORESIGHT_COMPONENT_FOUND
Value used only during lookup of a CoreSight component in ROM table.
static uint32_t mem_ap_get_tar_increment(struct adiv5_ap *ap)
static struct adiv5_ap * _dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
int adiv5_jim_mem_ap_spot_configure(struct adiv5_mem_ap_spot *cfg, struct jim_getopt_info *goi)
static const struct @61 class0x9_devarch[]
static int rtp_cs_component(enum coresight_access_mode mode, const struct rtp_ops *ops, struct adiv5_ap *ap, target_addr_t dbgbase, bool *is_mem_ap, int depth)
static int mem_ap_setup_transfer_verify_size_packing_fallback(struct adiv5_ap *ap, unsigned int size, target_addr_t address, bool addrinc, bool pack, unsigned int *this_size)
Queue transactions setting up transfer parameters for the currently selected MEM-AP.
int mem_ap_write_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t value)
Synchronous write of a word to memory or a system register.
This defines formats and data structures used to talk to ADIv5 entities.
static int dap_dp_poll_register(struct adiv5_dap *dap, unsigned int reg, uint32_t mask, uint32_t value, int timeout)
#define MEM_AP_REG_CSW(dap)
#define CSW_ADDRINC_PACKED
static bool is_64bit_ap(struct adiv5_ap *ap)
static int dap_queue_dp_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
Queue a DP register write.
#define AP_REG_IDR_CLASS_SHIFT
#define MEM_AP_REG_CFG(dap)
static int dap_queue_ap_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
Queue an AP register read.
#define MEM_AP_REG_TAR(dap)
#define MEM_AP_REG_CFG_LD
struct adiv5_dap * dap_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
static int dap_send_sequence(struct adiv5_dap *dap, enum swd_special_seq seq)
Send an adi-v5 sequence to the DAP.
#define AP_REG_IDR_CLASS_MASK
adiv5_configure_dap_optional
@ ADI_CONFIGURE_DAP_COMPULSORY
#define CSW_ADDRINC_SINGLE
#define AP_REG_IDR_CLASS_MEM_AP
#define MEM_AP_REG_CFG_BE
#define DP_BASEPTR0_VALID
struct adiv5_dap * adiv5_get_dap(struct arm_dap_object *obj)
static int dap_queue_dp_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
Queue a DP register read.
#define MEM_AP_REG_CFG_LA
#define MEM_AP_REG_DRW(dap)
static int dap_dp_read_atomic(struct adiv5_dap *dap, unsigned int reg, uint32_t *value)
#define MEM_AP_REG_BASE(dap)
static int dap_queue_ap_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
Queue an AP register write.
#define MEM_AP_REG_BASE64(dap)
const char * adiv5_dap_name(struct adiv5_dap *self)
#define MEM_AP_REG_BD0(dap)
static bool is_adiv6(const struct adiv5_dap *dap)
Check if DAP is ADIv6.
#define MEM_AP_REG_TAR64(dap)
static int dap_run(struct adiv5_dap *dap)
Perform all queued DAP operations, and clear any errors posted in the CTRL_STAT register when they ar...
#define MEM_AP_REG_CFG_INVALID
#define ARM_CS_CLASS_0X1_ROM_TABLE
#define ARM_CS_C9_DEVID_SYSMEM_MASK
static bool is_valid_arm_cs_cidr(uint32_t cidr)
#define ARM_CS_C9_DEVTYPE_MASK
#define ARM_CS_PIDR_SIZE(pidr)
#define ARM_CS_CLASS_0X9_CS_COMPONENT
#define ARM_CS_C9_DEVARCH
#define ARM_CS_C9_DEVTYPE_SUB_SHIFT
#define ARM_CS_CIDR_CLASS(cidr)
#define ARM_CS_C9_DEVARCH_REVISION(devarch)
#define ARM_CS_ROMENTRY_PRESENT
#define ARM_CS_C9_DEVTYPE_MAJOR_SHIFT
#define ARM_CS_C9_DEVTYPE
#define ARM_CS_C9_DEVTYPE_MAJOR_MASK
#define ARM_CS_C1_MEMTYPE_SYSMEM_MASK
#define ARM_CS_C9_DEVID_FORMAT_MASK
#define ARM_CS_ROMENTRY_OFFSET_MASK
#define ARM_CS_C9_DEVARCH_ARCHITECT(devarch)
#define ARM_CS_PIDR_JEDEC
#define ARM_CS_PIDR_PART(pidr)
#define ARM_CS_C9_DEVTYPE_SUB_MASK
#define ARM_CS_C9_DEVID_FORMAT_64BIT
#define ARM_CS_C9_DEVARCH_PRESENT
#define ARM_CS_PIDR_DESIGNER(pidr)
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_DATA
Use this macro to access the invoked command handler's data pointer, rather than accessing the variab...
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
static struct esp_usb_jtag * priv
static const char * jep106_manufacturer(unsigned int manufacturer)
int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
Remove argv[0] as wide.
int jim_nvp_name2value_obj(Jim_Interp *interp, const struct jim_nvp *p, Jim_Obj *o, struct jim_nvp **result)
int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
target_addr_t addr
Start address to search for the control block.
size_t size
Size of the control block search area.
This represents an ARM Debug Interface (v5) Access Port (AP).
uint32_t csw_size_supported_mask
Save the supported CSW.Size data types for the MEM-AP.
bool unaligned_access_bad
bool config_ap_never_release
bool packed_transfers_probed
bool packed_transfers_supported
uint32_t tar_autoincr_block
uint32_t csw_size_probed_mask
Probed CSW.Size data types for the MEM-AP.
uint64_t ap_num
ADIv5: Number of this AP (0~255) ADIv6: Base address of this AP (4k aligned) TODO: to be more coheren...
struct adiv5_dap * dap
DAP this AP belongs to.
uint32_t memaccess_tck
Configures how many extra tck clocks are added after starting a MEM-AP access before we try to read i...
uint32_t csw_default
Default value for (MEM-AP) AP_REG_CSW register.
target_addr_t tar_value
Cache for (MEM-AP) AP_REG_TAR register value This is written to configure the address being read or w...
uint32_t csw_value
Cache for (MEM-AP) AP_REG_CSW register value.
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
bool select_valid
Validity of DP SELECT cache.
struct adiv5_ap ap[DP_APSEL_MAX+1]
bool select_dpbanksel_valid
Partial DPBANKSEL validity for SWD only.
bool do_reconnect
Signals that an attempt to reestablish communication afresh should be performed before the next acces...
const struct dap_ops * ops
uint32_t * last_read
Holds the pointer to the destination word for the last queued read, for use with posted AP read seque...
uint64_t select
Cache for DP SELECT and SELECT1 (ADIv6) register.
bool ignore_syspwrupack
Flag saying whether to ignore the syspwrupack flag in DAP.
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Holds registers and coordinates of a CoreSight component.
enum coresight_access_mode mode
target_addr_t component_base
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
A TCL -ish GetOpt like code.
Name Value Pairs, aka: NVP.
Actions/operations to be executed while parsing ROM tables.
int(* mem_ap_header)(int retval, struct adiv5_ap *ap, uint64_t dbgbase, uint32_t apid, int depth, void *priv)
Executed at the start of a new MEM-AP, typically to print the MEM-AP header.
int(* rom_table_entry)(int retval, int depth, unsigned int offset, uint64_t romentry, void *priv)
Executed for each entry of a ROM table, typically to print the entry and information about validity o...
int(* cs_component)(int retval, struct cs_component_vals *v, int depth, void *priv)
Executed when a CoreSight component is parsed, typically to print information on the component.
int(* ap_header)(struct adiv5_ap *ap, int depth, void *priv)
Executed at the start of a new AP, typically to print the AP header.
#define ERROR_TARGET_SIZE_NOT_SUPPORTED
#define ERROR_TARGET_UNALIGNED_ACCESS
#define ERROR_TARGET_PACKING_NOT_SUPPORTED
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static struct ublast_lowlevel low