aboutsummaryrefslogtreecommitdiff
path: root/src/target/arm_adi_v5.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2021-08-09 15:31:10 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2022-06-24 21:38:08 +0000
commit8c1d518232c3105e5599099f41038212250f3798 (patch)
treef0282c8ec963d4684e9b54b4c6754106c407bb89 /src/target/arm_adi_v5.c
parent3f4bc6ce7f5c5a619590c3cc05a74d6bff6a124f (diff)
downloadriscv-openocd-8c1d518232c3105e5599099f41038212250f3798.zip
riscv-openocd-8c1d518232c3105e5599099f41038212250f3798.tar.gz
riscv-openocd-8c1d518232c3105e5599099f41038212250f3798.tar.bz2
arm_adi_v5: add option 'root' to 'dap info' command
On ADIv6 the system root ROM table is found by reading the DAP DP registers BASEPTR0 and BASEPTR1. Add option 'root' to the commands 'dap info' to let it retrieve the system root ROM table's AP from DAP DP, then use such AP for following dump. Change-Id: I1789457a005faa3870c5d14f763378d2f6a5f095 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6462 Tested-by: jenkins
Diffstat (limited to 'src/target/arm_adi_v5.c')
-rw-r--r--src/target/arm_adi_v5.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 79f9b8d..d33dcf8 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -1154,6 +1154,32 @@ static int dap_get_debugbase(struct adiv5_ap *ap,
return ERROR_OK;
}
+int adiv6_dap_read_baseptr(struct command_invocation *cmd, struct adiv5_dap *dap, uint64_t *baseptr)
+{
+ uint32_t baseptr_lower, baseptr_upper = 0;
+ int retval;
+
+ if (dap->asize > 32) {
+ retval = dap_queue_dp_read(dap, DP_BASEPTR1, &baseptr_upper);
+ if (retval != ERROR_OK)
+ return retval;
+ }
+
+ retval = dap_dp_read_atomic(dap, DP_BASEPTR0, &baseptr_lower);
+ if (retval != ERROR_OK)
+ return retval;
+
+ if ((baseptr_lower & DP_BASEPTR0_VALID) != DP_BASEPTR0_VALID) {
+ command_print(cmd, "System root table not present");
+ return ERROR_FAIL;
+ }
+
+ baseptr_lower &= ~0x0fff;
+ *baseptr = (((uint64_t)baseptr_upper) << 32) | baseptr_lower;
+
+ return ERROR_OK;
+}
+
/** Holds registers and coordinates of a CoreSight component */
struct cs_component_vals {
struct adiv5_ap *ap;
@@ -2225,6 +2251,18 @@ COMMAND_HANDLER(handle_dap_info_command)
apsel = dap->apsel;
break;
case 1:
+ if (!strcmp(CMD_ARGV[0], "root")) {
+ if (!is_adiv6(dap)) {
+ command_print(CMD, "Option \"root\" not allowed with ADIv5 DAP");
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ int retval = adiv6_dap_read_baseptr(CMD, dap, &apsel);
+ if (retval != ERROR_OK) {
+ command_print(CMD, "Failed reading DAP baseptr");
+ return retval;
+ }
+ break;
+ }
COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], apsel);
if (!is_ap_num_valid(dap, apsel)) {
command_print(CMD, "Invalid AP number");
@@ -2595,9 +2633,9 @@ const struct command_registration dap_instance_commands[] = {
.name = "info",
.handler = handle_dap_info_command,
.mode = COMMAND_EXEC,
- .help = "display ROM table for MEM-AP "
- "(default currently selected AP)",
- .usage = "[ap_num]",
+ .help = "display ROM table for specified MEM-AP (default currently selected AP) "
+ "or the ADIv6 root ROM table",
+ .usage = "[ap_num | 'root']",
},
{
.name = "apsel",