aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrien Grassein <agrassein@nanoxplore.com>2024-01-18 11:54:15 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2025-03-29 18:27:19 +0000
commitf885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac (patch)
tree352fa95134aeac410a7aa2cbcfc99150df4ae2da /src
parenta9fa3392670659dfd558d8733911ffce9538e2d2 (diff)
downloadriscv-openocd-f885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac.zip
riscv-openocd-f885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac.tar.gz
riscv-openocd-f885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac.tar.bz2
target/aarch64: Cleanup on exit
Restore target configuration on exit so that OpenOCD get correct values when restarting. Change-Id: I8cbba1fdae1d3c4a580197b7a97691443780ed06 Signed-off-by: Adrien Grassein <agrassein@nanoxplore.com> Signed-off-by: Adrien Charruel <acharruel@nanoxplore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8654 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/aarch64.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 609965b..ce7808e 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -2857,6 +2857,14 @@ static void aarch64_deinit_target(struct target *target)
struct aarch64_common *aarch64 = target_to_aarch64(target);
struct armv8_common *armv8 = &aarch64->armv8_common;
struct arm_dpm *dpm = &armv8->dpm;
+ uint64_t address;
+
+ if (target->state == TARGET_HALTED) {
+ // Restore the previous state of the target (gp registers, MMU, caches, etc)
+ int retval = aarch64_restore_one(target, true, &address, false, false);
+ if (retval != ERROR_OK)
+ LOG_TARGET_ERROR(target, "Failed to restore target state");
+ }
if (armv8->debug_ap)
dap_put_ap(armv8->debug_ap);