# documented nor supported except on ZY1000.
proc power_restore {} {
- puts "Sensed power restore."
+ puts "Sensed power restore, running reset init and halting GDB."
reset init
+
+ # Halt GDB so user can deal with a detected power restore.
+ #
+ # After GDB is halted, then output is no longer forwarded
+ # to the GDB console.
+ set targets [target names]
+ foreach t $targets {
+ # New event script.
+ $t invoke-event arp_halt_gdb
+ }
}
add_help_text power_restore "Overridable procedure run when power restore is detected. Runs 'reset init' by default."
# documented nor supported except on ZY1000.
proc srst_deasserted {} {
- puts "Sensed nSRST deasserted."
+ puts "Sensed nSRST deasserted, running reset init and halting GDB."
reset init
+
+ # Halt GDB so user can deal with a detected reset.
+ #
+ # After GDB is halted, then output is no longer forwarded
+ # to the GDB console.
+ set targets [target names]
+ foreach t $targets {
+ # New event script.
+ $t invoke-event arp_halt_gdb
+ }
}
+
add_help_text srst_deasserted "Overridable procedure run when srst deassert is detected. Runs 'reset init' by default."
proc srst_asserted {} {
return ERROR_OK;
}
-static void target_call_event_callbacks_all(enum target_event e) {
- struct target *target;
- target = all_targets;
- while (target) {
- target_call_event_callbacks(target, e);
- target = target->next;
- }
-}
-
/* process target state changes */
static int handle_target(void *priv)
{
int did_something = 0;
if (runSrstAsserted)
{
- LOG_INFO("Waking up GDB, srst asserted detected.");
- target_call_event_callbacks_all(TARGET_EVENT_GDB_HALT);
+ LOG_INFO("srst asserted detected, running srst_asserted proc.");
Jim_Eval(interp, "srst_asserted");
did_something = 1;
}
}
if (runPowerDropout)
{
- LOG_INFO("Waking up GDB, power dropout detected.");
- target_call_event_callbacks_all(TARGET_EVENT_GDB_HALT);
+ LOG_INFO("Power dropout detected, running power_dropout proc.");
Jim_Eval(interp, "power_dropout");
did_something = 1;
}
return JIM_OK;
}
+static int jim_target_halt_gdb(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+{
+ if (argc != 1)
+ {
+ Jim_WrongNumArgs(interp, 1, argv, "[no parameters]");
+ return JIM_ERR;
+ }
+ struct target *target = Jim_CmdPrivData(interp);
+
+ if (target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT) != ERROR_OK)
+ return JIM_ERR;
+
+ return JIM_OK;
+}
+
static int jim_target_poll(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 1)
.jim_handler = jim_target_examine,
.help = "used internally for reset processing",
},
+ {
+ .name = "arp_halt_gdb",
+ .mode = COMMAND_EXEC,
+ .jim_handler = jim_target_halt_gdb,
+ .help = "used internally for reset processing to halt GDB",
+ },
{
.name = "arp_poll",
.mode = COMMAND_EXEC,