From: Øyvind H. <go...@us...> - 2009-12-01 09:56:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 445da543d8db868466dcef7e23f75b3c2b54bc72 (commit) via 5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa (commit) from 63dc352876259562948b5d814de197ba534897b9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 445da543d8db868466dcef7e23f75b3c2b54bc72 Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Dec 1 08:42:53 2009 +0100 zy1000: keep up with latest changes to command handling Keep up with Jim Tcl interpreter creation cleanup. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/ecosboard.c b/src/ecosboard.c index 5588934..36e807e 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -80,6 +80,7 @@ #include <unistd.h> #include <stdio.h> +#include <openocd.h> #ifdef CYGPKG_HAL_NIOS2 #define ZY1000_SER_DEV "/dev/uart_0" @@ -505,8 +506,6 @@ static void zylinjtag_startNetwork(void) cyg_httpd_init_tcl_interpreter(); - interp = httpstate.jim_interp; - Jim_CreateCommand(httpstate.jim_interp, "log", zylinjtag_Jim_Command_log, NULL, NULL); Jim_CreateCommand(httpstate.jim_interp, "zy1000_reboot", @@ -933,8 +932,6 @@ bool logAllToSerial = false; int boolParam(char *var); -struct command_context *setup_command_handler(void); - static const char *zylin_config_dir="/config/settings"; static int add_default_dirs(void) @@ -1078,7 +1075,8 @@ int main(int argc, char *argv[]) /* initialize commandline interface */ struct command_context * cmd_ctx; - cmd_ctx = setup_command_handler(); + struct command_context *setup_command_handler(Jim_Interp *interp); + cmd_ctx = setup_command_handler(httpstate.jim_interp); command_set_output_handler(cmd_ctx, configuration_output_handler, NULL); command_context_mode(cmd_ctx, COMMAND_CONFIG); @@ -1095,7 +1093,7 @@ int main(int argc, char *argv[]) COMMAND_ANY, NULL); #endif - Jim_CreateCommand(interp, "uart", zylinjtag_Jim_Command_uart, NULL, NULL); + Jim_CreateCommand(httpstate.jim_interp, "uart", zylinjtag_Jim_Command_uart, NULL, NULL); log_init(); diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 115b3be..07d840f 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2008 by Ãyvind Harboe * + * Copyright (C) 2007-2009 by Ãyvind Harboe * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * commit 5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Dec 1 08:41:41 2009 +0100 command: the Jim interpreter can now be provided rather than created In embedded hosts, the Jim interpreter can come from the existing context rather than be created by OpenOCD. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/helper/command.c b/src/helper/command.c index dcad6a1..d657668 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -1272,7 +1272,7 @@ static const struct command_registration command_builtin_handlers[] = { COMMAND_REGISTRATION_DONE }; -struct command_context* command_init(const char *startup_tcl) +struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp) { struct command_context* context = malloc(sizeof(struct command_context)); const char *HostOs; @@ -1284,14 +1284,18 @@ struct command_context* command_init(const char *startup_tcl) context->output_handler_priv = NULL; #if !BUILD_ECOSBOARD - Jim_InitEmbedded(); - /* Create an interpreter */ - context->interp = Jim_CreateInterp(); - /* Add all the Jim core commands */ - Jim_RegisterCoreCommands(context->interp); + /* Create a jim interpreter if we were not handed one */ + if (interp == NULL) + { + Jim_InitEmbedded(); + /* Create an interpreter */ + interp = Jim_CreateInterp(); + /* Add all the Jim core commands */ + Jim_RegisterCoreCommands(interp); + } #endif + context->interp = interp; - Jim_Interp *interp = context->interp; #if defined(_MSC_VER) /* WinXX - is generic, the forward * looking problem is this: diff --git a/src/helper/command.h b/src/helper/command.h index 611db87..8d68c18 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -323,9 +323,11 @@ void command_set_output_handler(struct command_context* context, int command_context_mode(struct command_context *context, enum command_mode mode); /** - * Creates a new command context using the startup TCL provided. + * Creates a new command context using the startup TCL provided and + * the existing Jim interpreter, if any. If interp == NULL, then command_init + * creates a command interpreter. */ -struct command_context* command_init(const char *startup_tcl); +struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp); /** * Creates a copy of an existing command context. This does not create * a deep copy of the command list, so modifications in one context will diff --git a/src/openocd.c b/src/openocd.c index 22d4582..44e0292 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -188,14 +188,14 @@ static const struct command_registration openocd_command_handlers[] = { struct command_context *global_cmd_ctx; /* NB! this fn can be invoked outside this file for non PC hosted builds */ -struct command_context *setup_command_handler(void) +struct command_context *setup_command_handler(Jim_Interp *interp) { log_init(); LOG_DEBUG("log_init: complete"); struct command_context *cmd_ctx; - global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl); + global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl, interp); register_commands(cmd_ctx, NULL, openocd_command_handlers); /* register subsystem commands */ @@ -242,7 +242,7 @@ int openocd_main(int argc, char *argv[]) /* initialize commandline interface */ struct command_context *cmd_ctx; - cmd_ctx = setup_command_handler(); + cmd_ctx = setup_command_handler(NULL); #if BUILD_IOUTIL if (ioutil_init(cmd_ctx) != ERROR_OK) ----------------------------------------------------------------------- Summary of changes: src/ecosboard.c | 10 ++++------ src/helper/command.c | 18 +++++++++++------- src/helper/command.h | 6 ++++-- src/jtag/zy1000/zy1000.c | 2 +- src/openocd.c | 6 +++--- 5 files changed, 23 insertions(+), 19 deletions(-) hooks/post-receive -- Main OpenOCD repository |