This is an automated email from Gerrit. Florian Fainelli (f.faine...@gmail.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/6359
-- gerrit commit 3ca2e9bb062a4e2d3e2c325caf8579c9b02a93b7 Author: Florian Fainelli <f.faine...@gmail.com> Date: Tue Jul 6 20:19:28 2021 -0700 arm_adi_v5: Support parsing nested ROM tables ADI v5.1 and v6.0 permit the definition of CoreSight components (class 9 ROM entries) with a device type value of 0 which is to be scanned as a nested ROM table. Class 9 (CoreSight) components can only have up to 512 ROM table entries and the present indicator is with the value 0b11. dap_rom_display() is refactored a bit such that we always end up with attempting to parse the ROM contents using the appropriate upper limit for class 1 and 9 ROM types. Change-Id: I4ba497b3807f1f11f06186eb6e61959ea3540c59 Signed-off-by: Florian Fainelli <f.faine...@gmail.com> diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index fee3ecc..f0412c4 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1216,6 +1216,8 @@ static const struct { static int dap_rom_display(struct command_invocation *cmd, struct adiv5_ap *ap, target_addr_t dbgbase, int depth) { + uint32_t entry_present_mask = 0; + uint16_t rom_num_entries = 0; int retval; uint64_t pid; uint32_t cid; @@ -1297,26 +1299,8 @@ static int dap_rom_display(struct command_invocation *cmd, 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 & 0x01) { - /* Recurse */ - retval = dap_rom_display(cmd, ap, base_addr + (romentry & 0xFFFFF000), 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; - } - } + rom_num_entries = 960; + entry_present_mask = 0x1; } else if (class == 9) { /* CoreSight component */ const char *major = "Reserved", *subtype = "Reserved"; @@ -1462,6 +1446,36 @@ static int dap_rom_display(struct command_invocation *cmd, (uint8_t)(devtype & 0xff), major, subtype); /* REVISIT also show 0xfc8 DevId */ + + /* Components with a DEVTYPE of 0 can be nested ROMs, fall + * through to parsing those. + */ + if (devtype != 0) + return ERROR_OK; + + rom_num_entries = 512; + entry_present_mask = 0x3; + } + + /* Read ROM table entries from base address until we get 0x00000000 or reach the reserved area */ + for (uint16_t entry_offset = 0; entry_offset < rom_num_entries; 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 & entry_present_mask) { + /* Recurse */ + retval = dap_rom_display(cmd, ap, base_addr + (romentry & 0xFFFFF000), 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; + } } return ERROR_OK; --