84 return tar_autoincr_block - ((tar_autoincr_block - 1) & address);
240 address & 0xFFFFFFFFFFFFFFF0ull);
292 address & 0xFFFFFFFFFFFFFFF0ull);
360 }
else if (
size == 2) {
363 }
else if (
size == 1) {
374 uint32_t this_size =
size;
394 uint32_t outvalue = 0;
395 uint32_t drw_byte_idx = address;
399 outvalue |= (uint32_t)*
buffer++ << 8 * (3 ^ (drw_byte_idx++ & 3) ^ addr_xor);
400 outvalue |= (uint32_t)*
buffer++ << 8 * (3 ^ (drw_byte_idx++ & 3) ^ addr_xor);
401 outvalue |= (uint32_t)*
buffer++ << 8 * (3 ^ (drw_byte_idx++ & 3) ^ addr_xor);
402 outvalue |= (uint32_t)*
buffer++ << 8 * (3 ^ (drw_byte_idx & 3) ^ addr_xor);
405 outvalue |= (uint32_t)*
buffer++ << 8 * (1 ^ (drw_byte_idx++ & 3) ^ addr_xor);
406 outvalue |= (uint32_t)*
buffer++ << 8 * (1 ^ (drw_byte_idx & 3) ^ addr_xor);
409 outvalue |= (uint32_t)*
buffer++ << 8 * (0 ^ (drw_byte_idx & 3) ^ addr_xor);
415 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
416 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
417 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
418 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx & 3);
421 outvalue |= (uint32_t)*
buffer << 8 * (drw_byte_idx++ & 3);
422 outvalue |= (uint32_t)*(
buffer+1) << 8 * (drw_byte_idx++ & 3);
423 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
424 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx & 3);
427 outvalue |= (uint32_t)*
buffer << 8 * (drw_byte_idx++ & 3);
428 outvalue |= (uint32_t)*
buffer << 8 * (drw_byte_idx++ & 3);
429 outvalue |= (uint32_t)*
buffer << 8 * (drw_byte_idx++ & 3);
430 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx & 3);
435 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
436 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
439 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx++ & 3);
442 outvalue |= (uint32_t)*
buffer++ << 8 * (drw_byte_idx & 3);
454 address += this_size;
466 LOG_ERROR(
"Failed to write memory and, additionally, failed to find out where");
516 uint32_t *read_buf = calloc(
count,
sizeof(uint32_t));
518 uint32_t *read_ptr = read_buf;
520 LOG_ERROR(
"Failed to allocate read buffer");
528 uint32_t this_size =
size;
551 address += this_size;
571 if (nbytes > tar - address)
572 nbytes = tar - address;
574 LOG_ERROR(
"Failed to read memory and, additionally, failed to find out where");
581 uint32_t this_size =
size;
591 *
buffer++ = *read_ptr >> 8 * (3 - (address++ & 3));
592 *
buffer++ = *read_ptr >> 8 * (3 - (address++ & 3));
595 *
buffer++ = *read_ptr >> 8 * (3 - (address++ & 3));
598 *
buffer++ = *read_ptr >> 8 * (3 - (address++ & 3));
603 *
buffer++ = *read_ptr >> 8 * (address++ & 3);
604 *
buffer++ = *read_ptr >> 8 * (address++ & 3);
607 *
buffer++ = *read_ptr >> 8 * (address++ & 3);
610 *
buffer++ = *read_ptr >> 8 * (address++ & 3);
649 #define DAP_POWER_DOMAIN_TIMEOUT (10)
836 LOG_DEBUG(
"MEM_AP CFG: large data %d, long address %d, big-endian %d",
887 [0x0] =
"Generic verification component",
896 [0x9] =
"CoreSight component",
898 [0xB] =
"Peripheral Test Block",
900 [0xD] =
"OptimoDE DESS",
901 [0xE] =
"Generic IP component",
902 [0xF] =
"CoreLink, PrimeCell or System component",
905 #define ARCH_ID(architect, archid) ( \
906 (((architect) << ARM_CS_C9_DEVARCH_ARCHITECT_SHIFT) & ARM_CS_C9_DEVARCH_ARCHITECT_MASK) | \
907 (((archid) << ARM_CS_C9_DEVARCH_ARCHID_SHIFT) & ARM_CS_C9_DEVARCH_ARCHID_MASK) \
910 static const struct {
916 {
ARCH_ID(
ARM_ID, 0x1A01),
"Instrumentation Trace Macrocell (ITM) architecture" },
918 {
ARCH_ID(
ARM_ID, 0x1A03),
"Flash Patch and Breakpoint unit (FPB) architecture" },
919 {
ARCH_ID(
ARM_ID, 0x2A04),
"Processor debug architecture (ARMv8-M)" },
920 {
ARCH_ID(
ARM_ID, 0x6A05),
"Processor debug architecture (ARMv8-R)" },
922 {
ARCH_ID(
ARM_ID, 0x4A13),
"Embedded Trace Macrocell (ETM) architecture" },
923 {
ARCH_ID(
ARM_ID, 0x1A14),
"Cross Trigger Interface (CTI) architecture" },
924 {
ARCH_ID(
ARM_ID, 0x6A15),
"Processor debug architecture (v8.0-A)" },
925 {
ARCH_ID(
ARM_ID, 0x7A15),
"Processor debug architecture (v8.1-A)" },
926 {
ARCH_ID(
ARM_ID, 0x8A15),
"Processor debug architecture (v8.2-A)" },
927 {
ARCH_ID(
ARM_ID, 0x2A16),
"Processor Performance Monitor (PMU) architecture" },
928 {
ARCH_ID(
ARM_ID, 0x0A17),
"Memory Access Port v2 architecture" },
929 {
ARCH_ID(
ARM_ID, 0x0A27),
"JTAG Access Port v2 architecture" },
932 {
ARCH_ID(
ARM_ID, 0x0A47),
"Unknown Access Port v2 architecture" },
934 {
ARCH_ID(
ARM_ID, 0x0A63),
"System Trace Macrocell (STM) architecture" },
939 #define DEVARCH_ID_MASK (ARM_CS_C9_DEVARCH_ARCHITECT_MASK | ARM_CS_C9_DEVARCH_ARCHID_MASK)
940 #define DEVARCH_MEM_AP ARCH_ID(ARM_ID, 0x0A17)
941 #define DEVARCH_ROM_C_0X9 ARCH_ID(ARM_ID, 0x0AF7)
942 #define DEVARCH_UNKNOWN_V2 ARCH_ID(ARM_ID, 0x0A47)
947 return "not present";
956 static const struct {
994 if (ap_num & 0x0fffULL)
997 if (ap_num & ((~0ULL) << dap->
asize))
1013 LOG_DEBUG(
"On ADIv6 we cannot scan all the possible AP");
1018 for (
unsigned int ap_num = 0; ap_num <=
DP_APSEL_MAX; ap_num++) {
1024 uint32_t id_val = 0;
1038 LOG_DEBUG(
"Found %s at AP index: %d (IDR=0x%08" PRIX32
")",
1114 LOG_ERROR(
"BUG: refcount AP#0x%" PRIx64
" put underflow", ap->
ap_num);
1137 uint32_t baseptr_upper, baseptr_lower;
1163 *dbgbase = (((
target_addr_t)baseptr_upper) << 32) | baseptr_lower;
1170 uint32_t baseptr_lower, baseptr_upper = 0;
1173 if (dap->
asize > 32) {
1188 baseptr_lower &= ~0x0fff;
1189 *baseptr = (((uint64_t)baseptr_upper) << 32) | baseptr_lower;
1230 uint64_t component_base,
unsigned int reg, uint32_t *value)
1255 uint32_t cid0, cid1, cid2, cid3;
1256 uint32_t pid0, pid1, pid2, pid3, pid4;
1304 LOG_DEBUG(
"Failed read CoreSight registers");
1308 v->
cid = (cid3 & 0xff) << 24
1309 | (cid2 & 0xff) << 16
1310 | (cid1 & 0xff) << 8
1312 v->
pid = (uint64_t)(pid4 & 0xff) << 32
1313 | (pid3 & 0xff) << 24
1314 | (pid2 & 0xff) << 16
1315 | (pid1 & 0xff) << 8
1334 {
ARM_ID, 0x000,
"Cortex-M3 SCS",
"(System Control Space)", },
1335 {
ARM_ID, 0x001,
"Cortex-M3 ITM",
"(Instrumentation Trace Module)", },
1336 {
ARM_ID, 0x002,
"Cortex-M3 DWT",
"(Data Watchpoint and Trace)", },
1337 {
ARM_ID, 0x003,
"Cortex-M3 FPB",
"(Flash Patch and Breakpoint)", },
1338 {
ARM_ID, 0x008,
"Cortex-M0 SCS",
"(System Control Space)", },
1339 {
ARM_ID, 0x00a,
"Cortex-M0 DWT",
"(Data Watchpoint and Trace)", },
1340 {
ARM_ID, 0x00b,
"Cortex-M0 BPU",
"(Breakpoint Unit)", },
1341 {
ARM_ID, 0x00c,
"Cortex-M4 SCS",
"(System Control Space)", },
1342 {
ARM_ID, 0x00d,
"CoreSight ETM11",
"(Embedded Trace)", },
1343 {
ARM_ID, 0x00e,
"Cortex-M7 FPB",
"(Flash Patch and Breakpoint)", },
1344 {
ARM_ID, 0x193,
"SoC-600 TSGEN",
"(Timestamp Generator)", },
1345 {
ARM_ID, 0x470,
"Cortex-M1 ROM",
"(ROM Table)", },
1346 {
ARM_ID, 0x471,
"Cortex-M0 ROM",
"(ROM Table)", },
1347 {
ARM_ID, 0x490,
"Cortex-A15 GIC",
"(Generic Interrupt Controller)", },
1348 {
ARM_ID, 0x492,
"Cortex-R52 GICD",
"(Distributor)", },
1349 {
ARM_ID, 0x493,
"Cortex-R52 GICR",
"(Redistributor)", },
1350 {
ARM_ID, 0x4a1,
"Cortex-A53 ROM",
"(v8 Memory Map ROM Table)", },
1351 {
ARM_ID, 0x4a2,
"Cortex-A57 ROM",
"(ROM Table)", },
1352 {
ARM_ID, 0x4a3,
"Cortex-A53 ROM",
"(v7 Memory Map ROM Table)", },
1353 {
ARM_ID, 0x4a4,
"Cortex-A72 ROM",
"(ROM Table)", },
1354 {
ARM_ID, 0x4a9,
"Cortex-A9 ROM",
"(ROM Table)", },
1355 {
ARM_ID, 0x4aa,
"Cortex-A35 ROM",
"(v8 Memory Map ROM Table)", },
1356 {
ARM_ID, 0x4af,
"Cortex-A15 ROM",
"(ROM Table)", },
1357 {
ARM_ID, 0x4b5,
"Cortex-R5 ROM",
"(ROM Table)", },
1358 {
ARM_ID, 0x4b8,
"Cortex-R52 ROM",
"(ROM Table)", },
1359 {
ARM_ID, 0x4c0,
"Cortex-M0+ ROM",
"(ROM Table)", },
1360 {
ARM_ID, 0x4c3,
"Cortex-M3 ROM",
"(ROM Table)", },
1361 {
ARM_ID, 0x4c4,
"Cortex-M4 ROM",
"(ROM Table)", },
1362 {
ARM_ID, 0x4c7,
"Cortex-M7 PPB ROM",
"(Private Peripheral Bus ROM Table)", },
1363 {
ARM_ID, 0x4c8,
"Cortex-M7 ROM",
"(ROM Table)", },
1364 {
ARM_ID, 0x4e0,
"Cortex-A35 ROM",
"(v7 Memory Map ROM Table)", },
1365 {
ARM_ID, 0x4e4,
"Cortex-A76 ROM",
"(ROM Table)", },
1366 {
ARM_ID, 0x906,
"CoreSight CTI",
"(Cross Trigger)", },
1367 {
ARM_ID, 0x907,
"CoreSight ETB",
"(Trace Buffer)", },
1368 {
ARM_ID, 0x908,
"CoreSight CSTF",
"(Trace Funnel)", },
1369 {
ARM_ID, 0x909,
"CoreSight ATBR",
"(Advanced Trace Bus Replicator)", },
1370 {
ARM_ID, 0x910,
"CoreSight ETM9",
"(Embedded Trace)", },
1371 {
ARM_ID, 0x912,
"CoreSight TPIU",
"(Trace Port Interface Unit)", },
1372 {
ARM_ID, 0x913,
"CoreSight ITM",
"(Instrumentation Trace Macrocell)", },
1373 {
ARM_ID, 0x914,
"CoreSight SWO",
"(Single Wire Output)", },
1374 {
ARM_ID, 0x917,
"CoreSight HTM",
"(AHB Trace Macrocell)", },
1375 {
ARM_ID, 0x920,
"CoreSight ETM11",
"(Embedded Trace)", },
1376 {
ARM_ID, 0x921,
"Cortex-A8 ETM",
"(Embedded Trace)", },
1377 {
ARM_ID, 0x922,
"Cortex-A8 CTI",
"(Cross Trigger)", },
1378 {
ARM_ID, 0x923,
"Cortex-M3 TPIU",
"(Trace Port Interface Unit)", },
1379 {
ARM_ID, 0x924,
"Cortex-M3 ETM",
"(Embedded Trace)", },
1380 {
ARM_ID, 0x925,
"Cortex-M4 ETM",
"(Embedded Trace)", },
1381 {
ARM_ID, 0x930,
"Cortex-R4 ETM",
"(Embedded Trace)", },
1382 {
ARM_ID, 0x931,
"Cortex-R5 ETM",
"(Embedded Trace)", },
1383 {
ARM_ID, 0x932,
"CoreSight MTB-M0+",
"(Micro Trace Buffer)", },
1384 {
ARM_ID, 0x941,
"CoreSight TPIU-Lite",
"(Trace Port Interface Unit)", },
1385 {
ARM_ID, 0x950,
"Cortex-A9 PTM",
"(Program Trace Macrocell)", },
1386 {
ARM_ID, 0x955,
"Cortex-A5 ETM",
"(Embedded Trace)", },
1387 {
ARM_ID, 0x95a,
"Cortex-A72 ETM",
"(Embedded Trace)", },
1388 {
ARM_ID, 0x95b,
"Cortex-A17 PTM",
"(Program Trace Macrocell)", },
1389 {
ARM_ID, 0x95d,
"Cortex-A53 ETM",
"(Embedded Trace)", },
1390 {
ARM_ID, 0x95e,
"Cortex-A57 ETM",
"(Embedded Trace)", },
1391 {
ARM_ID, 0x95f,
"Cortex-A15 PTM",
"(Program Trace Macrocell)", },
1392 {
ARM_ID, 0x961,
"CoreSight TMC",
"(Trace Memory Controller)", },
1393 {
ARM_ID, 0x962,
"CoreSight STM",
"(System Trace Macrocell)", },
1394 {
ARM_ID, 0x975,
"Cortex-M7 ETM",
"(Embedded Trace)", },
1395 {
ARM_ID, 0x9a0,
"CoreSight PMU",
"(Performance Monitoring Unit)", },
1396 {
ARM_ID, 0x9a1,
"Cortex-M4 TPIU",
"(Trace Port Interface Unit)", },
1397 {
ARM_ID, 0x9a4,
"CoreSight GPR",
"(Granular Power Requester)", },
1398 {
ARM_ID, 0x9a5,
"Cortex-A5 PMU",
"(Performance Monitor Unit)", },
1399 {
ARM_ID, 0x9a7,
"Cortex-A7 PMU",
"(Performance Monitor Unit)", },
1400 {
ARM_ID, 0x9a8,
"Cortex-A53 CTI",
"(Cross Trigger)", },
1401 {
ARM_ID, 0x9a9,
"Cortex-M7 TPIU",
"(Trace Port Interface Unit)", },
1402 {
ARM_ID, 0x9ae,
"Cortex-A17 PMU",
"(Performance Monitor Unit)", },
1403 {
ARM_ID, 0x9af,
"Cortex-A15 PMU",
"(Performance Monitor Unit)", },
1404 {
ARM_ID, 0x9b6,
"Cortex-R52 PMU/CTI/ETM",
"(Performance Monitor Unit/Cross Trigger/ETM)", },
1405 {
ARM_ID, 0x9b7,
"Cortex-R7 PMU",
"(Performance Monitor Unit)", },
1406 {
ARM_ID, 0x9d3,
"Cortex-A53 PMU",
"(Performance Monitor Unit)", },
1407 {
ARM_ID, 0x9d7,
"Cortex-A57 PMU",
"(Performance Monitor Unit)", },
1408 {
ARM_ID, 0x9d8,
"Cortex-A72 PMU",
"(Performance Monitor Unit)", },
1409 {
ARM_ID, 0x9da,
"Cortex-A35 PMU/CTI/ETM",
"(Performance Monitor Unit/Cross Trigger/ETM)", },
1410 {
ARM_ID, 0x9e2,
"SoC-600 APB-AP",
"(APB4 Memory Access Port)", },
1411 {
ARM_ID, 0x9e3,
"SoC-600 AHB-AP",
"(AHB5 Memory Access Port)", },
1412 {
ARM_ID, 0x9e4,
"SoC-600 AXI-AP",
"(AXI Memory Access Port)", },
1413 {
ARM_ID, 0x9e5,
"SoC-600 APv1 Adapter",
"(Access Port v1 Adapter)", },
1414 {
ARM_ID, 0x9e6,
"SoC-600 JTAG-AP",
"(JTAG Access Port)", },
1415 {
ARM_ID, 0x9e7,
"SoC-600 TPIU",
"(Trace Port Interface Unit)", },
1416 {
ARM_ID, 0x9e8,
"SoC-600 TMC ETR/ETS",
"(Embedded Trace Router/Streamer)", },
1417 {
ARM_ID, 0x9e9,
"SoC-600 TMC ETB",
"(Embedded Trace Buffer)", },
1418 {
ARM_ID, 0x9ea,
"SoC-600 TMC ETF",
"(Embedded Trace FIFO)", },
1419 {
ARM_ID, 0x9eb,
"SoC-600 ATB Funnel",
"(Trace Funnel)", },
1420 {
ARM_ID, 0x9ec,
"SoC-600 ATB Replicator",
"(Trace Replicator)", },
1421 {
ARM_ID, 0x9ed,
"SoC-600 CTI",
"(Cross Trigger)", },
1422 {
ARM_ID, 0x9ee,
"SoC-600 CATU",
"(Address Translation Unit)", },
1423 {
ARM_ID, 0xc05,
"Cortex-A5 Debug",
"(Debug Unit)", },
1424 {
ARM_ID, 0xc07,
"Cortex-A7 Debug",
"(Debug Unit)", },
1425 {
ARM_ID, 0xc08,
"Cortex-A8 Debug",
"(Debug Unit)", },
1426 {
ARM_ID, 0xc09,
"Cortex-A9 Debug",
"(Debug Unit)", },
1427 {
ARM_ID, 0xc0e,
"Cortex-A17 Debug",
"(Debug Unit)", },
1428 {
ARM_ID, 0xc0f,
"Cortex-A15 Debug",
"(Debug Unit)", },
1429 {
ARM_ID, 0xc14,
"Cortex-R4 Debug",
"(Debug Unit)", },
1430 {
ARM_ID, 0xc15,
"Cortex-R5 Debug",
"(Debug Unit)", },
1431 {
ARM_ID, 0xc17,
"Cortex-R7 Debug",
"(Debug Unit)", },
1432 {
ARM_ID, 0xd03,
"Cortex-A53 Debug",
"(Debug Unit)", },
1433 {
ARM_ID, 0xd04,
"Cortex-A35 Debug",
"(Debug Unit)", },
1434 {
ARM_ID, 0xd07,
"Cortex-A57 Debug",
"(Debug Unit)", },
1435 {
ARM_ID, 0xd08,
"Cortex-A72 Debug",
"(Debug Unit)", },
1436 {
ARM_ID, 0xd0b,
"Cortex-A76 Debug",
"(Debug Unit)", },
1437 {
ARM_ID, 0xd0c,
"Neoverse N1",
"(Debug Unit)", },
1438 {
ARM_ID, 0xd13,
"Cortex-R52 Debug",
"(Debug Unit)", },
1439 {
ARM_ID, 0xd49,
"Neoverse N2",
"(Debug Unit)", },
1440 { 0x017, 0x120,
"TI SDTI",
"(System Debug Trace Interface)", },
1441 { 0x017, 0x343,
"TI DAPCTL",
"", },
1442 { 0x017, 0x9af,
"MSP432 ROM",
"(ROM Table)" },
1443 { 0x01f, 0xcd0,
"Atmel CPU with DSU",
"(CPU)" },
1444 { 0x041, 0x1db,
"XMC4500 ROM",
"(ROM Table)" },
1445 { 0x041, 0x1df,
"XMC4700/4800 ROM",
"(ROM Table)" },
1446 { 0x041, 0x1ed,
"XMC1000 ROM",
"(ROM Table)" },
1447 { 0x065, 0x000,
"SHARC+/Blackfin+",
"", },
1448 { 0x070, 0x440,
"Qualcomm QDSS Component v1",
"(Qualcomm Designed CoreSight Component v1)", },
1449 { 0x0bf, 0x100,
"Brahma-B53 Debug",
"(Debug Unit)", },
1450 { 0x0bf, 0x9d3,
"Brahma-B53 PMU",
"(Performance Monitor Unit)", },
1451 { 0x0bf, 0x4a1,
"Brahma-B53 ROM",
"(ROM Table)", },
1452 { 0x0bf, 0x721,
"Brahma-B53 ROM",
"(ROM Table)", },
1453 { 0x1eb, 0x181,
"Tegra 186 ROM",
"(ROM Table)", },
1454 { 0x1eb, 0x202,
"Denver ETM",
"(Denver Embedded Trace)", },
1455 { 0x1eb, 0x211,
"Tegra 210 ROM",
"(ROM Table)", },
1456 { 0x1eb, 0x302,
"Denver Debug",
"(Debug Unit)", },
1457 { 0x1eb, 0x402,
"Denver PMU",
"(Performance Monitor Unit)", },
1463 .
type =
"Unrecognized",
1476 const char *major =
"Reserved", *subtype =
"Reserved";
1479 switch (devtype_major) {
1481 major =
"Miscellaneous";
1487 subtype =
"Validation component";
1492 major =
"Trace Sink";
1509 major =
"Trace Link";
1515 subtype =
"Funnel, router";
1521 subtype =
"FIFO, buffer";
1526 major =
"Trace Source";
1532 subtype =
"Processor";
1538 subtype =
"Engine/Coprocessor";
1544 subtype =
"Software";
1549 major =
"Debug Control";
1555 subtype =
"Trigger Matrix";
1558 subtype =
"Debug Auth";
1561 subtype =
"Power Requestor";
1566 major =
"Debug Logic";
1572 subtype =
"Processor";
1578 subtype =
"Engine/Coprocessor";
1589 major =
"Performance Monitor";
1595 subtype =
"Processor";
1601 subtype =
"Engine/Coprocessor";
1641 uint32_t apid,
int depth,
void *
priv);
1687 int retval,
struct adiv5_ap *
ap, uint64_t dbgbase, uint32_t apid,
int depth)
1719 int retval,
int depth,
unsigned int offset, uint64_t romentry)
1731 #define ROM_TABLE_MAX_DEPTH (16)
1739 #define CORESIGHT_COMPONENT_FOUND (1)
1747 unsigned int width,
unsigned int max_entries)
1756 while (max_entries--) {
1758 uint32_t romentry_low, romentry_high;
1760 unsigned int saved_offset =
offset;
1771 LOG_DEBUG(
"Failed read ROM table entry");
1776 romentry = (((uint64_t)romentry_high) << 32) | romentry_low;
1780 romentry = romentry_low;
1790 if (romentry == 0) {
1802 LOG_DEBUG(
"Wrong AP # 0x%" PRIx64, component_base);
1805 retval =
rtp_ap(ops, next_ap, depth + 1);
1815 LOG_DEBUG(
"Ignore error parsing CoreSight component");
1922 invalid_entry = 0xFFFFFFFFFFFFFFFFull;
1924 invalid_entry = 0xFFFFFFFFul;
1926 if (dbgbase != invalid_entry && (dbgbase & 0x3) != 0x2) {
1928 dbgbase & 0xFFFFFFFFFFFFF000ull,
NULL, depth);
1960 command_print(
cmd,
"\t\tCan't read MEM-AP, the corresponding core might be turned off");
1970 snprintf(tabs,
sizeof(tabs),
"\t[L%02d] ", depth);
1987 invalid_entry = 0xFFFFFFFFFFFFFFFFull;
1989 invalid_entry = 0xFFFFFFFFul;
1993 if (dbgbase == invalid_entry || (dbgbase & 0x3) == 0x2) {
2019 command_print(
cmd,
"\t\tCan't read component, the corresponding core might be turned off");
2044 designer_id &= 0x7f;
2046 designer_id, designer_id == 0x41 ?
"ARM" :
"<unknown>");
2059 command_print(
cmd,
"\t\tMEMTYPE system memory not present: dedicated debug bus");
2083 command_print(
cmd,
"\t\tMEMTYPE system memory not present: dedicated debug bus");
2093 unsigned int offset, uint64_t romentry,
void *
priv)
2099 snprintf(tabs,
sizeof(tabs),
"[L%02d] ", depth);
2111 if (romentry == 0) {
2126 struct rtp_ops dap_info_ops = {
2134 return rtp_ap(&dap_info_ops, ap, 0);
2185 struct rtp_ops dap_lookup_cs_component_ops = {
2187 .mem_ap_header =
NULL,
2189 .rom_table_entry =
NULL,
2193 int retval =
rtp_ap(&dap_lookup_cs_component_ops, ap, 0);
2197 LOG_DEBUG(
"CS lookup ended in AP # 0x%" PRIx64
". Ignore it", lookup.
ap_num);
2205 LOG_DEBUG(
"CS lookup error %d", retval);
2224 { .name =
NULL, .value = -1 }
2228 struct adiv5_dap **dap_p, uint64_t *ap_num_p, uint32_t *base_p)
2230 assert(dap_p && ap_num_p);
2235 Jim_SetEmptyResult(goi->
interp);
2241 return JIM_CONTINUE;
2245 return JIM_CONTINUE;
2261 Jim_SetResultString(goi->
interp,
"DAP name invalid!", -1);
2264 if (*dap_p && *dap_p != dap) {
2265 Jim_SetResultString(goi->
interp,
2266 "DAP assignment cannot be changed!", -1);
2274 Jim_SetResultString(goi->
interp,
"DAP not configured", -1);
2289 if (ap_num < 0 || (ap_num >
DP_APSEL_MAX && (ap_num & 0xfff))) {
2290 Jim_SetResultString(goi->
interp,
"Invalid AP number!", -1);
2298 Jim_SetResultString(goi->
interp,
"AP number not configured", -1);
2301 Jim_SetResult(goi->
interp, Jim_NewIntObj(goi->
interp, *ap_num_p));
2306 LOG_WARNING(
"DEPRECATED! use \'-baseaddr' not \'-ctibase\'");
2314 *base_p = (uint32_t)base;
2318 Jim_SetResult(goi->
interp, Jim_NewIntObj(goi->
interp, *base_p));
2326 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"NO PARAMS");
2355 Jim_SetResultString(goi->
interp,
2356 "-chain-position and -dap configparams are mutually exclusive!", -1);
2401 if (!strcmp(
CMD_ARGV[0],
"root")) {
2438 uint32_t baseaddr_lower, baseaddr_upper;
2489 baseaddr = (((
target_addr_t)baseaddr_upper) << 32) | baseaddr_lower;
2561 uint32_t csw_val, csw_mask;
2574 if (strcmp(
CMD_ARGV[0],
"default") == 0)
2580 LOG_ERROR(
"CSW value cannot include 'Size' and 'AddrInc' bit-fields");
2594 LOG_ERROR(
"CSW mask cannot include 'Size' and 'AddrInc' bit-fields");
2660 uint32_t
reg, value;
2663 if (CMD_ARGC < 2 || CMD_ARGC > 3)
2674 if (
reg >= 4096 || (
reg & 3)) {
2675 command_print(
CMD,
"Invalid reg value (should be less than 4096 and 4 bytes aligned)");
2679 if (
reg >= 256 || (
reg & 3)) {
2680 command_print(
CMD,
"Invalid reg value (should be less than 256 and 4 bytes aligned)");
2741 uint32_t
reg, value;
2744 if (CMD_ARGC < 1 || CMD_ARGC > 2)
2748 if (
reg >= 256 || (
reg & 3)) {
2749 command_print(
CMD,
"Invalid reg value (should be less than 256 and 4 bytes aligned)");
2775 "TI BE-32 quirks mode");
2782 "Nuvoton NPCX quirks mode");
2788 .handler = handle_dap_info_command,
2790 .help =
"display ROM table for specified MEM-AP (default currently selected AP) "
2791 "or the ADIv6 root ROM table",
2792 .usage =
"[ap_num | 'root']",
2796 .handler = dap_apsel_command,
2798 .help =
"Set the currently selected AP (default 0) "
2799 "and display the result",
2800 .usage =
"[ap_num]",
2804 .handler = dap_apcsw_command,
2806 .help =
"Set CSW default bits",
2807 .usage =
"[value [mask]]",
2812 .handler = dap_apid_command,
2814 .help =
"return ID register from AP "
2815 "(default currently selected AP)",
2816 .usage =
"[ap_num]",
2820 .handler = dap_apreg_command,
2822 .help =
"read/write a register from AP "
2823 "(reg is byte address of a word register, like 0 4 8...)",
2824 .usage =
"ap_num reg [value]",
2828 .handler = dap_dpreg_command,
2830 .help =
"read/write a register from DP "
2831 "(reg is byte address (bank << 4 | reg) of a word register, like 0 4 8...)",
2832 .usage =
"reg [value]",
2836 .handler = dap_baseaddr_command,
2838 .help =
"return debug base address from MEM-AP "
2839 "(default currently selected AP)",
2840 .usage =
"[ap_num]",
2843 .name =
"memaccess",
2844 .handler = dap_memaccess_command,
2846 .help =
"set/get number of extra tck for MEM-AP memory "
2847 "bus access [0-255]",
2848 .usage =
"[cycles]",
2851 .name =
"ti_be_32_quirks",
2852 .handler = dap_ti_be_32_quirks_command,
2854 .help =
"set/get quirks mode for TI TMS450/TMS570 processors",
2855 .usage =
"[enable]",
2858 .name =
"nu_npcx_quirks",
2859 .handler = dap_nu_npcx_quirks_command,
2861 .help =
"set/get quirks mode for Nuvoton NPCX controllers",
2862 .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 const struct @58 ap_types[]
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 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_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 @57 class0x9_devarch[]
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 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)
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.
#define MEM_AP_REG_CSW(dap)
#define CSW_ADDRINC_PACKED
static int dap_queue_ap_write(struct adiv5_ap *ap, unsigned reg, uint32_t data)
Queue an AP register write.
static bool is_64bit_ap(struct adiv5_ap *ap)
#define AP_REG_IDR_CLASS_SHIFT
#define MEM_AP_REG_CFG(dap)
static int dap_queue_dp_write(struct adiv5_dap *dap, unsigned reg, uint32_t data)
Queue a DP register write.
#define MEM_AP_REG_TAR(dap)
#define MEM_AP_REG_CFG_LD
static int dap_queue_dp_read(struct adiv5_dap *dap, unsigned reg, uint32_t *data)
Queue a DP register read.
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
#define CSW_ADDRINC_SINGLE
#define AP_REG_IDR_CLASS_MEM_AP
static int dap_dp_read_atomic(struct adiv5_dap *dap, unsigned reg, uint32_t *value)
#define MEM_AP_REG_CFG_BE
#define DP_BASEPTR0_VALID
struct adiv5_dap * adiv5_get_dap(struct arm_dap_object *obj)
#define DP_SELECT_INVALID
#define MEM_AP_REG_CFG_LA
#define MEM_AP_REG_DRW(dap)
#define MEM_AP_REG_BASE(dap)
static int dap_queue_ap_read(struct adiv5_ap *ap, unsigned reg, uint32_t *data)
Queue an AP register read.
#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_dp_poll_register(struct adiv5_dap *dap, unsigned reg, uint32_t mask, uint32_t value, int timeout)
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 ...)
size_t size
Size of the control block search area.
This represents an ARM Debug Interface (v5) Access Port (AP).
bool unaligned_access_bad
bool config_ap_never_release
uint32_t tar_autoincr_block
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).
struct adiv5_ap ap[DP_APSEL_MAX+1]
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 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_UNALIGNED_ACCESS
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.