This is an automated email from Gerrit. Tomasz CEDRO ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1023
-- gerrit commit 9ff291072338a5574a08d7e9fbb9c52da312ba36 Author: Tomek CEDRO <[email protected]> Date: Tue Oct 30 20:29:47 2012 +0100 Implemented TCL interface to interface_signal infrastructure. Change-Id: I4a302ae49d27a455121efd1a05fc9ea58ffb0282 Signed-off-by: Tomek CEDRO <[email protected]> diff --git a/src/interface/interface_signal.c b/src/interface/interface_signal.c index 82b4d0e..1a2aec3 100644 --- a/src/interface/interface_signal.c +++ b/src/interface/interface_signal.c @@ -206,3 +206,107 @@ int oocd_interface_signal_del(char *name){ return ERROR_OK; } +/****************************************************************************** + * TCL INTERFACE TO INTERFACE_SIGNAL INFRASTRUCTURE AND OPERATIONS + ******************************************************************************/ + +/** Interface signals handling routine that can add, delete and list signals. + * Signal ADD requires signal name string and 32-bit mask, optionally a value. + * Values are read as HEX. Signal DEL requires only signal name to delete. + * Signal LIST will show marvelous table wits signal names, masks and values. + * Interfaces should be defined in configuration file by TCL interface. + * Parameters are checked before function execution. + */ +COMMAND_HANDLER(handle_oocd_interface_signal_command) +{ + LOG_DEBUG("entering function..."); + + if (!jtag_interface){ + command_print(CMD_CTX, "You must initialize interface first!"); + return ERROR_FAIL; + } + + if (CMD_ARGC<1 || CMD_ARGC>3){ + command_print(CMD_CTX, "Bad syntax!"); + return ERROR_COMMAND_SYNTAX_ERROR; + } + + int sigmask; + char signame[32]; + + if (!strncasecmp(CMD_ARGV[0], "add", 3)){ + if (CMD_ARGC<3){ + LOG_ERROR("Usage: interface_signal add signal_name signal_mask"); + return ERROR_FAIL; + } + if (!strncpy(signame, CMD_ARGV[1], 32)){ + LOG_ERROR("Unable to copy signal name from parameter list!"); + return ERROR_FAIL; + } + // We are going to add interface signal. + // Check the mask parameter. + if (!sscanf(CMD_ARGV[2], "%x", &sigmask)){ + LOG_ERROR("Bad signal mask parameter! Use HEX value."); + return ERROR_COMMAND_SYNTAX_ERROR; + } + // Now add the inetrface signal with specified parameters. + return oocd_interface_signal_add(signame, sigmask); + + } else if (!strncasecmp(CMD_ARGV[0], "del", 3)){ + if (CMD_ARGC<2){ + LOG_ERROR("Usage: interface_signal del signal_name"); + return ERROR_FAIL; + } + // We are going to delete specified signal. + return oocd_interface_signal_del((char *)CMD_ARGV[1]); + + } else if (!strncasecmp(CMD_ARGV[0], "list", 4)){ + //We are going to list available signals. + oocd_interface_signal_t *sig; + sig=jtag_interface->signal; + command_print(CMD_CTX, " Interface Signal Name | Mask | Value "); + command_print(CMD_CTX, "----------------------------------------------------------"); + while (sig) { + command_print(CMD_CTX, "%32s | 0x%08X | 0x%08X", sig->name, sig->mask, sig->value); + sig=sig->next; + } + // Also print warning if interface driver does not support bit-baning. + if (!jtag_interface->bitbang) command_print(CMD_CTX, "WARNING: This interface does not support bit-baning!"); + return ERROR_OK; + + } else if (!strncasecmp(CMD_ARGV[0], "find", 4)){ + if (CMD_ARGC<2){ + LOG_ERROR("Usage: interface_signal find signal_name"); + return ERROR_FAIL; + } + // Find the signal and print its details. + oocd_interface_signal_t *sig; + if ( (sig=oocd_interface_signal_find((char *)CMD_ARGV[1])) != NULL ){ + command_print(CMD_CTX, "%s: mask=0x%08X value=0x%08X", sig->name, sig->mask, sig->value); + return ERROR_OK; + } + // Or return information and error if not found. + command_print(CMD_CTX, "Signal not found!"); + return ERROR_FAIL; + } + // For unknown parameter print error and return error code. + command_print(CMD_CTX, "Unknown parameter!"); + return ERROR_COMMAND_SYNTAX_ERROR; +} + +static const struct command_registration oocd_interface_signal_commands[] = { + { + .name = "interface_signal", + .handler = handle_oocd_interface_signal_command, + .mode = COMMAND_ANY, + .help = "List, Find, Remove and Add interface signal mask", + .usage = "(add|del|find|list) signal_name [mask]", + }, + COMMAND_REGISTRATION_DONE +}; + +int oocd_interface_signal_register_commands(struct command_context *ctx) +{ + return register_commands(ctx, NULL, oocd_interface_signal_commands); +} + diff --git a/src/interface/interface_signal.h b/src/interface/interface_signal.h index 89e9934..c62a39c 100644 --- a/src/interface/interface_signal.h +++ b/src/interface/interface_signal.h @@ -46,4 +46,6 @@ int oocd_interface_signal_add(char *name, unsigned int mask); int oocd_interface_signal_del(char *name); oocd_interface_signal_t *oocd_interface_signal_find(char *name); +int oocd_interface_signal_register_commands(struct command_context *ctx); + #endif diff --git a/src/openocd.c b/src/openocd.c index 048ce85..6d18e61 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -32,6 +32,7 @@ #include <jtag/driver.h> #include <jtag/jtag.h> #include <transport/transport.h> +#include <interface/interface.h> #include <helper/ioutil.h> #include <helper/util.h> #include <helper/configuration.h> @@ -240,6 +241,7 @@ struct command_context *setup_command_handler(Jim_Interp *interp) &log_register_commands, &transport_register_commands, &interface_register_commands, + &oocd_interface_signal_register_commands, &target_register_commands, &flash_register_commands, &nand_register_commands, -- ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
