From 138b69dae3cee29c5b7374ab88771afa40ec1367 Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Mon, 4 May 2009 09:49:37 +0000 Subject: [PATCH] Sanitize src/cmd a bit: have a src/cmd/cmd.h with extern declarations, move some apparently local functions from include/urjtag/cmd.h to src/cmd/cmd.h git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1556 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/include/urjtag/cmd.h | 14 +---- urjtag/src/apps/jtag/jtag.c | 23 +------- urjtag/src/cmd/cmd.h | 98 ++++++++++++++++++++++++++++++++ urjtag/src/cmd/cmd_addpart.c | 4 +- urjtag/src/cmd/cmd_bit.c | 4 +- urjtag/src/cmd/cmd_bsdl.c | 4 +- urjtag/src/cmd/cmd_bus.c | 4 +- urjtag/src/cmd/cmd_cable.c | 4 +- urjtag/src/cmd/cmd_cmd.c | 66 +++++++-------------- urjtag/src/cmd/cmd_debug.c | 4 +- urjtag/src/cmd/cmd_detect.c | 4 +- urjtag/src/cmd/cmd_detectflash.c | 4 +- urjtag/src/cmd/cmd_discovery.c | 4 +- urjtag/src/cmd/cmd_dr.c | 4 +- urjtag/src/cmd/cmd_endian.c | 4 +- urjtag/src/cmd/cmd_eraseflash.c | 4 +- urjtag/src/cmd/cmd_flashmem.c | 4 +- urjtag/src/cmd/cmd_frequency.c | 4 +- urjtag/src/cmd/cmd_get.c | 4 +- urjtag/src/cmd/cmd_help.c | 4 +- urjtag/src/cmd/cmd_idcode.c | 4 +- urjtag/src/cmd/cmd_include.c | 6 +- urjtag/src/cmd/cmd_initbus.c | 4 +- urjtag/src/cmd/cmd_instruction.c | 4 +- urjtag/src/cmd/cmd_part.c | 4 +- urjtag/src/cmd/cmd_peekpoke.c | 6 +- urjtag/src/cmd/cmd_pod.c | 4 +- urjtag/src/cmd/cmd_print.c | 4 +- urjtag/src/cmd/cmd_quit.c | 4 +- urjtag/src/cmd/cmd_readmem.c | 4 +- urjtag/src/cmd/cmd_register.c | 4 +- urjtag/src/cmd/cmd_reset.c | 4 +- urjtag/src/cmd/cmd_salias.c | 2 + urjtag/src/cmd/cmd_scan.c | 4 +- urjtag/src/cmd/cmd_set.c | 4 +- urjtag/src/cmd/cmd_shell.c | 4 +- urjtag/src/cmd/cmd_shift.c | 4 +- urjtag/src/cmd/cmd_signal.c | 4 +- urjtag/src/cmd/cmd_svf.c | 4 +- urjtag/src/cmd/cmd_test.c | 4 +- urjtag/src/cmd/cmd_usleep.c | 4 +- urjtag/src/cmd/cmd_writemem.c | 4 +- 42 files changed, 239 insertions(+), 116 deletions(-) create mode 100644 urjtag/src/cmd/cmd.h diff --git a/urjtag/include/urjtag/cmd.h b/urjtag/include/urjtag/cmd.h index 39733d23..b7826d1b 100644 --- a/urjtag/include/urjtag/cmd.h +++ b/urjtag/include/urjtag/cmd.h @@ -36,19 +36,11 @@ #include "types.h" -typedef struct -{ - char *name; - char *desc; - void (*help) (void); - int (*run) (urj_chain_t *chain, char *params[]); -} urj_cmd_t; - -extern const urj_cmd_t *urj_cmds[]; - int urj_cmd_run (urj_chain_t *chain, char *params[]); +char *urj_cmd_find_next (const char *text, int state); +/* @@@@ RFHH candidate to become local in src/cmd/: */ int urj_cmd_params (char *params[]); +/* @@@@ RFHH candidate to become local in src/cmd/: */ int urj_cmd_get_number (const char *s, unsigned int *i); -int urj_cmd_test_cable (urj_chain_t *chain); #endif /* URJ_CMD_H */ diff --git a/urjtag/src/apps/jtag/jtag.c b/urjtag/src/apps/jtag/jtag.c index 382c658f..b249b71d 100644 --- a/urjtag/src/apps/jtag/jtag.c +++ b/urjtag/src/apps/jtag/jtag.c @@ -92,27 +92,6 @@ jtag_create_jtagdir (void) #ifdef HAVE_LIBREADLINE -static char * -cmd_find_next (const char *text, int state) -{ - static size_t cmd_idx, len; - - if (!state) - { - cmd_idx = 0; - len = strlen (text); - } - - while (urj_cmds[cmd_idx]) - { - char *name = urj_cmds[cmd_idx++]->name; - if (!strncmp (name, text, len)) - return strdup (name); - } - - return NULL; -} - #ifdef HAVE_READLINE_COMPLETION static char ** urj_cmd_completion (const char *text, int start, int end) @@ -120,7 +99,7 @@ urj_cmd_completion (const char *text, int start, int end) char **ret = NULL; if (start == 0) - ret = rl_completion_matches (text, cmd_find_next); + ret = rl_completion_matches (text, urj_cmd_find_next); return ret; } diff --git a/urjtag/src/cmd/cmd.h b/urjtag/src/cmd/cmd.h new file mode 100644 index 00000000..a6968a99 --- /dev/null +++ b/urjtag/src/cmd/cmd.h @@ -0,0 +1,98 @@ +/* + * $Id$ + * + * Copyright (C) 2003 ETC s.r.o. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the ETC s.r.o. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Written by Marcel Telka , 2003. + * + */ + +#ifndef URJ_SRC_CMD_H +#define URJ_SRC_CMD_H + +#include + +#include + +typedef struct +{ + char *name; + char *desc; + void (*help) (void); + int (*run) (urj_chain_t *chain, char *params[]); +} urj_cmd_t; + +extern const urj_cmd_t urj_cmd_quit; +extern const urj_cmd_t urj_cmd_help; +extern const urj_cmd_t urj_cmd_frequency; +extern const urj_cmd_t urj_cmd_cable; +extern const urj_cmd_t urj_cmd_reset; +extern const urj_cmd_t urj_cmd_discovery; +extern const urj_cmd_t urj_cmd_idcode; +extern const urj_cmd_t urj_cmd_detect; +extern const urj_cmd_t urj_cmd_signal; +extern const urj_cmd_t urj_cmd_scan; +extern const urj_cmd_t urj_cmd_salias; +extern const urj_cmd_t urj_cmd_bit; +extern const urj_cmd_t urj_cmd_register; +extern const urj_cmd_t urj_cmd_initbus; +extern const urj_cmd_t urj_cmd_print; +extern const urj_cmd_t urj_cmd_part; +extern const urj_cmd_t urj_cmd_bus; +extern const urj_cmd_t urj_cmd_instruction; +extern const urj_cmd_t urj_cmd_shift; +extern const urj_cmd_t urj_cmd_dr; +extern const urj_cmd_t urj_cmd_get; +extern const urj_cmd_t urj_cmd_test; +extern const urj_cmd_t urj_cmd_shell; +extern const urj_cmd_t urj_cmd_set; +extern const urj_cmd_t urj_cmd_endian; +extern const urj_cmd_t urj_cmd_peek; +extern const urj_cmd_t urj_cmd_poke; +extern const urj_cmd_t urj_cmd_pod; +extern const urj_cmd_t urj_cmd_readmem; +extern const urj_cmd_t urj_cmd_writemem; +extern const urj_cmd_t urj_cmd_detectflash; +extern const urj_cmd_t urj_cmd_flashmem; +extern const urj_cmd_t urj_cmd_eraseflash; +extern const urj_cmd_t urj_cmd_script; +extern const urj_cmd_t urj_cmd_include; +extern const urj_cmd_t urj_cmd_addpart; +extern const urj_cmd_t urj_cmd_usleep; +#ifdef ENABLE_SVF +extern const urj_cmd_t urj_cmd_svf; +#endif +#ifdef ENABLE_BSDL +extern const urj_cmd_t urj_cmd_bsdl; +#endif +extern const urj_cmd_t urj_cmd_debug; + +extern const urj_cmd_t *urj_cmds[]; + +int urj_cmd_test_cable (urj_chain_t *chain); + +#endif /* URJ_CMD_H */ diff --git a/urjtag/src/cmd/cmd_addpart.c b/urjtag/src/cmd/cmd_addpart.c index 9b5d587d..6f0af9c2 100644 --- a/urjtag/src/cmd/cmd_addpart.c +++ b/urjtag/src/cmd/cmd_addpart.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_addpart_run (urj_chain_t *chain, char *params[]) { @@ -73,7 +75,7 @@ cmd_addpart_help (void) } -urj_cmd_t urj_cmd_addpart = { +const urj_cmd_t urj_cmd_addpart = { "addpart", N_("manually adds parts on the JTAG chain"), cmd_addpart_help, diff --git a/urjtag/src/cmd/cmd_bit.c b/urjtag/src/cmd/cmd_bit.c index ffe068df..ad6b4632 100644 --- a/urjtag/src/cmd/cmd_bit.c +++ b/urjtag/src/cmd/cmd_bit.c @@ -32,6 +32,8 @@ #include +#include "cmd.h" + static void cmd_bit_print_params (char *params[], unsigned int parameters, char *command, size_t command_size) @@ -187,7 +189,7 @@ cmd_bit_help (void) "CSTATE Control state, valid state is only Z\n"), "bit"); } -urj_cmd_t urj_cmd_bit = { +const urj_cmd_t urj_cmd_bit = { "bit", N_("define new BSR bit"), cmd_bit_help, diff --git a/urjtag/src/cmd/cmd_bsdl.c b/urjtag/src/cmd/cmd_bsdl.c index cf1f6e98..ccac8f38 100644 --- a/urjtag/src/cmd/cmd_bsdl.c +++ b/urjtag/src/cmd/cmd_bsdl.c @@ -32,6 +32,8 @@ #include #include +#include "cmd.h" + static int cmd_bsdl_run (urj_chain_t *chain, char *params[]) { @@ -118,7 +120,7 @@ cmd_bsdl_help (void) "bsdl", "bsdl", "bsdl", "bsdl"); } -urj_cmd_t urj_cmd_bsdl = { +const urj_cmd_t urj_cmd_bsdl = { "bsdl", N_("manage BSDL files"), cmd_bsdl_help, diff --git a/urjtag/src/cmd/cmd_bus.c b/urjtag/src/cmd/cmd_bus.c index 4c538b55..b41bfade 100644 --- a/urjtag/src/cmd/cmd_bus.c +++ b/urjtag/src/cmd/cmd_bus.c @@ -32,6 +32,8 @@ #include +#include "cmd.h" + static int cmd_bus_run (urj_chain_t *chain, char *params[]) { @@ -71,7 +73,7 @@ cmd_bus_help (void) "\n" "BUS bus number\n"), "bus"); } -urj_cmd_t urj_cmd_bus = { +const urj_cmd_t urj_cmd_bus = { "bus", N_("change active bus"), cmd_bus_help, diff --git a/urjtag/src/cmd/cmd_cable.c b/urjtag/src/cmd/cmd_cable.c index b914df44..cd8e84ba 100644 --- a/urjtag/src/cmd/cmd_cable.c +++ b/urjtag/src/cmd/cmd_cable.c @@ -36,6 +36,8 @@ #include +#include "cmd.h" + static int cmd_cable_run (urj_chain_t *chain, char *params[]) { @@ -146,7 +148,7 @@ cmd_cable_help (void) _(urj_tap_cable_drivers[i]->description)); } -urj_cmd_t urj_cmd_cable = { +const urj_cmd_t urj_cmd_cable = { "cable", N_("select JTAG cable"), cmd_cable_help, diff --git a/urjtag/src/cmd/cmd_cmd.c b/urjtag/src/cmd/cmd_cmd.c index 4824e501..0b8e676a 100644 --- a/urjtag/src/cmd/cmd_cmd.c +++ b/urjtag/src/cmd/cmd_cmd.c @@ -31,50 +31,7 @@ #include -extern urj_cmd_t urj_cmd_quit; -extern urj_cmd_t urj_cmd_help; -extern urj_cmd_t urj_cmd_frequency; -extern urj_cmd_t urj_cmd_cable; -extern urj_cmd_t urj_cmd_reset; -extern urj_cmd_t urj_cmd_discovery; -extern urj_cmd_t urj_cmd_idcode; -extern urj_cmd_t urj_cmd_detect; -extern urj_cmd_t urj_cmd_signal; -extern urj_cmd_t urj_cmd_scan; -extern const urj_cmd_t urj_cmd_salias; -extern urj_cmd_t urj_cmd_bit; -extern urj_cmd_t urj_cmd_register; -extern const urj_cmd_t urj_cmd_initbus; -extern urj_cmd_t urj_cmd_print; -extern urj_cmd_t urj_cmd_part; -extern urj_cmd_t urj_cmd_bus; -extern urj_cmd_t urj_cmd_instruction; -extern urj_cmd_t urj_cmd_shift; -extern urj_cmd_t urj_cmd_dr; -extern urj_cmd_t urj_cmd_get; -extern urj_cmd_t urj_cmd_test; -extern urj_cmd_t urj_cmd_shell; -extern urj_cmd_t urj_cmd_set; -extern urj_cmd_t urj_cmd_endian; -extern urj_cmd_t urj_cmd_peek; -extern urj_cmd_t urj_cmd_poke; -extern urj_cmd_t urj_cmd_pod; -extern urj_cmd_t urj_cmd_readmem; -extern urj_cmd_t urj_cmd_writemem; -extern urj_cmd_t urj_cmd_detectflash; -extern urj_cmd_t urj_cmd_flashmem; -extern urj_cmd_t urj_cmd_eraseflash; -extern urj_cmd_t urj_cmd_script; -extern urj_cmd_t urj_cmd_include; -extern urj_cmd_t urj_cmd_addpart; -extern urj_cmd_t urj_cmd_usleep; -#ifdef ENABLE_SVF -extern urj_cmd_t urj_cmd_svf; -#endif -#ifdef ENABLE_BSDL -extern urj_cmd_t urj_cmd_bsdl; -#endif -extern urj_cmd_t urj_cmd_debug; +#include "cmd.h" const urj_cmd_t *urj_cmds[] = { &urj_cmd_quit, @@ -124,6 +81,27 @@ const urj_cmd_t *urj_cmds[] = { NULL /* last must be NULL */ }; +char * +urj_cmd_find_next (const char *text, int state) +{ + static size_t cmd_idx, len; + + if (!state) + { + cmd_idx = 0; + len = strlen (text); + } + + while (urj_cmds[cmd_idx]) + { + char *name = urj_cmds[cmd_idx++]->name; + if (!strncmp (name, text, len)) + return strdup (name); + } + + return NULL; +} + int urj_cmd_test_cable (urj_chain_t *chain) { diff --git a/urjtag/src/cmd/cmd_debug.c b/urjtag/src/cmd/cmd_debug.c index e275d61d..0a0c4509 100644 --- a/urjtag/src/cmd/cmd_debug.c +++ b/urjtag/src/cmd/cmd_debug.c @@ -32,6 +32,8 @@ #include +#include "cmd.h" + static int cmd_debug_run (urj_chain_t *chain, char *params[]) { @@ -55,7 +57,7 @@ cmd_debug_help (void) "\n" "n =1 fileio, 2=tap commands, 4 =?\n"), "debug n"); } -urj_cmd_t urj_cmd_debug = { +const urj_cmd_t urj_cmd_debug = { "debug", N_("debug jtag program"), cmd_debug_help, diff --git a/urjtag/src/cmd/cmd_detect.c b/urjtag/src/cmd/cmd_detect.c index b655a833..06f6c088 100644 --- a/urjtag/src/cmd/cmd_detect.c +++ b/urjtag/src/cmd/cmd_detect.c @@ -35,6 +35,8 @@ #include +#include "cmd.h" + static int cmd_detect_run (urj_chain_t *chain, char *params[]) { @@ -90,7 +92,7 @@ cmd_detect_help (void) "detect"); } -urj_cmd_t urj_cmd_detect = { +const urj_cmd_t urj_cmd_detect = { "detect", N_("detect parts on the JTAG chain"), cmd_detect_help, diff --git a/urjtag/src/cmd/cmd_detectflash.c b/urjtag/src/cmd/cmd_detectflash.c index 30eaf3d3..03a0fa14 100644 --- a/urjtag/src/cmd/cmd_detectflash.c +++ b/urjtag/src/cmd/cmd_detectflash.c @@ -30,6 +30,8 @@ #include #include +#include "cmd.h" + static int cmd_detectflash_run (urj_chain_t *chain, char *params[]) { @@ -62,7 +64,7 @@ cmd_detectflash_help (void) "detectflash"); } -urj_cmd_t urj_cmd_detectflash = { +const urj_cmd_t urj_cmd_detectflash = { "detectflash", N_("detect parameters of flash chips attached to a part"), cmd_detectflash_help, diff --git a/urjtag/src/cmd/cmd_discovery.c b/urjtag/src/cmd/cmd_discovery.c index d8b2b8b8..b3599995 100644 --- a/urjtag/src/cmd/cmd_discovery.c +++ b/urjtag/src/cmd/cmd_discovery.c @@ -30,6 +30,8 @@ #include +#include "cmd.h" + static int cmd_discovery_run (urj_chain_t *chain, char *params[]) { @@ -60,7 +62,7 @@ cmd_discovery_help (void) "discovery"); } -urj_cmd_t urj_cmd_discovery = { +const urj_cmd_t urj_cmd_discovery = { "discovery", N_("discovery of unknown parts in the JTAG chain"), cmd_discovery_help, diff --git a/urjtag/src/cmd/cmd_dr.c b/urjtag/src/cmd/cmd_dr.c index a0872b59..3f714db2 100644 --- a/urjtag/src/cmd/cmd_dr.c +++ b/urjtag/src/cmd/cmd_dr.c @@ -35,6 +35,8 @@ #include +#include "cmd.h" + static int cmd_dr_run (urj_chain_t *chain, char *params[]) { @@ -118,7 +120,7 @@ cmd_dr_help (void) "dr", "dr"); } -urj_cmd_t urj_cmd_dr = { +const urj_cmd_t urj_cmd_dr = { "dr", N_("display active data register for a part"), cmd_dr_help, diff --git a/urjtag/src/cmd/cmd_endian.c b/urjtag/src/cmd/cmd_endian.c index 73e9e4ce..3c15040f 100644 --- a/urjtag/src/cmd/cmd_endian.c +++ b/urjtag/src/cmd/cmd_endian.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_endian_run (urj_chain_t *chain, char *params[]) { @@ -68,7 +70,7 @@ cmd_endian_help (void) "endian [little|big]"); } -urj_cmd_t urj_cmd_endian = { +const urj_cmd_t urj_cmd_endian = { "endian", N_("set/print endianess"), cmd_endian_help, diff --git a/urjtag/src/cmd/cmd_eraseflash.c b/urjtag/src/cmd/cmd_eraseflash.c index b11485f8..1025271f 100644 --- a/urjtag/src/cmd/cmd_eraseflash.c +++ b/urjtag/src/cmd/cmd_eraseflash.c @@ -33,6 +33,8 @@ #include +#include "cmd.h" + static int cmd_eraseflash_run (urj_chain_t *chain, char *params[]) { @@ -76,7 +78,7 @@ cmd_eraseflash_help (void) _(urj_flash_flash_drivers[i]->description)); } -urj_cmd_t urj_cmd_eraseflash = { +const urj_cmd_t urj_cmd_eraseflash = { "eraseflash", N_("erase flash memory by number of blocks"), cmd_eraseflash_help, diff --git a/urjtag/src/cmd/cmd_flashmem.c b/urjtag/src/cmd/cmd_flashmem.c index 19c14e9b..628d5c09 100644 --- a/urjtag/src/cmd/cmd_flashmem.c +++ b/urjtag/src/cmd/cmd_flashmem.c @@ -33,6 +33,8 @@ #include +#include "cmd.h" + static int cmd_flashmem_run (urj_chain_t *chain, char *params[]) { @@ -99,7 +101,7 @@ cmd_flashmem_help (void) _(urj_flash_flash_drivers[i]->description)); } -urj_cmd_t urj_cmd_flashmem = { +const urj_cmd_t urj_cmd_flashmem = { "flashmem", N_("burn flash memory with data from a file"), cmd_flashmem_help, diff --git a/urjtag/src/cmd/cmd_frequency.c b/urjtag/src/cmd/cmd_frequency.c index e3aac126..2b87cf5e 100644 --- a/urjtag/src/cmd/cmd_frequency.c +++ b/urjtag/src/cmd/cmd_frequency.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_frequency_run (urj_chain_t *chain, char *params[]) { @@ -73,7 +75,7 @@ cmd_frequency_help (void) "Use 0 for FREQ to disable frequency limit.\n"), "frequency"); } -urj_cmd_t urj_cmd_frequency = { +const urj_cmd_t urj_cmd_frequency = { "frequency", N_("setup JTAG frequency"), cmd_frequency_help, diff --git a/urjtag/src/cmd/cmd_get.c b/urjtag/src/cmd/cmd_get.c index 05fd232f..d7cc300e 100644 --- a/urjtag/src/cmd/cmd_get.c +++ b/urjtag/src/cmd/cmd_get.c @@ -33,6 +33,8 @@ #include +#include "cmd.h" + static int cmd_get_run (urj_chain_t *chain, char *params[]) { @@ -76,7 +78,7 @@ cmd_get_help (void) "get signal"); } -urj_cmd_t urj_cmd_get = { +const urj_cmd_t urj_cmd_get = { "get", N_("get external signal value"), cmd_get_help, diff --git a/urjtag/src/cmd/cmd_help.c b/urjtag/src/cmd/cmd_help.c index 6e6fa033..69ea44e3 100644 --- a/urjtag/src/cmd/cmd_help.c +++ b/urjtag/src/cmd/cmd_help.c @@ -29,6 +29,8 @@ #include +#include "cmd.h" + static int cmd_help_run (urj_chain_t *chain, char *params[]) { @@ -72,7 +74,7 @@ cmd_help_help (void) "help"); } -urj_cmd_t urj_cmd_help = { +const urj_cmd_t urj_cmd_help = { "help", N_("display this help"), cmd_help_help, diff --git a/urjtag/src/cmd/cmd_idcode.c b/urjtag/src/cmd/cmd_idcode.c index 51686a8d..129ada3d 100644 --- a/urjtag/src/cmd/cmd_idcode.c +++ b/urjtag/src/cmd/cmd_idcode.c @@ -29,6 +29,8 @@ #include +#include "cmd.h" + static int cmd_idcode_run (urj_chain_t *chain, char *params[]) { @@ -63,7 +65,7 @@ cmd_idcode_help (void) "idcode"); } -urj_cmd_t urj_cmd_idcode = { +const urj_cmd_t urj_cmd_idcode = { "idcode", N_("Read IDCODEs of all parts in a JTAG chain"), cmd_idcode_help, diff --git a/urjtag/src/cmd/cmd_include.c b/urjtag/src/cmd/cmd_include.c index 9e65391f..b59a3582 100644 --- a/urjtag/src/cmd/cmd_include.c +++ b/urjtag/src/cmd/cmd_include.c @@ -35,6 +35,8 @@ #include #include +#include "cmd.h" + static int cmd_include_or_script_run (urj_chain_t *chain, int is_include, char *params[]) { @@ -133,7 +135,7 @@ cmd_include_help (void) cmd_include_or_script_help ("include"); } -urj_cmd_t urj_cmd_include = { +const urj_cmd_t urj_cmd_include = { "include", N_("include command sequence from external repository"), cmd_include_help, @@ -152,7 +154,7 @@ cmd_script_help (void) cmd_include_or_script_help ("script"); } -urj_cmd_t urj_cmd_script = { +const urj_cmd_t urj_cmd_script = { "script", N_("run command sequence from external file"), cmd_script_help, diff --git a/urjtag/src/cmd/cmd_initbus.c b/urjtag/src/cmd/cmd_initbus.c index df7d0b8b..6c072c92 100644 --- a/urjtag/src/cmd/cmd_initbus.c +++ b/urjtag/src/cmd/cmd_initbus.c @@ -33,6 +33,8 @@ #include #include +#include "cmd.h" + static int cmd_initbus_run (urj_chain_t *chain, char *params[]) { @@ -95,7 +97,7 @@ cmd_initbus_help (void) urj_bus_drivers[i]->description); } -const urj_cmd_t urj_cmd_initbus = { +const const urj_cmd_t urj_cmd_initbus = { "initbus", N_("initialize bus driver for active part"), cmd_initbus_help, diff --git a/urjtag/src/cmd/cmd_instruction.c b/urjtag/src/cmd/cmd_instruction.c index b30f220d..3155006d 100644 --- a/urjtag/src/cmd/cmd_instruction.c +++ b/urjtag/src/cmd/cmd_instruction.c @@ -32,6 +32,8 @@ #include +#include "cmd.h" + static int cmd_instruction_run (urj_chain_t *chain, char *params[]) { @@ -97,7 +99,7 @@ cmd_instruction_help (void) "instruction", "instruction", "instruction"); } -urj_cmd_t urj_cmd_instruction = { +const urj_cmd_t urj_cmd_instruction = { "instruction", N_("change active instruction for a part or declare new instruction"), cmd_instruction_help, diff --git a/urjtag/src/cmd/cmd_part.c b/urjtag/src/cmd/cmd_part.c index 847adc40..8f968ef2 100644 --- a/urjtag/src/cmd/cmd_part.c +++ b/urjtag/src/cmd/cmd_part.c @@ -33,6 +33,8 @@ #include +#include "cmd.h" + static int cmd_part_run (urj_chain_t *chain, char *params[]) { @@ -115,7 +117,7 @@ cmd_part_help (void) "\n" "bus->part part number | alias\n"), "part"); } -urj_cmd_t urj_cmd_part = { +const urj_cmd_t urj_cmd_part = { "part", N_("change active part for current JTAG chain"), cmd_part_help, diff --git a/urjtag/src/cmd/cmd_peekpoke.c b/urjtag/src/cmd/cmd_peekpoke.c index 4e4d3cc0..c8c34c7e 100644 --- a/urjtag/src/cmd/cmd_peekpoke.c +++ b/urjtag/src/cmd/cmd_peekpoke.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_peek_run (urj_chain_t *chain, char *params[]) { @@ -88,7 +90,7 @@ cmd_peek_help (void) "\n"), "peek"); } -urj_cmd_t urj_cmd_peek = { +const urj_cmd_t urj_cmd_peek = { "peek", N_("read a single word"), cmd_peek_help, @@ -141,7 +143,7 @@ cmd_poke_help (void) "\n"), "poke"); } -urj_cmd_t urj_cmd_poke = { +const urj_cmd_t urj_cmd_poke = { "poke", N_("write a single word"), cmd_poke_help, diff --git a/urjtag/src/cmd/cmd_pod.c b/urjtag/src/cmd/cmd_pod.c index 2828c4d7..68140d15 100644 --- a/urjtag/src/cmd/cmd_pod.c +++ b/urjtag/src/cmd/cmd_pod.c @@ -35,6 +35,8 @@ #include +#include "cmd.h" + static int cmd_pod_run (urj_chain_t *chain, char *params[]) { @@ -87,7 +89,7 @@ cmd_pod_help (void) "# 0 or 1\n"), "pod"); } -urj_cmd_t urj_cmd_pod = { +const urj_cmd_t urj_cmd_pod = { "pod", N_("Set state of POD signal(s)"), cmd_pod_help, diff --git a/urjtag/src/cmd/cmd_print.c b/urjtag/src/cmd/cmd_print.c index 50fd8890..8563cdd9 100644 --- a/urjtag/src/cmd/cmd_print.c +++ b/urjtag/src/cmd/cmd_print.c @@ -49,6 +49,8 @@ typedef char wchar_t; #include +#include "cmd.h" + static int cmd_print_run (urj_chain_t *chain, char *params[]) { @@ -258,7 +260,7 @@ cmd_print_help (void) "print"); } -urj_cmd_t urj_cmd_print = { +const urj_cmd_t urj_cmd_print = { "print", N_("display JTAG chain list/status"), cmd_print_help, diff --git a/urjtag/src/cmd/cmd_quit.c b/urjtag/src/cmd/cmd_quit.c index e6ea2bd7..dc7ab24a 100644 --- a/urjtag/src/cmd/cmd_quit.c +++ b/urjtag/src/cmd/cmd_quit.c @@ -28,6 +28,8 @@ #include +#include "cmd.h" + static int cmd_quit_run (urj_chain_t *chain, char *params[]) { @@ -43,7 +45,7 @@ cmd_quit_help (void) printf (_("Usage: %s\n" "Exit from %s.\n"), "quit", PACKAGE); } -urj_cmd_t urj_cmd_quit = { +const urj_cmd_t urj_cmd_quit = { "quit", N_("exit and terminate this session"), cmd_quit_help, diff --git a/urjtag/src/cmd/cmd_readmem.c b/urjtag/src/cmd/cmd_readmem.c index 66c2778e..b92dda31 100644 --- a/urjtag/src/cmd/cmd_readmem.c +++ b/urjtag/src/cmd/cmd_readmem.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_readmem_run (urj_chain_t *chain, char *params[]) { @@ -77,7 +79,7 @@ cmd_readmem_help (void) "readmem"); } -urj_cmd_t urj_cmd_readmem = { +const urj_cmd_t urj_cmd_readmem = { "readmem", N_("read content of the memory and write it to file"), cmd_readmem_help, diff --git a/urjtag/src/cmd/cmd_register.c b/urjtag/src/cmd/cmd_register.c index eba95909..fb502c98 100644 --- a/urjtag/src/cmd/cmd_register.c +++ b/urjtag/src/cmd/cmd_register.c @@ -35,6 +35,8 @@ #include +#include "cmd.h" + static int cmd_register_run (urj_chain_t *chain, char *params[]) { @@ -105,7 +107,7 @@ cmd_register_help (void) "LENGTH Data register length\n"), "register"); } -urj_cmd_t urj_cmd_register = { +const urj_cmd_t urj_cmd_register = { "register", N_("define new data register for a part"), cmd_register_help, diff --git a/urjtag/src/cmd/cmd_reset.c b/urjtag/src/cmd/cmd_reset.c index 517d6818..0fb6cc8d 100644 --- a/urjtag/src/cmd/cmd_reset.c +++ b/urjtag/src/cmd/cmd_reset.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_reset_run (urj_chain_t *chain, char *params[]) { @@ -51,7 +53,7 @@ cmd_reset_help (void) printf (_("Usage: %s\n" "Reset current JTAG chain.\n"), "reset"); } -urj_cmd_t urj_cmd_reset = { +const urj_cmd_t urj_cmd_reset = { "reset", N_("reset JTAG chain"), cmd_reset_help, diff --git a/urjtag/src/cmd/cmd_salias.c b/urjtag/src/cmd/cmd_salias.c index b92870e7..f0554291 100644 --- a/urjtag/src/cmd/cmd_salias.c +++ b/urjtag/src/cmd/cmd_salias.c @@ -34,6 +34,8 @@ #include "urjtag/cmd.h" +#include "cmd.h" + static int cmd_salias_run (urj_chain_t *chain, char *params[]) { diff --git a/urjtag/src/cmd/cmd_scan.c b/urjtag/src/cmd/cmd_scan.c index 5665ec7b..346aec57 100644 --- a/urjtag/src/cmd/cmd_scan.c +++ b/urjtag/src/cmd/cmd_scan.c @@ -37,6 +37,8 @@ #include +#include "cmd.h" + static int cmd_scan_run (urj_chain_t *chain, char *params[]) { @@ -129,7 +131,7 @@ cmd_scan_help (void) "Read BSR and show changes since last scan.\n"), "scan"); } -urj_cmd_t urj_cmd_scan = { +const urj_cmd_t urj_cmd_scan = { "scan", N_("read BSR and show changes since last scan"), cmd_scan_help, diff --git a/urjtag/src/cmd/cmd_set.c b/urjtag/src/cmd/cmd_set.c index f257e6f4..e4336ba3 100644 --- a/urjtag/src/cmd/cmd_set.c +++ b/urjtag/src/cmd/cmd_set.c @@ -33,6 +33,8 @@ #include +#include "cmd.h" + static int cmd_set_run (urj_chain_t *chain, char *params[]) { @@ -92,7 +94,7 @@ cmd_set_help (void) " is 'out'\n"), "set signal"); } -urj_cmd_t urj_cmd_set = { +const urj_cmd_t urj_cmd_set = { "set", N_("set external signal value"), cmd_set_help, diff --git a/urjtag/src/cmd/cmd_shell.c b/urjtag/src/cmd/cmd_shell.c index 49456e64..9ebb721c 100644 --- a/urjtag/src/cmd/cmd_shell.c +++ b/urjtag/src/cmd/cmd_shell.c @@ -33,6 +33,8 @@ #include +#include "cmd.h" + static int cmd_shell_run (urj_chain_t *chain, char *params[]) { @@ -83,7 +85,7 @@ cmd_shell_help (void) "\n" "CMMD OS Shell Command\n"), "shell cmmd"); } -urj_cmd_t urj_cmd_shell = { +const urj_cmd_t urj_cmd_shell = { "shell", N_("shell cmmd"), cmd_shell_help, diff --git a/urjtag/src/cmd/cmd_shift.c b/urjtag/src/cmd/cmd_shift.c index 359c09e8..6f0dcffa 100644 --- a/urjtag/src/cmd/cmd_shift.c +++ b/urjtag/src/cmd/cmd_shift.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_shift_run (urj_chain_t *chain, char *params[]) { @@ -63,7 +65,7 @@ cmd_shift_help (void) "shift ir", "shift dr"); } -urj_cmd_t urj_cmd_shift = { +const urj_cmd_t urj_cmd_shift = { "shift", N_("shift data/instruction registers through JTAG chain"), cmd_shift_help, diff --git a/urjtag/src/cmd/cmd_signal.c b/urjtag/src/cmd/cmd_signal.c index c7cf5901..9563efbc 100644 --- a/urjtag/src/cmd/cmd_signal.c +++ b/urjtag/src/cmd/cmd_signal.c @@ -34,6 +34,8 @@ #include +#include "cmd.h" + static int cmd_signal_run (urj_chain_t *chain, char *params[]) { @@ -91,7 +93,7 @@ cmd_signal_help (void) "PIN# List of pin # for a signal\n"), "signal"); } -urj_cmd_t urj_cmd_signal = { +const urj_cmd_t urj_cmd_signal = { "signal", N_("define new signal for a part"), cmd_signal_help, diff --git a/urjtag/src/cmd/cmd_svf.c b/urjtag/src/cmd/cmd_svf.c index 25cc6fd0..1104ad50 100644 --- a/urjtag/src/cmd/cmd_svf.c +++ b/urjtag/src/cmd/cmd_svf.c @@ -33,6 +33,8 @@ #include #include +#include "cmd.h" + static int cmd_svf_run (urj_chain_t *chain, char *params[]) { @@ -87,7 +89,7 @@ cmd_svf_help (void) "\n" "FILE file containing SVF commands\n"), "svf"); } -urj_cmd_t urj_cmd_svf = { +const urj_cmd_t urj_cmd_svf = { "svf", N_("execute svf commands from file"), cmd_svf_help, diff --git a/urjtag/src/cmd/cmd_test.c b/urjtag/src/cmd/cmd_test.c index fc6ada4c..53b95912 100644 --- a/urjtag/src/cmd/cmd_test.c +++ b/urjtag/src/cmd/cmd_test.c @@ -35,6 +35,8 @@ #include +#include "cmd.h" + static int cmd_test_run (urj_chain_t *chain, char *params[]) { @@ -91,7 +93,7 @@ cmd_test_help (void) "get signal"); } -urj_cmd_t urj_cmd_test = { +const urj_cmd_t urj_cmd_test = { "test", N_("test external signal value"), cmd_test_help, diff --git a/urjtag/src/cmd/cmd_usleep.c b/urjtag/src/cmd/cmd_usleep.c index ee069867..1a5be2c7 100644 --- a/urjtag/src/cmd/cmd_usleep.c +++ b/urjtag/src/cmd/cmd_usleep.c @@ -31,6 +31,8 @@ #include +#include "cmd.h" + static int cmd_usleep_run (urj_chain_t *chain, char *params[]) { @@ -54,7 +56,7 @@ cmd_usleep_help (void) "Sleep some number of microseconds.\n"), "usleep"); } -urj_cmd_t urj_cmd_usleep = { +const urj_cmd_t urj_cmd_usleep = { "usleep", N_("Sleep some number of microseconds"), cmd_usleep_help, diff --git a/urjtag/src/cmd/cmd_writemem.c b/urjtag/src/cmd/cmd_writemem.c index f8955513..5c6920e7 100644 --- a/urjtag/src/cmd/cmd_writemem.c +++ b/urjtag/src/cmd/cmd_writemem.c @@ -29,6 +29,8 @@ #include +#include "cmd.h" + static int cmd_writemem_run (urj_chain_t *chain, char *params[]) { @@ -76,7 +78,7 @@ cmd_writemem_help (void) "writemem"); } -urj_cmd_t urj_cmd_writemem = { +const urj_cmd_t urj_cmd_writemem = { "writemem", N_("write content of file to the memory"), cmd_writemem_help,