This is an automated email from Gerrit. Antonio Borneo ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/6113
-- gerrit commit a02ea72bb59f8c719c399dccd3c3b497d402ceec Author: Antonio Borneo <[email protected]> Date: Thu Mar 18 18:17:02 2021 +0100 target: add event 'shutdown' OpenOCD does not modify anything on the target when it shutdowns. If the target was halted or running, it will keep the same. Any configuration for target clock, cpu debug enable, power management and so on will be left in the current state. This is not always ideal, but any action at OpenOCD shutdown is strongly related to the use case, and cannot be standardized. Add a new target event 'shutdown' that would be called before OpenOCD quits. It can contain any action that the user considers relevant before OpenOCD quits. Change-Id: Ibc3804f232817a454835e151c2a5b62b3f7b52fc Signed-off-by: Antonio Borneo <[email protected]> diff --git a/doc/openocd.texi b/doc/openocd.texi index 0c1714e..99d4f8a 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -5053,6 +5053,8 @@ when reset disables PLLs needed to use a fast clock. @* After single-step has completed @item @b{trace-config} @* After target hardware trace configuration was changed +@item @b{shutdown} +@* Before OpenOCD exit. @end itemize @quotation Note diff --git a/src/target/target.c b/src/target/target.c index eb83dae..3210e6c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -234,6 +234,8 @@ static const Jim_Nvp nvp_target_event[] = { { .value = TARGET_EVENT_TRACE_CONFIG, .name = "trace-config" }, + { .value = TARGET_EVENT_SHUTDOWN, .name = "shutdown" }, + { .name = NULL, .value = -1 } }; @@ -2264,6 +2266,10 @@ static void target_destroy(struct target *target) void target_quit(void) { + for (struct target *target = all_targets; target; target = target->next) + if (target_was_examined(target)) + target_call_event_callbacks(target, TARGET_EVENT_SHUTDOWN); + struct target_event_callback *pe = target_event_callbacks; while (pe) { struct target_event_callback *t = pe->next; diff --git a/src/target/target.h b/src/target/target.h index b9ae2f7..f8cc2a7 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -292,6 +292,8 @@ enum target_event { TARGET_EVENT_GDB_FLASH_WRITE_END, TARGET_EVENT_TRACE_CONFIG, + + TARGET_EVENT_SHUTDOWN, }; struct target_event_action { -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
