aboutsummaryrefslogtreecommitdiff
path: root/src/target/aarch64.c
diff options
context:
space:
mode:
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>2017-04-06 09:49:37 +0200
committerMatthias Welwarsky <matthias@welwarsky.de>2018-01-16 09:06:02 +0000
commit685cdf86ea841caf01da70167b61f7b0b9db4435 (patch)
treec9553a73491541da157d21b080a6f67d81a5aa52 /src/target/aarch64.c
parent1482c26a4e656eaa35712895024a56303f4ba7ea (diff)
downloadriscv-openocd-685cdf86ea841caf01da70167b61f7b0b9db4435.zip
riscv-openocd-685cdf86ea841caf01da70167b61f7b0b9db4435.tar.gz
riscv-openocd-685cdf86ea841caf01da70167b61f7b0b9db4435.tar.bz2
aarch64: speed up first examination
Don't use atomic dap operations when not necessary. Also remove loop trying to set core power request, didn't find a platform where it actually worked and it's slowing examination down. Change-Id: I44e5c2f289f951b8f4579f08a841172404a52053 Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com> Reviewed-on: http://openocd.zylin.com/4143 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Diffstat (limited to 'src/target/aarch64.c')
-rw-r--r--src/target/aarch64.c60
1 files changed, 20 insertions, 40 deletions
diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index f1ce914..784274a 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -180,7 +180,7 @@ static int aarch64_init_debug_access(struct target *target)
int retval;
uint32_t dummy;
- LOG_DEBUG(" ");
+ LOG_DEBUG("%s", target_name(target));
retval = mem_ap_write_atomic_u32(armv8->debug_ap,
armv8->debug_base + CPUV8_DBG_OSLAR, 0);
@@ -2173,7 +2173,7 @@ static int aarch64_examine_first(struct target *target)
int retval = ERROR_OK;
uint64_t debug, ttypr;
uint32_t cpuid;
- uint32_t tmp0, tmp1;
+ uint32_t tmp0, tmp1, tmp2, tmp3;
debug = ttypr = cpuid = 0;
retval = dap_dp_init(swjdp);
@@ -2213,32 +2213,6 @@ static int aarch64_examine_first(struct target *target)
} else
armv8->debug_base = target->dbgbase;
- uint32_t prsr;
- int64_t then = timeval_ms();
- do {
- retval = mem_ap_read_atomic_u32(armv8->debug_ap,
- armv8->debug_base + CPUV8_DBG_PRSR, &prsr);
- if (retval == ERROR_OK) {
- retval = mem_ap_write_atomic_u32(armv8->debug_ap,
- armv8->debug_base + CPUV8_DBG_PRCR, PRCR_COREPURQ|PRCR_CORENPDRQ);
- if (retval != ERROR_OK) {
- LOG_DEBUG("write to PRCR failed");
- break;
- }
- }
-
- if (timeval_ms() > then + 1000) {
- retval = ERROR_TARGET_TIMEOUT;
- break;
- }
-
- } while ((prsr & PRSR_PU) == 0);
-
- if (retval != ERROR_OK) {
- LOG_ERROR("target %s: failed to set power state of the core.", target_name(target));
- return retval;
- }
-
retval = mem_ap_write_atomic_u32(armv8->debug_ap,
armv8->debug_base + CPUV8_DBG_OSLAR, 0);
if (retval != ERROR_OK) {
@@ -2246,34 +2220,40 @@ static int aarch64_examine_first(struct target *target)
return retval;
}
- retval = mem_ap_read_atomic_u32(armv8->debug_ap,
+ retval = mem_ap_read_u32(armv8->debug_ap,
armv8->debug_base + CPUV8_DBG_MAINID0, &cpuid);
if (retval != ERROR_OK) {
LOG_DEBUG("Examine %s failed", "CPUID");
return retval;
}
- retval = mem_ap_read_atomic_u32(armv8->debug_ap,
+ retval = mem_ap_read_u32(armv8->debug_ap,
armv8->debug_base + CPUV8_DBG_MEMFEATURE0, &tmp0);
- retval += mem_ap_read_atomic_u32(armv8->debug_ap,
+ retval += mem_ap_read_u32(armv8->debug_ap,
armv8->debug_base + CPUV8_DBG_MEMFEATURE0 + 4, &tmp1);
if (retval != ERROR_OK) {
LOG_DEBUG("Examine %s failed", "Memory Model Type");
return retval;
}
- ttypr |= tmp1;
- ttypr = (ttypr << 32) | tmp0;
-
- retval = mem_ap_read_atomic_u32(armv8->debug_ap,
- armv8->debug_base + CPUV8_DBG_DBGFEATURE0, &tmp0);
- retval += mem_ap_read_atomic_u32(armv8->debug_ap,
- armv8->debug_base + CPUV8_DBG_DBGFEATURE0 + 4, &tmp1);
+ retval = mem_ap_read_u32(armv8->debug_ap,
+ armv8->debug_base + CPUV8_DBG_DBGFEATURE0, &tmp2);
+ retval += mem_ap_read_u32(armv8->debug_ap,
+ armv8->debug_base + CPUV8_DBG_DBGFEATURE0 + 4, &tmp3);
if (retval != ERROR_OK) {
LOG_DEBUG("Examine %s failed", "ID_AA64DFR0_EL1");
return retval;
}
- debug |= tmp1;
- debug = (debug << 32) | tmp0;
+
+ retval = dap_run(armv8->debug_ap->dap);
+ if (retval != ERROR_OK) {
+ LOG_ERROR("%s: examination failed\n", target_name(target));
+ return retval;
+ }
+
+ ttypr |= tmp1;
+ ttypr = (ttypr << 32) | tmp0;
+ debug |= tmp3;
+ debug = (debug << 32) | tmp2;
LOG_DEBUG("cpuid = 0x%08" PRIx32, cpuid);
LOG_DEBUG("ttypr = 0x%08" PRIx64, ttypr);