]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
target/aarch64: Cleanup on exit
authorAdrien Grassein <agrassein@nanoxplore.com>
Thu, 18 Jan 2024 10:54:15 +0000 (11:54 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 29 Mar 2025 18:27:19 +0000 (18:27 +0000)
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>
src/target/aarch64.c

index 609965ba55ff5fb7cc3928e537a67b48773c114c..ce7808e3ac5134691cdaebb19654660b0453e3d8 100644 (file)
@@ -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);