From 970893163c9ac987f57551d49f2ebfbd5fef3396 Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Fri, 24 Apr 2009 12:34:24 +0000 Subject: [PATCH] Rename a few globals that had escaped; rename register.h to tap_register.h, instruction.h to part_instruction.h PART I -- does not compile\! git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1528 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/README | 2 +- urjtag/include/Makefile.am | 4 +- urjtag/include/cmd.h | 1 - urjtag/include/data_register.h | 2 +- urjtag/include/flash.h | 2 + urjtag/include/instruction.h | 18 +++---- urjtag/include/jtag.h | 4 +- urjtag/include/part.h | 10 ++-- urjtag/include/tap.h | 2 +- urjtag/include/{register.h => tap_register.h} | 4 +- urjtag/src/bus/fjmem.c | 2 +- urjtag/src/bus/readmem.c | 2 +- urjtag/src/bus/writemem.c | 2 +- urjtag/src/cmd/cmd_cmd.c | 39 --------------- urjtag/src/cmd/cmd_debug.c | 2 +- urjtag/src/cmd/cmd_dr.c | 2 +- urjtag/src/cmd/cmd_endian.c | 6 +-- urjtag/src/cmd/cmd_instruction.c | 2 +- urjtag/src/cmd/cmd_parse.c | 4 +- urjtag/src/cmd/cmd_print.c | 2 +- urjtag/src/flash/flash.c | 5 +- urjtag/src/jtag.c | 50 ++++++++++++++++--- urjtag/src/part/instruction.c | 8 +-- urjtag/src/part/part.c | 6 +-- urjtag/src/svf/svf.h | 2 +- urjtag/src/tap/detect.c | 2 +- urjtag/src/tap/register.c | 2 +- urjtag/src/tap/tap.c | 2 +- 28 files changed, 93 insertions(+), 96 deletions(-) rename urjtag/include/{register.h => tap_register.h} (97%) diff --git a/urjtag/README b/urjtag/README index 7890d15e..26677cc7 100644 --- a/urjtag/README +++ b/urjtag/README @@ -1,6 +1,6 @@ $Id$ -The subdirectory urjtag/ or the UrJTAG package contains a branch that is used +The subdirectory urjtag/ of the UrJTAG package contains a branch that is used for the conversion of UrJTAG to a library plus a separate command shell. Changes and commits to this branch will be frequent, and will affect nearly every aspect of the source tree, like file names, file locations, code layout, diff --git a/urjtag/include/Makefile.am b/urjtag/include/Makefile.am index d9c72419..718e5bdb 100644 --- a/urjtag/include/Makefile.am +++ b/urjtag/include/Makefile.am @@ -39,10 +39,10 @@ noinst_HEADERS = \ flash/mic.h \ flash/intel.h \ gettext.h \ - instruction.h \ + part_instruction.h \ parport.h \ part.h \ - register.h \ + tap_register.h \ bssignal.h \ tap_state.h \ jtag.h \ diff --git a/urjtag/include/cmd.h b/urjtag/include/cmd.h index 820f0173..f709baaa 100644 --- a/urjtag/include/cmd.h +++ b/urjtag/include/cmd.h @@ -46,7 +46,6 @@ typedef struct extern const urj_cmd_t *urj_cmds[]; -char **urj_cmd_completion (const char *text, int start, int end); int urj_cmd_run (urj_chain_t *chain, char *params[]); int urj_cmd_params (char *params[]); int urj_cmd_get_number (char *s, unsigned int *i); diff --git a/urjtag/include/data_register.h b/urjtag/include/data_register.h index aeb18548..53c38af6 100644 --- a/urjtag/include/data_register.h +++ b/urjtag/include/data_register.h @@ -25,7 +25,7 @@ #ifndef URJ_DATA_REGISTER_H #define URJ_DATA_REGISTER_H -#include "register.h" +#include "tap_register.h" #define URJ_DATA_REGISTER_MAXLEN 32 diff --git a/urjtag/include/flash.h b/urjtag/include/flash.h index da0bdd15..addcb7e0 100644 --- a/urjtag/include/flash.h +++ b/urjtag/include/flash.h @@ -85,6 +85,8 @@ typedef struct #define URJ_FLASH_ERROR_BLOCK_LOCKED 3 #define URJ_FLASH_ERROR_UNKNOWN 99 +extern urj_flash_cfi_array_t *urj_flash_cfi_array; + void urj_flash_detectflash (urj_bus_t *bus, uint32_t adr); void urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int); diff --git a/urjtag/include/instruction.h b/urjtag/include/instruction.h index 1ed019b3..0f676cda 100644 --- a/urjtag/include/instruction.h +++ b/urjtag/include/instruction.h @@ -22,27 +22,27 @@ * */ -#ifndef URJ_INSTRUCTION_H -#define URJ_INSTRUCTION_H +#ifndef URJ_PART_INSTRUCTION_H +#define URJ_PART_INSTRUCTION_H -#include "register.h" +#include "tap_register.h" #include "data_register.h" #define URJ_INSTRUCTION_MAXLEN_INSTRUCTION 20 -typedef struct urj_instruction urj_instruction_t; +typedef struct urj_part_instruction urj_part_instruction_t; -struct urj_instruction +struct urj_part_instruction { char name[URJ_INSTRUCTION_MAXLEN_INSTRUCTION + 1]; urj_tap_register_t *value; urj_tap_register_t *out; urj_data_register_t *data_register; - urj_instruction_t *next; + urj_part_instruction_t *next; }; -urj_instruction_t *urj_part_instruction_alloc (const char *name, int len, - const char *val); -void urj_part_instruction_free (urj_instruction_t *i); +urj_part_instruction_t *urj_part_instruction_alloc (const char *name, int len, + const char *val); +void urj_part_instruction_free (urj_part_instruction_t *i); #endif /* URJ_INSTRUCTION_H */ diff --git a/urjtag/include/jtag.h b/urjtag/include/jtag.h index 78bc7b65..050119ae 100644 --- a/urjtag/include/jtag.h +++ b/urjtag/include/jtag.h @@ -40,8 +40,8 @@ extern urj_bus_t *urj_bus; -extern int big_endian; -extern int debug_mode; +extern int urj_big_endian; +extern int urj_debug_mode; const char *urj_cmd_jtag_get_data_dir (void); diff --git a/urjtag/include/part.h b/urjtag/include/part.h index af147ff0..5ce852f5 100644 --- a/urjtag/include/part.h +++ b/urjtag/include/part.h @@ -28,7 +28,7 @@ #include #include "bssignal.h" -#include "instruction.h" +#include "part_instruction.h" #include "data_register.h" #include "bsbit.h" @@ -48,8 +48,8 @@ struct urj_part urj_part_signal_t *signals; urj_part_salias_t *saliases; int instruction_length; - urj_instruction_t *instructions; - urj_instruction_t *active_instruction; + urj_part_instruction_t *instructions; + urj_part_instruction_t *active_instruction; urj_data_register_t *data_registers; int boundary_length; urj_bsbit_t **bsbits; @@ -58,8 +58,8 @@ struct urj_part urj_part_t *urj_part_alloc (const urj_tap_register_t *id); void urj_part_free (urj_part_t *p); urj_part_t *read_part (FILE * f, urj_tap_register_t *idr); -urj_instruction_t *urj_part_find_instruction (urj_part_t *p, - const char *iname); +urj_part_instruction_t *urj_part_find_instruction (urj_part_t *p, + const char *iname); urj_data_register_t *urj_part_find_data_register (urj_part_t *p, const char *drname); urj_part_signal_t *urj_part_find_signal (urj_part_t *p, diff --git a/urjtag/include/tap.h b/urjtag/include/tap.h index 6472d450..3c05ff72 100644 --- a/urjtag/include/tap.h +++ b/urjtag/include/tap.h @@ -25,7 +25,7 @@ #ifndef URJ_TAP_H #define URJ_TAP_H -#include "register.h" +#include "tap_register.h" #include "chain.h" void urj_tap_reset (urj_chain_t *chain); diff --git a/urjtag/include/register.h b/urjtag/include/tap_register.h similarity index 97% rename from urjtag/include/register.h rename to urjtag/include/tap_register.h index 218c4a9c..a53fe7e8 100644 --- a/urjtag/include/register.h +++ b/urjtag/include/tap_register.h @@ -22,8 +22,8 @@ * */ -#ifndef URJ_REGISTER_H -#define URJ_REGISTER_H +#ifndef URJ_TAP_REGISTER_H +#define URJ_TAP_REGISTER_H typedef struct urj_tap_register { diff --git a/urjtag/src/bus/fjmem.c b/urjtag/src/bus/fjmem.c index bfa1720f..13d0787b 100644 --- a/urjtag/src/bus/fjmem.c +++ b/urjtag/src/bus/fjmem.c @@ -85,7 +85,7 @@ fjmem_detect_reg_len (urj_chain_t *chain, urj_part_t *part, char *opcode, int len) { urj_data_register_t *dr; - urj_instruction_t *i; + urj_part_instruction_t *i; int l, fjmem_reg_len; char *tdo_bit; diff --git a/urjtag/src/bus/readmem.c b/urjtag/src/bus/readmem.c index b39c0f09..3c52b74b 100644 --- a/urjtag/src/bus/readmem.c +++ b/urjtag/src/bus/readmem.c @@ -101,7 +101,7 @@ urj_bus_readmem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len) data = URJ_BUS_READ_END (bus); for (j = step; j > 0; j--) - if (big_endian) + if (urj_big_endian) b[bc++] = (data >> ((j - 1) * 8)) & 0xFF; else { diff --git a/urjtag/src/bus/writemem.c b/urjtag/src/bus/writemem.c index b0ac3f4a..2ac3b6ac 100644 --- a/urjtag/src/bus/writemem.c +++ b/urjtag/src/bus/writemem.c @@ -116,7 +116,7 @@ urj_bus_writemem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len) data = 0; for (j = step; j > 0; j--) { - if (big_endian) + if (urj_big_endian) { data |= b[bidx++]; data <<= 8; diff --git a/urjtag/src/cmd/cmd_cmd.c b/urjtag/src/cmd/cmd_cmd.c index 76c3bce9..cfca4f15 100644 --- a/urjtag/src/cmd/cmd_cmd.c +++ b/urjtag/src/cmd/cmd_cmd.c @@ -26,9 +26,6 @@ #include #include -#ifdef HAVE_LIBREADLINE -#include -#endif #include "jtag.h" @@ -127,42 +124,6 @@ const urj_cmd_t *urj_cmds[] = { NULL /* last must be NULL */ }; -#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 -char ** -urj_cmd_completion (const char *text, int start, int end) -{ - char **ret = NULL; - - if (start == 0) - ret = rl_completion_matches (text, cmd_find_next); - - return ret; -} -#endif -#endif - 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 350341c8..5b656a0d 100644 --- a/urjtag/src/cmd/cmd_debug.c +++ b/urjtag/src/cmd/cmd_debug.c @@ -45,7 +45,7 @@ cmd_debug_run (urj_chain_t *chain, char *params[]) if (urj_cmd_get_number (params[1], &i)) return 1; - debug_mode = i; + urj_debug_mode = i; return 1; } diff --git a/urjtag/src/cmd/cmd_dr.c b/urjtag/src/cmd/cmd_dr.c index a232480f..a8608375 100644 --- a/urjtag/src/cmd/cmd_dr.c +++ b/urjtag/src/cmd/cmd_dr.c @@ -27,7 +27,7 @@ #include #include -#include "register.h" +#include "tap_register.h" #include "jtag.h" #include "cmd.h" diff --git a/urjtag/src/cmd/cmd_endian.c b/urjtag/src/cmd/cmd_endian.c index 0afc59d8..1bacd32f 100644 --- a/urjtag/src/cmd/cmd_endian.c +++ b/urjtag/src/cmd/cmd_endian.c @@ -39,7 +39,7 @@ cmd_endian_run (urj_chain_t *chain, char *params[]) if (!params[1]) { - if (big_endian) + if (urj_big_endian) printf (_("Endianess for external files: big\n")); else printf (_("Endianess for external files: little\n")); @@ -49,12 +49,12 @@ cmd_endian_run (urj_chain_t *chain, char *params[]) if (strcasecmp (params[1], "little") == 0) { - big_endian = 0; + urj_big_endian = 0; return 1; } if (strcasecmp (params[1], "big") == 0) { - big_endian = 1; + urj_big_endian = 1; return 1; } diff --git a/urjtag/src/cmd/cmd_instruction.c b/urjtag/src/cmd/cmd_instruction.c index 69d330f2..3a4328c9 100644 --- a/urjtag/src/cmd/cmd_instruction.c +++ b/urjtag/src/cmd/cmd_instruction.c @@ -85,7 +85,7 @@ cmd_instruction_run (urj_chain_t *chain, char *params[]) if (urj_cmd_params (params) == 4) { - urj_instruction_t *i; + urj_part_instruction_t *i; if (strlen (params[2]) != part->instruction_length) { diff --git a/urjtag/src/cmd/cmd_parse.c b/urjtag/src/cmd/cmd_parse.c index 2e315275..f723c23b 100644 --- a/urjtag/src/cmd/cmd_parse.c +++ b/urjtag/src/cmd/cmd_parse.c @@ -110,7 +110,7 @@ urj_cmd_jtag_parse_line (urj_chain_t *chain, char *line) a[tcnt] = NULL; r = urj_cmd_run (chain, a); - if (debug_mode & 1) + if (urj_debug_mode & 1) printf ("Return in urj_cmd_jtag_parse_line r=%d\n", r); free (a); free (sline); @@ -172,7 +172,7 @@ urj_cmd_jtag_parse_file (urj_chain_t *chain, const char *filename) go = urj_cmd_jtag_parse_stream (chain, f); fclose (f); - if (debug_mode & 1) + if (urj_debug_mode & 1) printf ("File Closed gp=%d\n", go); return go; } diff --git a/urjtag/src/cmd/cmd_print.c b/urjtag/src/cmd/cmd_print.c index a2c0c8c2..9d40dfe1 100644 --- a/urjtag/src/cmd/cmd_print.c +++ b/urjtag/src/cmd/cmd_print.c @@ -104,7 +104,7 @@ cmd_print_run (urj_chain_t *chain, char *params[]) if (strcasecmp (params[1], "instructions") == 0) { urj_part_t *part; - urj_instruction_t *inst; + urj_part_instruction_t *inst; snprintf (format, 128, _(" Active %%-%ds %%-%ds"), URJ_INSTRUCTION_MAXLEN_INSTRUCTION, diff --git a/urjtag/src/flash/flash.c b/urjtag/src/flash/flash.c index f3a005b5..09296969 100644 --- a/urjtag/src/flash/flash.c +++ b/urjtag/src/flash/flash.c @@ -65,7 +65,6 @@ urj_flash_driver_t *urj_flash_flash_drivers[] = { NULL }; -extern urj_flash_cfi_array_t *urj_flash_cfi_array; static urj_flash_driver_t *flash_driver = NULL; static void @@ -363,7 +362,7 @@ urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int noverify) data = 0; for (j = 0; j < flash_driver->bus_width; j++) - if (big_endian) + if (urj_big_endian) data = (data << 8) | b[bc + j]; else data |= b[bc + j] << (j * 8); @@ -420,7 +419,7 @@ urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int noverify) data = 0; for (j = 0; j < flash_driver->bus_width; j++) - if (big_endian) + if (urj_big_endian) data = (data << 8) | b[bc + j]; else data |= b[bc + j] << (j * 8); diff --git a/urjtag/src/jtag.c b/urjtag/src/jtag.c index df9a736c..55f2d287 100644 --- a/urjtag/src/jtag.c +++ b/urjtag/src/jtag.c @@ -50,15 +50,15 @@ #include "bus.h" #include "cmd.h" #include "jtag.h" +#include "flash.h" #ifndef HAVE_GETLINE ssize_t urj_lib_getline (char **lineptr, size_t *n, FILE * stream); #endif -int debug_mode = 0; -int big_endian = 0; -int interactive = 0; -extern urj_flash_cfi_array_t *urj_flash_cfi_array; +int urj_debug_mode = 0; +int urj_big_endian = 0; +static int urj_interactive = 0; #define JTAGDIR ".jtag" #define HISTORYFILE "history" @@ -92,6 +92,41 @@ 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) +{ + char **ret = NULL; + + if (start == 0) + ret = rl_completion_matches (text, cmd_find_next); + + return ret; +} +#endif /* def HAVE_READLINE_COMPLETION */ + #ifdef HAVE_READLINE_HISTORY static void @@ -145,7 +180,8 @@ jtag_save_history (void) } #endif /* HAVE_READLINE_HISTORY */ -#endif + +#endif /* HAVE_READLINE */ static int jtag_readline_multiple_commands_support (urj_chain_t *chain, char *line) /* multiple commands should be separated with '::' */ @@ -345,7 +381,7 @@ main (int argc, char *const argv[]) break; case 'i': - interactive = 1; + urj_interactive = 1; break; case 'h': @@ -433,7 +469,7 @@ main (int argc, char *const argv[]) } } - if (!interactive) + if (!urj_interactive) return 0; } diff --git a/urjtag/src/part/instruction.c b/urjtag/src/part/instruction.c index 2ae266a8..2ceed238 100644 --- a/urjtag/src/part/instruction.c +++ b/urjtag/src/part/instruction.c @@ -28,12 +28,12 @@ #include #include -#include "instruction.h" +#include "part_instruction.h" -urj_instruction_t * +urj_part_instruction_t * urj_part_instruction_alloc (const char *name, int len, const char *val) { - urj_instruction_t *i; + urj_part_instruction_t *i; if (!name || !val) return NULL; @@ -69,7 +69,7 @@ urj_part_instruction_alloc (const char *name, int len, const char *val) } void -urj_part_instruction_free (urj_instruction_t *i) +urj_part_instruction_free (urj_part_instruction_t *i) { if (!i) return; diff --git a/urjtag/src/part/part.c b/urjtag/src/part/part.c index f6168d06..9e30bb94 100644 --- a/urjtag/src/part/part.c +++ b/urjtag/src/part/part.c @@ -87,7 +87,7 @@ urj_part_free (urj_part_t *p) /* instructions */ while (p->instructions) { - urj_instruction_t *i = p->instructions; + urj_part_instruction_t *i = p->instructions; p->instructions = i->next; urj_part_instruction_free (i); } @@ -108,10 +108,10 @@ urj_part_free (urj_part_t *p) free (p); } -urj_instruction_t * +urj_part_instruction_t * urj_part_find_instruction (urj_part_t *p, const char *iname) { - urj_instruction_t *i; + urj_part_instruction_t *i; if (!p || !iname) return NULL; diff --git a/urjtag/src/svf/svf.h b/urjtag/src/svf/svf.h index ec7b8ee5..0311ec73 100644 --- a/urjtag/src/svf/svf.h +++ b/urjtag/src/svf/svf.h @@ -95,7 +95,7 @@ struct parser_priv struct svf_parser_params parser_params; void *scanner; urj_part_t *part; - urj_instruction_t *ir; + urj_part_instruction_t *ir; urj_data_register_t *dr; urj_svf_sxr_t sir_params; urj_svf_sxr_t sdr_params; diff --git a/urjtag/src/tap/detect.c b/urjtag/src/tap/detect.c index 1beb9226..5b115930 100644 --- a/urjtag/src/tap/detect.c +++ b/urjtag/src/tap/detect.c @@ -34,7 +34,7 @@ #include -#include "register.h" +#include "tap_register.h" #include "tap.h" #include "cable.h" #include "part.h" diff --git a/urjtag/src/tap/register.c b/urjtag/src/tap/register.c index 16cad952..e906452e 100644 --- a/urjtag/src/tap/register.c +++ b/urjtag/src/tap/register.c @@ -25,7 +25,7 @@ #include #include -#include "register.h" +#include "tap_register.h" urj_tap_register_t * urj_tap_register_alloc (int len) diff --git a/urjtag/src/tap/tap.c b/urjtag/src/tap/tap.c index 0e5ce6a1..5145509a 100644 --- a/urjtag/src/tap/tap.c +++ b/urjtag/src/tap/tap.c @@ -26,7 +26,7 @@ #include -#include "register.h" +#include "tap_register.h" #include "tap.h" #include "tap_state.h" #include "chain.h"