gdb: restore behavior from 0.3.1 for srst_asserted and power_restore
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 31 Jan 2010 20:02:06 +0000 (21:02 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 1 Feb 2010 12:45:09 +0000 (13:45 +0100)
srst_asserted and power_restore can now be overriden to do
nothing. By default they will "reset init" the targets and
halt gdb.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/jtag/startup.tcl
src/target/target.c

index ab215babd44dea2210d80f7f7d887fab4e82aca2..4e6d5fc181a15b9dc067cd793140c5bb3f933bcc 100644 (file)
@@ -30,8 +30,18 @@ proc init_reset { mode } {
 # 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."
@@ -46,9 +56,20 @@ proc power_dropout {} {
 # 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 {} {
index 1eb65a62e0f40f3938062a03b2957e0be955f4da..2522408382e31e695c7af9f76da6278cb950ceac 100644 (file)
@@ -1739,15 +1739,6 @@ static int sense_handler(void)
        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)
 {
@@ -1767,8 +1758,7 @@ 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;
                }
@@ -1779,8 +1769,7 @@ static int handle_target(void *priv)
                }
                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;
                }
@@ -4065,6 +4054,21 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv
        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)
@@ -4345,6 +4349,12 @@ static const struct command_registration target_instance_command_handlers[] = {
                .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,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)