Skip to content

Commit f885a8d

Browse files
Adrien Grasseinborneoa
authored andcommitted
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 <[email protected]> Signed-off-by: Adrien Charruel <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/8654 Tested-by: jenkins Reviewed-by: Antonio Borneo <[email protected]>
1 parent a9fa339 commit f885a8d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/target/aarch64.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,6 +2857,14 @@ static void aarch64_deinit_target(struct target *target)
28572857
struct aarch64_common *aarch64 = target_to_aarch64(target);
28582858
struct armv8_common *armv8 = &aarch64->armv8_common;
28592859
struct arm_dpm *dpm = &armv8->dpm;
2860+
uint64_t address;
2861+
2862+
if (target->state == TARGET_HALTED) {
2863+
// Restore the previous state of the target (gp registers, MMU, caches, etc)
2864+
int retval = aarch64_restore_one(target, true, &address, false, false);
2865+
if (retval != ERROR_OK)
2866+
LOG_TARGET_ERROR(target, "Failed to restore target state");
2867+
}
28602868

28612869
if (armv8->debug_ap)
28622870
dap_put_ap(armv8->debug_ap);

0 commit comments

Comments
 (0)