summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-29 14:04:21 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-30 16:29:24 -0800
commitcee1f39f18296a3aa291b806052c7c3d5a066347 (patch)
tree02f14bd2f740b865c08a702d241290b0d5407756 /src
parent64653b0bbb0b2ac87de83d867f241360087b7588 (diff)
downloadopenocd+libswd-cee1f39f18296a3aa291b806052c7c3d5a066347.tar.gz
openocd+libswd-cee1f39f18296a3aa291b806052c7c3d5a066347.tar.bz2
openocd+libswd-cee1f39f18296a3aa291b806052c7c3d5a066347.tar.xz
openocd+libswd-cee1f39f18296a3aa291b806052c7c3d5a066347.zip
allow deferal of init
Adds 'noinit' command to prevent OpenOCD from running 'init' at the end up startup, allowing it to be given from telnet or TCL. This provides the old behavior by default, and users can add this command to their scripts to get the new behavior.
Diffstat (limited to 'src')
-rw-r--r--src/openocd.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/openocd.c b/src/openocd.c
index 287a819b..2a65b4d8 100644
--- a/src/openocd.c
+++ b/src/openocd.c
@@ -91,6 +91,16 @@ static int log_target_callback_event_handler(struct target *target, enum target_
int ioutil_init(struct command_context *cmd_ctx);
+static bool init_at_startup = true;
+
+COMMAND_HANDLER(handle_noinit_command)
+{
+ if (CMD_ARGC != 0)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ init_at_startup = false;
+ return ERROR_OK;
+}
+
/* OpenOCD can't really handle failure of this command. Patches welcome! :-) */
COMMAND_HANDLER(handle_init_command)
{
@@ -159,15 +169,24 @@ static const struct command_registration openocd_command_handlers[] = {
{
.name = "version",
.handler = &handle_version_command,
- .mode = COMMAND_EXEC,
+ .mode = COMMAND_ANY,
.help = "show program version",
},
{
+ .name = "noinit",
+ .handler = &handle_noinit_command,
+ .mode = COMMAND_CONFIG,
+ .help = "Prevent 'init' from being called at startup.",
+ },
+ {
.name = "init",
.handler = &handle_init_command,
- .mode = COMMAND_ANY,
+ .mode = COMMAND_CONFIG,
.help = "Initializes configured targets and servers. "
- "If called more than once, does nothing.",
+ "Changes command mode from CONFIG to EXEC. "
+ "Unless 'noinit' is called, this command is "
+ "called automatically at the end of startup.",
+
},
COMMAND_REGISTRATION_DONE
};
@@ -262,7 +281,7 @@ int openocd_main(int argc, char *argv[])
if (ERROR_OK != ret)
return EXIT_FAILURE;
- if (1)
+ if (init_at_startup)
{
ret = command_run_line(cmd_ctx, "init");
if (ERROR_OK != ret)