diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index c9cb42c2..cb0150f2 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,4 +1,10 @@ +2009-05-02 Rutger Hofman + + Refactor the autoconf stuff a bit so make install actually creates + include/urjtag/*.h + 2009-05-01 Rutger Hofman + Global variables for liburjtag should not reside in the shell app * src/jtag.c: split into src/global/urjtag.c and src/apps/jtag/jtag.c diff --git a/urjtag/configure.ac b/urjtag/configure.ac index e6f0b1cc..10b46922 100644 --- a/urjtag/configure.ac +++ b/urjtag/configure.ac @@ -88,6 +88,7 @@ AM_GNU_GETTEXT_VERSION(0.14.1) AC_PROG_CC AC_PROG_YACC AC_PROG_LIBTOOL +AC_PROG_CC_C99 AC_SEARCH_LIBS([ioperm], [ioperm]) diff --git a/urjtag/include/urjtag/bssignal.h b/urjtag/include/urjtag/bssignal.h index 467c4dcd..2cbfb77d 100644 --- a/urjtag/include/urjtag/bssignal.h +++ b/urjtag/include/urjtag/bssignal.h @@ -68,11 +68,4 @@ urj_part_signal_t *urj_part_signal_define (urj_chain_t *chain, int urj_part_signal_redefine_pin (urj_chain_t *chain, urj_part_signal_t *s, const char *pin_name); -/** - * Check whether a chain has an active part - * - * @return if error, NULL, and sets urj_error. - */ -urj_part_t *urj_part_active_part(urj_chain_t *chain); - #endif /* URJ_BSSIGNAL_H */ diff --git a/urjtag/include/urjtag/bus.h b/urjtag/include/urjtag/bus.h index 3f0fb784..25c517d5 100644 --- a/urjtag/include/urjtag/bus.h +++ b/urjtag/include/urjtag/bus.h @@ -26,12 +26,18 @@ #ifndef URJ_BUS_H #define URJ_BUS_H -/* @@@@ this had better be an internal include file RFHH */ - #include +#include #include "bus_driver.h" +extern urj_bus_t *urj_bus; + +void urj_bus_readmem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len); +void urj_bus_writemem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len); + +/* @@@@ this had better be in an internal include file RFHH */ + typedef struct { int len; diff --git a/urjtag/include/urjtag/chain.h b/urjtag/include/urjtag/chain.h index 4e691c5b..bac6158e 100644 --- a/urjtag/include/urjtag/chain.h +++ b/urjtag/include/urjtag/chain.h @@ -65,6 +65,12 @@ void urj_tap_chain_shift_data_registers_mode (urj_chain_t *chain, void urj_tap_chain_flush (urj_chain_t *chain); int urj_tap_chain_set_pod_signal (urj_chain_t *chain, int mask, int val); int urj_tap_chain_get_pod_signal (urj_chain_t *chain, urj_pod_sigsel_t sig); +/** + * Check whether a chain has an active part + * + * @return NULL on error, and sets urj_error. + */ +urj_part_t *urj_tap_chain_active_part(urj_chain_t *chain); typedef struct { diff --git a/urjtag/include/urjtag/cmd.h b/urjtag/include/urjtag/cmd.h index f709baaa..39733d23 100644 --- a/urjtag/include/urjtag/cmd.h +++ b/urjtag/include/urjtag/cmd.h @@ -34,7 +34,7 @@ #ifndef URJ_CMD_H #define URJ_CMD_H -#include "chain.h" +#include "types.h" typedef struct { @@ -48,7 +48,7 @@ extern const urj_cmd_t *urj_cmds[]; 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); +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/include/urjtag/error.h b/urjtag/include/urjtag/error.h index ef9df9d1..4c8c7502 100644 --- a/urjtag/include/urjtag/error.h +++ b/urjtag/include/urjtag/error.h @@ -35,6 +35,7 @@ typedef enum urj_error { URJ_ERROR_NO_ACTIVE_PART, URJ_ERROR_INVALID, URJ_ERROR_NOTFOUND, + URJ_ERROR_IO, /**< I/O error from OS */ } urj_error_t; /** Max length of message string that can be recorded. */ @@ -68,7 +69,8 @@ extern urj_error_state_t urj_error_state; urj_error_state.file = __FILE__; \ urj_error_state.function = __func__; \ urj_error_state.line = __LINE__; \ - snprintf(urj_error_state.msg, sizeof urj_error_state.msg, __VA_ARGS__); \ + snprintf (urj_error_state.msg, sizeof urj_error_state.msg, \ + __VA_ARGS__); \ } while (0) /** diff --git a/urjtag/include/urjtag/flash.h b/urjtag/include/urjtag/flash.h index bd0d9525..3ca268ce 100644 --- a/urjtag/include/urjtag/flash.h +++ b/urjtag/include/urjtag/flash.h @@ -39,18 +39,6 @@ #include "types.h" -#if 0 -/* Following moved here from brux/cfi.h */ - -#include - -typedef struct -{ - int width; /* 1 for 8 bits, 2 for 16 bits, 4 for 32 bits, etc. */ - urj_flash_cfi_query_structure_t cfi; -} urj_flash_cfi_chip_t; -#endif - typedef struct urj_flash_cfi_chip urj_flash_cfi_chip_t; typedef struct diff --git a/urjtag/include/urjtag/jim/some_cpu.h b/urjtag/include/urjtag/jim/some_cpu.h index e9083ce7..3f0f545b 100644 --- a/urjtag/include/urjtag/jim/some_cpu.h +++ b/urjtag/include/urjtag/jim/some_cpu.h @@ -25,7 +25,7 @@ #ifndef URJ_JIM_SOME_CPU_H #define URJ_JIM_SOME_CPU_H -#include +#include void urj_jim_some_cpu_tck_rise (urj_jim_device_t *dev); urj_jim_device_t *urj_jim_some_cpu (void); diff --git a/urjtag/include/urjtag/jtag.h b/urjtag/include/urjtag/jtag.h index 33dd6d84..71264d7d 100644 --- a/urjtag/include/urjtag/jtag.h +++ b/urjtag/include/urjtag/jtag.h @@ -25,33 +25,15 @@ #ifndef URJ_JTAG_H #define URJ_JTAG_H -#include -#include - #include "types.h" -extern urj_bus_t *urj_bus; extern int urj_big_endian; extern int urj_debug_mode; /** Register the application name with cmd_jtag. * @param argv0 is remembered as a pointer, it is not strdup()'ed. */ -void urj_cmd_jtag_set_argv0(const char *argv0); -const char *urj_cmd_jtag_get_data_dir (void); - -int urj_cmd_jtag_parse_file (urj_chain_t *chain, const char *filename); -int urj_cmd_jtag_parse_line (urj_chain_t *chain, char *line); -int urj_cmd_jtag_parse_stream (urj_chain_t *chain, FILE * f); - -/* @@@@ RFHH shouldn't these be in their module's .h file? */ -int urj_tap_detect_parts (urj_chain_t *chain, const char *db_path); -int urj_tap_manual_add (urj_chain_t *chain, int instr_len); -int urj_tap_detect_register_size (urj_chain_t *chain); -void urj_tap_discovery (urj_chain_t *chain); -void urj_tap_urj_tap_idcode (urj_chain_t *chain, unsigned int bytes); - -void urj_bus_readmem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len); -void urj_bus_writemem (urj_bus_t *bus, FILE * f, uint32_t addr, uint32_t len); +void urj_set_argv0(const char *argv0); +const char *urj_get_data_dir (void); #endif /* URJ_JTAG_H */ diff --git a/urjtag/include/urjtag/part.h b/urjtag/include/urjtag/part.h index d1ad4a56..d6e6e3d5 100644 --- a/urjtag/include/urjtag/part.h +++ b/urjtag/include/urjtag/part.h @@ -52,7 +52,7 @@ 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_part_t *read_part (FILE *f, urj_tap_register_t *idr); 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, @@ -79,6 +79,8 @@ urj_part_instruction_t *urj_part_instruction_define (urj_part_t *part, const char *instruction, const char *code, const char *data_register); + + /** * parts */ diff --git a/urjtag/include/urjtag/tap.h b/urjtag/include/urjtag/tap.h index ff414754..1afc4ecb 100644 --- a/urjtag/include/urjtag/tap.h +++ b/urjtag/include/urjtag/tap.h @@ -27,8 +27,6 @@ #include "types.h" -#include "tap_register.h" - void urj_tap_reset (urj_chain_t *chain); void urj_tap_reset_bypass (urj_chain_t *chain); void urj_tap_capture_dr (urj_chain_t *chain); @@ -43,4 +41,11 @@ void urj_tap_shift_register (urj_chain_t *chain, const urj_tap_register_t *in, urj_tap_register_t *out, int tap_exit); +/** API functions */ +int urj_tap_detect_parts (urj_chain_t *chain, const char *db_path); +int urj_tap_manual_add (urj_chain_t *chain, int instr_len); +int urj_tap_detect_register_size (urj_chain_t *chain); +void urj_tap_discovery (urj_chain_t *chain); +void urj_tap_idcode (urj_chain_t *chain, unsigned int bytes); + #endif /* URJ_TAP_H */ diff --git a/urjtag/src/apps/jtag/jtag.c b/urjtag/src/apps/jtag/jtag.c index cc4880d7..0da93d9e 100644 --- a/urjtag/src/apps/jtag/jtag.c +++ b/urjtag/src/apps/jtag/jtag.c @@ -49,8 +49,9 @@ #include #include #include -#include #include +#include +#include #ifndef HAVE_GETLINE ssize_t urj_lib_getline (char **lineptr, size_t *n, FILE * stream); @@ -204,7 +205,7 @@ jtag_readline_multiple_commands_support (urj_chain_t *chain, char *line) ++line; } - r = urj_cmd_jtag_parse_line (chain, line); + r = urj_parse_line (chain, line); urj_tap_chain_flush (chain); @@ -298,7 +299,7 @@ jtag_parse_rc (urj_chain_t *chain) strcat (file, "/"); strcat (file, RCFILE); - go = urj_cmd_jtag_parse_file (chain, file); + go = urj_parse_file (chain, file); free (file); @@ -332,7 +333,7 @@ main (int argc, char *const argv[]) int quiet = 0; urj_chain_t *chain = NULL; - urj_cmd_jtag_set_argv0(argv[0]); + urj_set_argv0(argv[0]); if (geteuid () == 0 && getuid () != 0) { @@ -453,7 +454,7 @@ main (int argc, char *const argv[]) return -1; } - go = urj_cmd_jtag_parse_file (chain, argv[i]); + go = urj_parse_file (chain, argv[i]); cleanup (chain); if (go < 0) { @@ -475,7 +476,7 @@ main (int argc, char *const argv[]) printf (_("Out of memory\n")); return -1; } - urj_cmd_jtag_parse_stream (chain, stdin); + urj_parse_stream (chain, stdin); cleanup (chain); diff --git a/urjtag/src/bsdl/bsdl.c b/urjtag/src/bsdl/bsdl.c index f18eb50f..d10399ab 100644 --- a/urjtag/src/bsdl/bsdl.c +++ b/urjtag/src/bsdl/bsdl.c @@ -35,7 +35,6 @@ #include #include -#include #include //#include "bsdl_local.h" diff --git a/urjtag/src/bsdl/bsdl_sem.c b/urjtag/src/bsdl/bsdl_sem.c index a8750b41..0bc920f0 100644 --- a/urjtag/src/bsdl/bsdl_sem.c +++ b/urjtag/src/bsdl/bsdl_sem.c @@ -29,8 +29,8 @@ #include #include -#include #include +#include #include "bsdl_sysdep.h" diff --git a/urjtag/src/bsdl/bsdl_types.h b/urjtag/src/bsdl/bsdl_types.h index 48bd289d..3553cba0 100644 --- a/urjtag/src/bsdl/bsdl_types.h +++ b/urjtag/src/bsdl/bsdl_types.h @@ -25,7 +25,7 @@ #ifndef URJ_BSDL_TYPES_H #define URJ_BSDL_TYPES_H -#include +#include #include /* private data of the flex scanner diff --git a/urjtag/src/bsdl/vhdl_flex.l b/urjtag/src/bsdl/vhdl_flex.l index ce55a980..4339cd7e 100644 --- a/urjtag/src/bsdl/vhdl_flex.l +++ b/urjtag/src/bsdl/vhdl_flex.l @@ -127,6 +127,8 @@ LEGAL NOTICES: #include #include +#include + #include "bsdl_sysdep.h" #include "bsdl_msg.h" @@ -495,7 +497,7 @@ void urj_vhdl_flex_switch_file( yyscan_t scanner, char *filename ) f = fopen( filename, "r" ); if (!f) { - const char *db_path = urj_cmd_jtag_get_data_dir(); + const char *db_path = urj_get_data_dir(); char *db_file; if ((db_file = malloc( strlen( db_path ) + diff --git a/urjtag/src/bus/au1500.c b/urjtag/src/bus/au1500.c index 8ec889ae..9b56dbe7 100644 --- a/urjtag/src/bus/au1500.c +++ b/urjtag/src/bus/au1500.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/avr32.c b/urjtag/src/bus/avr32.c index 6ba2b020..8142e6d8 100644 --- a/urjtag/src/bus/avr32.c +++ b/urjtag/src/bus/avr32.c @@ -36,9 +36,9 @@ #include #include #include -#include #include #include +#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bcm1250.c b/urjtag/src/bus/bcm1250.c index 4a2f49be..a101d0e7 100644 --- a/urjtag/src/bus/bcm1250.c +++ b/urjtag/src/bus/bcm1250.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bf533_ezkit.c b/urjtag/src/bus/bf533_ezkit.c index f427c936..e2f59a6e 100644 --- a/urjtag/src/bus/bf533_ezkit.c +++ b/urjtag/src/bus/bf533_ezkit.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bf533_stamp.c b/urjtag/src/bus/bf533_stamp.c index 4c592524..13b663f1 100644 --- a/urjtag/src/bus/bf533_stamp.c +++ b/urjtag/src/bus/bf533_stamp.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bf537_stamp.c b/urjtag/src/bus/bf537_stamp.c index ea7f1129..80007f12 100644 --- a/urjtag/src/bus/bf537_stamp.c +++ b/urjtag/src/bus/bf537_stamp.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bf548_ezkit.c b/urjtag/src/bus/bf548_ezkit.c index 5f2bd1c0..fb3d2570 100644 --- a/urjtag/src/bus/bf548_ezkit.c +++ b/urjtag/src/bus/bf548_ezkit.c @@ -32,7 +32,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bf561_ezkit.c b/urjtag/src/bus/bf561_ezkit.c index 9d7f44c5..803bc24f 100644 --- a/urjtag/src/bus/bf561_ezkit.c +++ b/urjtag/src/bus/bf561_ezkit.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/bscoach.c b/urjtag/src/bus/bscoach.c index 1a009ef4..3bc72de6 100644 --- a/urjtag/src/bus/bscoach.c +++ b/urjtag/src/bus/bscoach.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "buses.h" diff --git a/urjtag/src/bus/ejtag.c b/urjtag/src/bus/ejtag.c index 485022ad..85c062d7 100644 --- a/urjtag/src/bus/ejtag.c +++ b/urjtag/src/bus/ejtag.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/urjtag/src/bus/ejtag_dma.c b/urjtag/src/bus/ejtag_dma.c index 7b1d2be0..40937b75 100644 --- a/urjtag/src/bus/ejtag_dma.c +++ b/urjtag/src/bus/ejtag_dma.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include diff --git a/urjtag/src/bus/fjmem.c b/urjtag/src/bus/fjmem.c index 03e4d393..53e6ccb8 100644 --- a/urjtag/src/bus/fjmem.c +++ b/urjtag/src/bus/fjmem.c @@ -31,10 +31,10 @@ #include #include #include -#include #include #include #include +#include #include #include "buses.h" diff --git a/urjtag/src/bus/generic_bus.c b/urjtag/src/bus/generic_bus.c index 94f90b61..dd65692e 100644 --- a/urjtag/src/bus/generic_bus.c +++ b/urjtag/src/bus/generic_bus.c @@ -28,7 +28,6 @@ #include #include -#include #include "generic_bus.h" diff --git a/urjtag/src/bus/h7202.c b/urjtag/src/bus/h7202.c index 65fb272f..37ccc9a5 100644 --- a/urjtag/src/bus/h7202.c +++ b/urjtag/src/bus/h7202.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/ixp425.c b/urjtag/src/bus/ixp425.c index b27ffc93..e9287474 100644 --- a/urjtag/src/bus/ixp425.c +++ b/urjtag/src/bus/ixp425.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/jopcyc.c b/urjtag/src/bus/jopcyc.c index 67bf486c..139fc0ea 100644 --- a/urjtag/src/bus/jopcyc.c +++ b/urjtag/src/bus/jopcyc.c @@ -64,7 +64,6 @@ #include #include #include -#include #include #include "buses.h" diff --git a/urjtag/src/bus/lh7a400.c b/urjtag/src/bus/lh7a400.c index 2fc4726a..56c6e0ae 100644 --- a/urjtag/src/bus/lh7a400.c +++ b/urjtag/src/bus/lh7a400.c @@ -42,7 +42,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/mpc5200.c b/urjtag/src/bus/mpc5200.c index 053396c8..8424aeb7 100644 --- a/urjtag/src/bus/mpc5200.c +++ b/urjtag/src/bus/mpc5200.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/mpc824x.c b/urjtag/src/bus/mpc824x.c index d1edf1af..6da9d350 100644 --- a/urjtag/src/bus/mpc824x.c +++ b/urjtag/src/bus/mpc824x.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/ppc405ep.c b/urjtag/src/bus/ppc405ep.c index c9c62045..88100a3a 100644 --- a/urjtag/src/bus/ppc405ep.c +++ b/urjtag/src/bus/ppc405ep.c @@ -30,7 +30,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/ppc440gx_ebc8.c b/urjtag/src/bus/ppc440gx_ebc8.c index b9783183..dabd6f5d 100644 --- a/urjtag/src/bus/ppc440gx_ebc8.c +++ b/urjtag/src/bus/ppc440gx_ebc8.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/prototype.c b/urjtag/src/bus/prototype.c index 7e48d016..6c2f624e 100644 --- a/urjtag/src/bus/prototype.c +++ b/urjtag/src/bus/prototype.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/pxa2x0.c b/urjtag/src/bus/pxa2x0.c index d86d5661..e61203d7 100644 --- a/urjtag/src/bus/pxa2x0.c +++ b/urjtag/src/bus/pxa2x0.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include "buses.h" diff --git a/urjtag/src/bus/s3c4510x.c b/urjtag/src/bus/s3c4510x.c index 4feaba7a..710083e0 100644 --- a/urjtag/src/bus/s3c4510x.c +++ b/urjtag/src/bus/s3c4510x.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include "buses.h" diff --git a/urjtag/src/bus/sa1110.c b/urjtag/src/bus/sa1110.c index 67a877d5..6dac6217 100644 --- a/urjtag/src/bus/sa1110.c +++ b/urjtag/src/bus/sa1110.c @@ -36,7 +36,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/sh7727.c b/urjtag/src/bus/sh7727.c index 19327260..57d3b330 100644 --- a/urjtag/src/bus/sh7727.c +++ b/urjtag/src/bus/sh7727.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/sh7750r.c b/urjtag/src/bus/sh7750r.c index 19d8742e..813b596d 100644 --- a/urjtag/src/bus/sh7750r.c +++ b/urjtag/src/bus/sh7750r.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/sh7751r.c b/urjtag/src/bus/sh7751r.c index 1f0568da..7a97f576 100644 --- a/urjtag/src/bus/sh7751r.c +++ b/urjtag/src/bus/sh7751r.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/sharc21065l.c b/urjtag/src/bus/sharc21065l.c index c292402a..02ef6c92 100644 --- a/urjtag/src/bus/sharc21065l.c +++ b/urjtag/src/bus/sharc21065l.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/slsup3.c b/urjtag/src/bus/slsup3.c index 1b763923..edb6cd61 100644 --- a/urjtag/src/bus/slsup3.c +++ b/urjtag/src/bus/slsup3.c @@ -36,7 +36,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/tx4925.c b/urjtag/src/bus/tx4925.c index 9a7049e5..650da41e 100644 --- a/urjtag/src/bus/tx4925.c +++ b/urjtag/src/bus/tx4925.c @@ -34,7 +34,6 @@ #include #include #include -#include #include "buses.h" #include "generic_bus.h" diff --git a/urjtag/src/bus/zefant-xs3.c b/urjtag/src/bus/zefant-xs3.c index 98c87134..27843db0 100644 --- a/urjtag/src/bus/zefant-xs3.c +++ b/urjtag/src/bus/zefant-xs3.c @@ -64,7 +64,6 @@ #include #include #include -#include #include #include "buses.h" diff --git a/urjtag/src/cmd/Makefile.am b/urjtag/src/cmd/Makefile.am index 562a3cae..b53bbf7a 100644 --- a/urjtag/src/cmd/Makefile.am +++ b/urjtag/src/cmd/Makefile.am @@ -53,7 +53,6 @@ libcmd_la_SOURCES = \ cmd_shell.c \ cmd_set.c \ cmd_endian.c \ - cmd_parse.c \ cmd_peekpoke.c \ cmd_pod.c \ cmd_readmem.c \ @@ -63,8 +62,7 @@ libcmd_la_SOURCES = \ cmd_include.c \ cmd_addpart.c \ cmd_cmd.c \ - cmd_usleep.c \ - cmd_jtag_data_dir.c + cmd_usleep.c if ENABLE_SVF libcmd_la_SOURCES += cmd_svf.c @@ -73,5 +71,3 @@ endif if ENABLE_BSDL libcmd_la_SOURCES += cmd_bsdl.c endif - -AM_CPPFLAGS = -DJTAG_BIN_DIR=\"$(bindir)\" -DJTAG_DATA_DIR=\"$(pkgdatadir)\" diff --git a/urjtag/src/cmd/cmd_addpart.c b/urjtag/src/cmd/cmd_addpart.c index 3e5625dc..9b5d587d 100644 --- a/urjtag/src/cmd/cmd_addpart.c +++ b/urjtag/src/cmd/cmd_addpart.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/urjtag/src/cmd/cmd_bit.c b/urjtag/src/cmd/cmd_bit.c index 19acc0d8..ffe068df 100644 --- a/urjtag/src/cmd/cmd_bit.c +++ b/urjtag/src/cmd/cmd_bit.c @@ -29,7 +29,6 @@ #include #include -#include #include diff --git a/urjtag/src/cmd/cmd_bus.c b/urjtag/src/cmd/cmd_bus.c index a532359e..4c538b55 100644 --- a/urjtag/src/cmd/cmd_bus.c +++ b/urjtag/src/cmd/cmd_bus.c @@ -27,8 +27,8 @@ #include #include +#include #include -#include #include diff --git a/urjtag/src/cmd/cmd_cable.c b/urjtag/src/cmd/cmd_cable.c index ae80f335..b914df44 100644 --- a/urjtag/src/cmd/cmd_cable.c +++ b/urjtag/src/cmd/cmd_cable.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/urjtag/src/cmd/cmd_cmd.c b/urjtag/src/cmd/cmd_cmd.c index 5d4c725e..4824e501 100644 --- a/urjtag/src/cmd/cmd_cmd.c +++ b/urjtag/src/cmd/cmd_cmd.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include @@ -199,7 +199,7 @@ urj_cmd_params (char *params[]) } int -urj_cmd_get_number (char *s, unsigned int *i) +urj_cmd_get_number (const char *s, unsigned int *i) { int n; int r; diff --git a/urjtag/src/cmd/cmd_debug.c b/urjtag/src/cmd/cmd_debug.c index 9677e8c2..e275d61d 100644 --- a/urjtag/src/cmd/cmd_debug.c +++ b/urjtag/src/cmd/cmd_debug.c @@ -27,9 +27,7 @@ #include #include -//#include -//#include "part.h" -//#include "bssignal.h" + #include #include diff --git a/urjtag/src/cmd/cmd_detect.c b/urjtag/src/cmd/cmd_detect.c index ebbcd7f8..b655a833 100644 --- a/urjtag/src/cmd/cmd_detect.c +++ b/urjtag/src/cmd/cmd_detect.c @@ -27,10 +27,11 @@ #include #include -#include #include +#include #include #include +#include #include @@ -49,7 +50,7 @@ cmd_detect_run (urj_chain_t *chain, char *params[]) urj_bus_buses_free (); urj_part_parts_free (chain->parts); chain->parts = NULL; - urj_tap_detect_parts (chain, urj_cmd_jtag_get_data_dir ()); + urj_tap_detect_parts (chain, urj_get_data_dir ()); if (!chain->parts) return 1; if (!chain->parts->len) diff --git a/urjtag/src/cmd/cmd_detectflash.c b/urjtag/src/cmd/cmd_detectflash.c index d03e6f5a..30eaf3d3 100644 --- a/urjtag/src/cmd/cmd_detectflash.c +++ b/urjtag/src/cmd/cmd_detectflash.c @@ -26,7 +26,7 @@ #include -#include +#include #include #include diff --git a/urjtag/src/cmd/cmd_discovery.c b/urjtag/src/cmd/cmd_discovery.c index c600eef6..d8b2b8b8 100644 --- a/urjtag/src/cmd/cmd_discovery.c +++ b/urjtag/src/cmd/cmd_discovery.c @@ -26,7 +26,7 @@ #include -#include +#include #include diff --git a/urjtag/src/cmd/cmd_dr.c b/urjtag/src/cmd/cmd_dr.c index d0710cbb..a0872b59 100644 --- a/urjtag/src/cmd/cmd_dr.c +++ b/urjtag/src/cmd/cmd_dr.c @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -40,7 +39,10 @@ static int cmd_dr_run (urj_chain_t *chain, char *params[]) { int dir = 1; + urj_part_t *part; urj_tap_register_t *r; + urj_data_register_t *dr; + urj_part_instruction_t *active_ir; if (urj_cmd_params (params) < 1 || urj_cmd_params (params) > 2) return -1; @@ -48,25 +50,18 @@ cmd_dr_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); - return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "dr"); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } - if (chain->parts->parts[chain->active_part]->active_instruction == NULL) + active_ir = part->active_instruction; + if (active_ir == NULL) { printf (_("%s: part without active instruction\n"), "dr"); return 1; } - if (chain->parts->parts[chain->active_part]->active_instruction-> - data_register == NULL) + dr = active_ir->data_register; + if (dr == NULL) { printf (_("%s: part without active data register\n"), "dr"); return 1; @@ -86,8 +81,7 @@ cmd_dr_run (urj_chain_t *chain, char *params[]) return -1; } - r = chain->parts->parts[chain->active_part]->active_instruction-> - data_register->in; + r = dr->in; if (r->len != strlen (params[1])) { printf (_("%s: register length mismatch\n"), "dr"); @@ -103,11 +97,9 @@ cmd_dr_run (urj_chain_t *chain, char *params[]) } if (dir) - r = chain->parts->parts[chain->active_part]->active_instruction-> - data_register->out; + r = dr->out; else - r = chain->parts->parts[chain->active_part]->active_instruction-> - data_register->in; + r = dr->in; printf (_("%s\n"), urj_tap_register_get_string (r)); return 1; diff --git a/urjtag/src/cmd/cmd_endian.c b/urjtag/src/cmd/cmd_endian.c index 8a024a4b..73e9e4ce 100644 --- a/urjtag/src/cmd/cmd_endian.c +++ b/urjtag/src/cmd/cmd_endian.c @@ -46,7 +46,6 @@ cmd_endian_run (urj_chain_t *chain, char *params[]) return 1; } - if (strcasecmp (params[1], "little") == 0) { urj_big_endian = 0; diff --git a/urjtag/src/cmd/cmd_eraseflash.c b/urjtag/src/cmd/cmd_eraseflash.c index e374ad51..b11485f8 100644 --- a/urjtag/src/cmd/cmd_eraseflash.c +++ b/urjtag/src/cmd/cmd_eraseflash.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/urjtag/src/cmd/cmd_flashmem.c b/urjtag/src/cmd/cmd_flashmem.c index dab29704..19c14e9b 100644 --- a/urjtag/src/cmd/cmd_flashmem.c +++ b/urjtag/src/cmd/cmd_flashmem.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/urjtag/src/cmd/cmd_frequency.c b/urjtag/src/cmd/cmd_frequency.c index 00a6fa5a..e3aac126 100644 --- a/urjtag/src/cmd/cmd_frequency.c +++ b/urjtag/src/cmd/cmd_frequency.c @@ -26,8 +26,8 @@ #include +#include #include -#include #include diff --git a/urjtag/src/cmd/cmd_get.c b/urjtag/src/cmd/cmd_get.c index bb7a5516..05fd232f 100644 --- a/urjtag/src/cmd/cmd_get.c +++ b/urjtag/src/cmd/cmd_get.c @@ -28,8 +28,8 @@ #include #include +#include #include -#include #include @@ -38,6 +38,7 @@ cmd_get_run (urj_chain_t *chain, char *params[]) { int data; urj_part_signal_t *s; + urj_part_t *part; if (urj_cmd_params (params) != 3) return -1; @@ -48,26 +49,17 @@ cmd_get_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); - return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "get"); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } - s = urj_part_find_signal (chain->parts->parts[chain->active_part], - params[2]); + s = urj_part_find_signal (part, params[2]); if (!s) { printf (_("signal '%s' not found\n"), params[2]); return 1; } - data = urj_part_get_signal (chain->parts->parts[chain->active_part], s); + data = urj_part_get_signal (part, s); if (data != -1) printf (_("%s = %d\n"), params[2], data); diff --git a/urjtag/src/cmd/cmd_idcode.c b/urjtag/src/cmd/cmd_idcode.c index 87a3b0fa..51686a8d 100644 --- a/urjtag/src/cmd/cmd_idcode.c +++ b/urjtag/src/cmd/cmd_idcode.c @@ -25,7 +25,7 @@ #include -#include +#include #include @@ -49,7 +49,7 @@ cmd_idcode_run (urj_chain_t *chain, char *params[]) return 1; printf (_("Reading %d bytes if idcode\n"), bytes); - urj_tap_urj_tap_idcode (chain, bytes); + urj_tap_idcode (chain, bytes); return 1; } diff --git a/urjtag/src/cmd/cmd_include.c b/urjtag/src/cmd/cmd_include.c index 45bfdf26..9e65391f 100644 --- a/urjtag/src/cmd/cmd_include.c +++ b/urjtag/src/cmd/cmd_include.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -65,7 +66,7 @@ cmd_include_or_script_run (urj_chain_t *chain, int is_include, char *params[]) } else { - const char *jtag_data_dir = urj_cmd_jtag_get_data_dir (); + const char *jtag_data_dir = urj_get_data_dir (); path = malloc (len = strlen (jtag_data_dir) + strlen (params[1]) + 2); if (path != NULL) { @@ -97,7 +98,7 @@ cmd_include_or_script_run (urj_chain_t *chain, int is_include, char *params[]) for (i = 0; i < j; i++) { - go = urj_cmd_jtag_parse_file (chain, path); + go = urj_parse_file (chain, path); if (go < 0) { diff --git a/urjtag/src/cmd/cmd_initbus.c b/urjtag/src/cmd/cmd_initbus.c index b09bc0c8..df7d0b8b 100644 --- a/urjtag/src/cmd/cmd_initbus.c +++ b/urjtag/src/cmd/cmd_initbus.c @@ -32,7 +32,6 @@ #include #include #include -#include static int cmd_initbus_run (urj_chain_t *chain, char *params[]) @@ -45,17 +44,8 @@ cmd_initbus_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); - return 1; - } - - if (chain->active_part >= chain->parts->len || chain->active_part < 0) - { - printf (_("%s: no active part\n"), "initbus"); + if (urj_tap_chain_active_part (chain) == NULL) return 1; - } for (i = 0; urj_bus_drivers[i] != NULL; i++) { diff --git a/urjtag/src/cmd/cmd_instruction.c b/urjtag/src/cmd/cmd_instruction.c index 87fbdce8..b30f220d 100644 --- a/urjtag/src/cmd/cmd_instruction.c +++ b/urjtag/src/cmd/cmd_instruction.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include @@ -40,19 +40,9 @@ cmd_instruction_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "instruction"); - return 1; - } - - part = chain->parts->parts[chain->active_part]; if (urj_cmd_params (params) == 2) { diff --git a/urjtag/src/cmd/cmd_part.c b/urjtag/src/cmd/cmd_part.c index f1dd0b94..847adc40 100644 --- a/urjtag/src/cmd/cmd_part.c +++ b/urjtag/src/cmd/cmd_part.c @@ -30,7 +30,6 @@ #include #include -#include #include @@ -44,10 +43,19 @@ cmd_part_run (urj_chain_t *chain, char *params[]) { if (strcasecmp (params[1], "alias") == 0) { - urj_part_t *part; - part = chain->parts->parts[chain->active_part]; - /* @@@@ ToDo RFHH check malloc result */ + urj_part_t *part = urj_tap_chain_active_part (chain); + + if (part == NULL) + return 1; + part->alias = malloc (strlen (params[2]) + 1); + if (part->alias == NULL) + { + urj_error_set(URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails", + strlen (params[2]) + 1); + return -1; + } + strcpy (part->alias, params[2]); return 1; } diff --git a/urjtag/src/cmd/cmd_peekpoke.c b/urjtag/src/cmd/cmd_peekpoke.c index 820178ac..e9e0bd25 100644 --- a/urjtag/src/cmd/cmd_peekpoke.c +++ b/urjtag/src/cmd/cmd_peekpoke.c @@ -28,7 +28,6 @@ #include #include -#include #include diff --git a/urjtag/src/cmd/cmd_pod.c b/urjtag/src/cmd/cmd_pod.c index c09c317c..2828c4d7 100644 --- a/urjtag/src/cmd/cmd_pod.c +++ b/urjtag/src/cmd/cmd_pod.c @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/urjtag/src/cmd/cmd_readmem.c b/urjtag/src/cmd/cmd_readmem.c index 0b9fbca5..66c2778e 100644 --- a/urjtag/src/cmd/cmd_readmem.c +++ b/urjtag/src/cmd/cmd_readmem.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/urjtag/src/cmd/cmd_register.c b/urjtag/src/cmd/cmd_register.c index 0f69c31f..eba95909 100644 --- a/urjtag/src/cmd/cmd_register.c +++ b/urjtag/src/cmd/cmd_register.c @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -46,27 +45,16 @@ cmd_register_run (urj_chain_t *chain, char *params[]) if (urj_cmd_params (params) != 3) return -1; - if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); - return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "register"); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } if (urj_cmd_get_number (params[2], &len)) return -1; - part = chain->parts->parts[chain->active_part]; - if (urj_part_find_data_register (part, params[1]) != NULL) { printf (_("Data register '%s' already defined\n"), params[1]); diff --git a/urjtag/src/cmd/cmd_reset.c b/urjtag/src/cmd/cmd_reset.c index 19aa71c3..517d6818 100644 --- a/urjtag/src/cmd/cmd_reset.c +++ b/urjtag/src/cmd/cmd_reset.c @@ -27,7 +27,6 @@ #include #include -#include #include #include diff --git a/urjtag/src/cmd/cmd_salias.c b/urjtag/src/cmd/cmd_salias.c index c6f0fefe..b92870e7 100644 --- a/urjtag/src/cmd/cmd_salias.c +++ b/urjtag/src/cmd/cmd_salias.c @@ -31,7 +31,6 @@ #include "urjtag/chain.h" #include "urjtag/part.h" #include "urjtag/bssignal.h" -#include "urjtag/jtag.h" #include "urjtag/cmd.h" @@ -48,19 +47,10 @@ cmd_salias_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); - return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "signal"); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } - part = chain->parts->parts[chain->active_part]; if (urj_part_find_signal (part, params[1]) != NULL) { printf (_("Signal '%s' already defined\n"), params[1]); diff --git a/urjtag/src/cmd/cmd_scan.c b/urjtag/src/cmd/cmd_scan.c index 49385d05..5665ec7b 100644 --- a/urjtag/src/cmd/cmd_scan.c +++ b/urjtag/src/cmd/cmd_scan.c @@ -34,7 +34,6 @@ #include #include #include -#include #include @@ -52,19 +51,9 @@ cmd_scan_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "scan"); - return 1; - } - - part = chain->parts->parts[chain->active_part]; /* search for Boundary Scan Register */ bsr = urj_part_find_data_register (part, "BSR"); diff --git a/urjtag/src/cmd/cmd_set.c b/urjtag/src/cmd/cmd_set.c index fba5246f..f257e6f4 100644 --- a/urjtag/src/cmd/cmd_set.c +++ b/urjtag/src/cmd/cmd_set.c @@ -28,8 +28,8 @@ #include #include +#include #include -#include #include @@ -39,6 +39,7 @@ cmd_set_run (urj_chain_t *chain, char *params[]) int dir; unsigned int data = 0; urj_part_signal_t *s; + urj_part_t *part; if (urj_cmd_params (params) < 4 || urj_cmd_params (params) > 5) return -1; @@ -49,17 +50,9 @@ cmd_set_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); - return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "set"); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } /* direction */ if (strcasecmp (params[3], "in") != 0 @@ -76,15 +69,13 @@ cmd_set_run (urj_chain_t *chain, char *params[]) return -1; } - s = urj_part_find_signal (chain->parts->parts[chain->active_part], - params[2]); + s = urj_part_find_signal (part, params[2]); if (!s) { printf (_("signal '%s' not found\n"), params[2]); return 1; } - urj_part_set_signal (chain->parts->parts[chain->active_part], s, dir, - data); + urj_part_set_signal (part, s, dir, data); return 1; } diff --git a/urjtag/src/cmd/cmd_shell.c b/urjtag/src/cmd/cmd_shell.c index 4ae7b6ca..49456e64 100644 --- a/urjtag/src/cmd/cmd_shell.c +++ b/urjtag/src/cmd/cmd_shell.c @@ -30,9 +30,6 @@ #include #include #include -//#include -//#include -#include #include diff --git a/urjtag/src/cmd/cmd_shift.c b/urjtag/src/cmd/cmd_shift.c index c8920480..359c09e8 100644 --- a/urjtag/src/cmd/cmd_shift.c +++ b/urjtag/src/cmd/cmd_shift.c @@ -28,7 +28,6 @@ #include #include -#include #include diff --git a/urjtag/src/cmd/cmd_signal.c b/urjtag/src/cmd/cmd_signal.c index b635f5ca..c7cf5901 100644 --- a/urjtag/src/cmd/cmd_signal.c +++ b/urjtag/src/cmd/cmd_signal.c @@ -28,9 +28,9 @@ #include #include +#include #include #include -#include #include @@ -47,11 +47,9 @@ cmd_signal_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - part = urj_part_active_part (chain); + part = urj_tap_chain_active_part (chain); if (part == NULL) - { return 1; - } if ((s = urj_part_find_signal (part, params[1])) != NULL) { diff --git a/urjtag/src/cmd/cmd_test.c b/urjtag/src/cmd/cmd_test.c index 78673b74..fc6ada4c 100644 --- a/urjtag/src/cmd/cmd_test.c +++ b/urjtag/src/cmd/cmd_test.c @@ -28,11 +28,12 @@ #include #include //#include -#include "urjtag/part.h" -#include "urjtag/bssignal.h" -#include "urjtag/jtag.h" -#include "urjtag/cmd.h" +#include +#include +#include + +#include static int cmd_test_run (urj_chain_t *chain, char *params[]) @@ -40,6 +41,7 @@ cmd_test_run (urj_chain_t *chain, char *params[]) int data; unsigned int i; urj_part_signal_t *s; + urj_part_t *part; if (urj_cmd_params (params) != 4) return -1; @@ -50,20 +52,11 @@ cmd_test_run (urj_chain_t *chain, char *params[]) if (!urj_cmd_test_cable (chain)) return 1; - if (!chain->parts) - { - printf (_("Run \"detect\" first.\n")); + part = urj_tap_chain_active_part (chain); + if (part == NULL) return 1; - } - - if (chain->active_part >= chain->parts->len) - { - printf (_("%s: no active part\n"), "get"); - return 1; - } - s = urj_part_find_signal (chain->parts->parts[chain->active_part], - params[2]); + s = urj_part_find_signal (part, params[2]); if (!s) { printf (_("signal '%s' not found\n"), params[2]); @@ -76,7 +69,7 @@ cmd_test_run (urj_chain_t *chain, char *params[]) if (urj_cmd_get_number (params[3], &i)) return 1; - data = urj_part_get_signal (chain->parts->parts[chain->active_part], s); + data = urj_part_get_signal (part, s); if (data != -1) { if (data != i) diff --git a/urjtag/src/cmd/cmd_usleep.c b/urjtag/src/cmd/cmd_usleep.c index 393ef02f..ee069867 100644 --- a/urjtag/src/cmd/cmd_usleep.c +++ b/urjtag/src/cmd/cmd_usleep.c @@ -29,7 +29,6 @@ #include #include -#include #include static int diff --git a/urjtag/src/cmd/cmd_writemem.c b/urjtag/src/cmd/cmd_writemem.c index be080aa5..f8955513 100644 --- a/urjtag/src/cmd/cmd_writemem.c +++ b/urjtag/src/cmd/cmd_writemem.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/urjtag/src/flash/amd_flash.c b/urjtag/src/flash/amd_flash.c index 0d20bb16..b7f96136 100644 --- a/urjtag/src/flash/amd_flash.c +++ b/urjtag/src/flash/amd_flash.c @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/urjtag/src/flash/cfi.c b/urjtag/src/flash/cfi.c index 8fd4137c..9bd8b36f 100644 --- a/urjtag/src/flash/cfi.c +++ b/urjtag/src/flash/cfi.c @@ -33,7 +33,6 @@ #include #include -#include #include #include diff --git a/urjtag/src/flash/flash.c b/urjtag/src/flash/flash.c index 0f526c78..7eaff3c3 100644 --- a/urjtag/src/flash/flash.c +++ b/urjtag/src/flash/flash.c @@ -43,9 +43,10 @@ #include "intel.h" #include -#include #include +#include +/* @@@@ RFHH Put these into a local .h file, so the implementation can check */ extern urj_flash_driver_t urj_flash_amd_32_flash_driver; extern urj_flash_driver_t urj_flash_amd_16_flash_driver; extern urj_flash_driver_t urj_flash_amd_8_flash_driver; @@ -124,24 +125,16 @@ urj_flashmsbin (urj_bus_t *bus, FILE * f, int noverify) uint32_t start; uint32_t len; int first, last; + uint32_t block_size = + cfi->device_geometry.erase_block_regions[0].erase_block_size; fread (&start, sizeof start, 1, f); fread (&len, sizeof len, 1, f); - first = - start / - (cfi->device_geometry.erase_block_regions[0].erase_block_size * - 2); - last = - (start + len - - 1) / - (cfi->device_geometry.erase_block_regions[0].erase_block_size * - 2); + first = start / (block_size * 2); + last = (start + len - 1) / (block_size * 2); for (; first <= last; first++) { - adr = - first * - cfi->device_geometry.erase_block_regions[0].erase_block_size * - 2; + adr = first * block_size * 2; flash_driver->unlock_block (urj_flash_cfi_array, adr); printf (_("block %d unlocked\n"), first); printf (_("erasing block %d: %d\n"), first, @@ -260,8 +253,7 @@ find_block (urj_flash_cfi_query_structure_t *cfi, int adr, int bus_width, for (i = 0; i < cfi->device_geometry.number_of_erase_regions; i++) { const int region_blocks = - cfi->device_geometry.erase_block_regions[i]. - number_of_erase_blocks; + cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks; const int flash_block_size = cfi->device_geometry.erase_block_regions[i].erase_block_size; const int region_block_size = @@ -271,8 +263,7 @@ find_block (urj_flash_cfi_query_structure_t *cfi, int adr, int bus_width, if (adr < (bb + region_size)) { int bir = (adr - bb) / region_block_size; - *bytes_until_next_block = - bb + (bir + 1) * region_block_size - adr; + *bytes_until_next_block = bb + (bir + 1) * region_block_size - adr; return b + bir; } b += region_blocks; @@ -282,7 +273,7 @@ find_block (urj_flash_cfi_query_structure_t *cfi, int adr, int bus_width, } void -urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int noverify) +urj_flashmem (urj_bus_t *bus, FILE *f, uint32_t addr, int noverify) { uint32_t adr; urj_flash_cfi_query_structure_t *cfi; @@ -310,8 +301,7 @@ urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int noverify) for (i = 0, neb = 0; i < cfi->device_geometry.number_of_erase_regions; i++) neb += - cfi->device_geometry.erase_block_regions[i]. - number_of_erase_blocks; + cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks; erased = malloc (neb * sizeof *erased); if (!erased) @@ -329,10 +319,8 @@ urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int noverify) uint32_t data; uint8_t b[BSIZE]; int bc = 0, bn = 0, btr = BSIZE; - int block_no = - find_block (cfi, adr - urj_flash_cfi_array->address, bus_width, - chip_width, - &btr); + int block_no = find_block (cfi, adr - urj_flash_cfi_array->address, + bus_width, chip_width, &btr); write_buffer_count = 0; write_buffer_adr = adr; @@ -374,9 +362,8 @@ urj_flashmem (urj_bus_t *bus, FILE * f, uint32_t addr, int noverify) } if (write_buffer_count > 0) - if (flash_driver-> - program (urj_flash_cfi_array, write_buffer_adr, write_buffer, - write_buffer_count)) + if (flash_driver->program (urj_flash_cfi_array, write_buffer_adr, + write_buffer, write_buffer_count)) { printf (_("\nflash error\n")); return; @@ -464,10 +451,8 @@ urj_flasherase (urj_bus_t *bus, uint32_t addr, int number) for (i = 1; i <= number; i++) { int btr = 0; - int block_no = - find_block (cfi, addr - urj_flash_cfi_array->address, bus_width, - chip_width, - &btr); + int block_no = find_block (cfi, addr - urj_flash_cfi_array->address, + bus_width, chip_width, &btr); if (block_no < 0) { diff --git a/urjtag/src/flash/intel.c b/urjtag/src/flash/intel.c index 0cb72ce5..ca106e84 100644 --- a/urjtag/src/flash/intel.c +++ b/urjtag/src/flash/intel.c @@ -41,7 +41,6 @@ #include #include -#include #include #include @@ -49,26 +48,6 @@ #include "intel.h" #include "mic.h" -static int intel_flash_erase_block (urj_flash_cfi_array_t *cfi_array, - uint32_t adr); -static int intel_flash_unlock_block (urj_flash_cfi_array_t *cfi_array, - uint32_t adr); -static int intel_flash_program_single (urj_flash_cfi_array_t *cfi_array, - uint32_t adr, uint32_t data); -static int intel_flash_program_buffer (urj_flash_cfi_array_t *cfi_array, - uint32_t adr, uint32_t *buffer, - int count); -static int intel_flash_program (urj_flash_cfi_array_t *cfi_array, - uint32_t adr, uint32_t *buffer, int count); -static int intel_flash_erase_block32 (urj_flash_cfi_array_t *cfi_array, - uint32_t adr); -static int intel_flash_unlock_block32 (urj_flash_cfi_array_t *cfi_array, - uint32_t adr); -static int intel_flash_program32_single (urj_flash_cfi_array_t *cfi_array, - uint32_t adr, uint32_t data); -static int intel_flash_program32 (urj_flash_cfi_array_t *cfi_array, - uint32_t adr, uint32_t *buffer, int count); - /* autodetect, we can handle this chip */ static int intel_flash_autodetect32 (urj_flash_cfi_array_t *cfi_array) @@ -79,14 +58,15 @@ intel_flash_autodetect32 (urj_flash_cfi_array_t *cfi_array) &area) != URJ_STATUS_OK) return 0; - return ((cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_MITSUBISHI_SCS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_MITSUBISHI_ECS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_INTEL_ECS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_INTEL_SCS)) && (area.width == 32); + return ((cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_MITSUBISHI_SCS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_MITSUBISHI_ECS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_INTEL_ECS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_INTEL_SCS)) + && (area.width == 32); } static int @@ -98,14 +78,15 @@ intel_flash_autodetect (urj_flash_cfi_array_t *cfi_array) &area) != URJ_STATUS_OK) return 0; - return ((cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_MITSUBISHI_SCS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_MITSUBISHI_ECS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_INTEL_ECS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_INTEL_SCS)) && (area.width == 16); + return ((cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_MITSUBISHI_SCS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_MITSUBISHI_ECS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_INTEL_ECS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_INTEL_SCS)) + && (area.width == 16); } static int @@ -117,14 +98,15 @@ intel_flash_autodetect8 (urj_flash_cfi_array_t *cfi_array) &area) != URJ_STATUS_OK) return 0; - return ((cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_MITSUBISHI_SCS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_MITSUBISHI_ECS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_INTEL_ECS) - || (cfi_array->cfi_chips[0]->cfi.identification_string. - pri_id_code == CFI_VENDOR_INTEL_SCS)) && (area.width == 8); + return ((cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_MITSUBISHI_SCS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_MITSUBISHI_ECS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_INTEL_ECS) + || (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code + == CFI_VENDOR_INTEL_SCS)) + && (area.width == 8); } static void @@ -133,9 +115,7 @@ _intel_flash_print_info (urj_flash_cfi_array_t *cfi_array, int o) uint32_t mid, cid; urj_bus_t *bus = cfi_array->bus; - mid = - (URJ_BUS_READ (bus, cfi_array->address + (0x00 << o)) & - 0xFF); + mid = (URJ_BUS_READ (bus, cfi_array->address + (0x00 << o)) & 0xFF); switch (mid) { case STD_MIC_INTEL: @@ -153,9 +133,7 @@ _intel_flash_print_info (urj_flash_cfi_array_t *cfi_array, int o) } printf (_("Chip: ")); - cid = - (URJ_BUS_READ (bus, cfi_array->address + (0x01 << o)) & - 0xFFFF); + cid = (URJ_BUS_READ (bus, cfi_array->address + (0x01 << o)) & 0xFFFF); switch (cid) { case 0x0016: diff --git a/urjtag/src/flash/jedec.c b/urjtag/src/flash/jedec.c index 8f21b132..f4d5152f 100644 --- a/urjtag/src/flash/jedec.c +++ b/urjtag/src/flash/jedec.c @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -107,604 +106,291 @@ struct amd_flash_info static const struct amd_flash_info table[] = { { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29LV160DT, - .name = "AMD AM29LV160DT", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = 0x10000,.numblocks = 31}, - {.offset = 0x1F0000,.erasesize = 0x08000,.numblocks = 1}, - {.offset = 0x1F8000,.erasesize = 0x02000,.numblocks = 2}, - {.offset = 0x1FC000,.erasesize = 0x04000,.numblocks = 1} - } - }, { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29LV160DB, - .name = "AMD AM29LV160DB", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = 0x04000,.numblocks = 1}, - {.offset = 0x004000,.erasesize = 0x02000,.numblocks = 2}, - {.offset = 0x008000,.erasesize = 0x08000,.numblocks = 1}, - {.offset = 0x010000,.erasesize = 0x10000,.numblocks = 31} - } - }, { - .mfr_id = MANUFACTURER_TOSHIBA, - .dev_id = TC58FVT160, - .name = "Toshiba TC58FVT160", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = 0x10000,.numblocks = - 31}, - {.offset = 0x1F0000,.erasesize = 0x08000,.numblocks = - 1}, - {.offset = 0x1F8000,.erasesize = 0x02000,.numblocks = - 2}, - {.offset = 0x1FC000,.erasesize = 0x04000,.numblocks = - 1} - } - }, { - .mfr_id = MANUFACTURER_FUJITSU, - .dev_id = MBM29LV160TE, - .name = "Fujitsu MBM29LV160TE", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = - 0x10000,.numblocks = 31}, - {.offset = 0x1F0000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = 0x1F8000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = 0x1FC000,.erasesize = - 0x04000,.numblocks = 1} - } - }, { - .mfr_id = MANUFACTURER_TOSHIBA, - .dev_id = TC58FVB160, - .name = "Toshiba TC58FVB160", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = - 0x04000,.numblocks = 1}, - {.offset = 0x004000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = 0x008000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = 0x010000,.erasesize = - 0x10000,.numblocks = 31} - } - }, { - .mfr_id = MANUFACTURER_FUJITSU, - .dev_id = MBM29LV160BE, - .name = "Fujitsu MBM29LV160BE", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = - 0x04000,.numblocks = 1}, - {.offset = 0x004000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = 0x008000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = 0x010000,.erasesize = - 0x10000,.numblocks = 31} - } - }, { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29LV800BB, - .name = "AMD AM29LV800BB", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = - 0x04000,.numblocks = 1}, - {.offset = 0x004000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = 0x008000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = 0x010000,.erasesize = - 0x10000,.numblocks = 15} - } - }, { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29F800BB, - .name = "AMD AM29F800BB", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = 0x000000,.erasesize = - 0x04000,.numblocks = 1}, - {.offset = 0x004000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = 0x008000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = 0x010000,.erasesize = - 0x10000,.numblocks = 15} - } - }, { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29LV800BT, - .name = "AMD AM29LV800BT", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = - 0x000000,.erasesize = - 0x10000,.numblocks = 15}, - {.offset = - 0x0F0000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = - 0x0F8000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = - 0x0FC000,.erasesize = - 0x04000,.numblocks = 1} - } - }, { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29F800BT, - .name = "AMD AM29F800BT", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = - 0x000000,.erasesize = - 0x10000,.numblocks = - 15}, - {.offset = - 0x0F0000,.erasesize = - 0x08000,.numblocks = 1}, - {.offset = - 0x0F8000,.erasesize = - 0x02000,.numblocks = 2}, - {.offset = - 0x0FC000,.erasesize = - 0x04000,.numblocks = 1} - } - }, { - .mfr_id = MANUFACTURER_AMD, - .dev_id = AM29LV800BB, - .name = "AMD AM29LV800BB", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = - 0x000000,. - erasesize = - 0x10000,.numblocks = - 15}, - {.offset = - 0x0F0000,. - erasesize = - 0x08000,.numblocks = - 1}, - {.offset = - 0x0F8000,. - erasesize = - 0x02000,.numblocks = - 2}, - {.offset = - 0x0FC000,. - erasesize = - 0x04000,.numblocks = - 1} - } - }, { - .mfr_id = - MANUFACTURER_FUJITSU, - .dev_id = MBM29LV800BB, - .name = - "Fujitsu MBM29LV800BB", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = - 0x000000,. - erasesize = - 0x04000,. - numblocks = 1}, - {.offset = - 0x004000,. - erasesize = - 0x02000,. - numblocks = 2}, - {.offset = - 0x008000,. - erasesize = - 0x08000,. - numblocks = 1}, - {.offset = - 0x010000,. - erasesize = - 0x10000,. - numblocks = 15} - } - }, { - .mfr_id = - MANUFACTURER_ST, - .dev_id = M29W800T, - .name = "ST M29W800T", - .size = 0x00100000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = - AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {.offset = - 0x000000,. - erasesize = - 0x10000,. - numblocks = - 15}, - {.offset = - 0x0F0000,. - erasesize = - 0x08000,. - numblocks = - 1}, - {.offset = - 0x0F8000,. - erasesize = - 0x02000,. - numblocks = - 2}, - {.offset = - 0x0FC000,. - erasesize = - 0x04000,. - numblocks = - 1} - } - }, { - .mfr_id = - MANUFACTURER_ST, - .dev_id = M29W160DT, - .name = - "ST M29W160DT", - .size = 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = - AUTOSELECT_M1, - .numeraseregions = 4, - .regions = { - {. - offset = - 0x000000,. - erasesize - = - 0x10000,. - numblocks - = 31}, - {. - offset = - 0x1F0000,. - erasesize - = - 0x08000,. - numblocks - = 1}, - {. - offset = - 0x1F8000,. - erasesize - = - 0x02000,. - numblocks - = 2}, - {. - offset = - 0x1FC000,. - erasesize - = - 0x04000,. - numblocks - = 1} - } - }, { - .mfr_id = - MANUFACTURER_ST, - .dev_id = - M29W160DB, - .name = - "ST M29W160DB", - .size = - 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = - AUTOSELECT_M1, - . - numeraseregions = - 4, - .regions = { - {. - offset - = - 0x000000,. - erasesize - = - 0x04000,. - numblocks - = - 1}, - {. - offset - = - 0x004000,. - erasesize - = - 0x02000,. - numblocks - = - 2}, - {. - offset - = - 0x008000,. - erasesize - = - 0x08000,. - numblocks - = - 1}, - {. - offset - = - 0x010000,. - erasesize - = - 0x10000,. - numblocks - = - 31} - } - }, { - .mfr_id = - MANUFACTURER_AMD, - .dev_id = - AM29BDS323D, - .name = - "AMD AM29BDS323D", - .size = - 0x00400000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - .as_method = - AUTOSELECT_M1, - . - numeraseregions - = 3, - .regions = { - {.offset = 0x000000,.erasesize = 0x10000,.numblocks = 48}, - {.offset = 0x300000,.erasesize = 0x10000,.numblocks = 15}, - {.offset = 0x3f0000,.erasesize = 0x02000,.numblocks = 8}, - } - }, { - .mfr_id = - MANUFACTURER_AMD, - .dev_id = - AM29BDS643D, - .name = - "AMD AM29BDS643D", - .size = - 0x00800000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - . - as_method - = - AUTOSELECT_M1, - . - numeraseregions - = 3, - . - regions = - { - {. - offset - = - 0x000000,. - erasesize - = - 0x10000,. - numblocks - = 96}, - {. - offset - = - 0x600000,. - erasesize - = - 0x10000,. - numblocks - = 31}, - {. - offset - = - 0x7f0000,. - erasesize - = - 0x02000,. - numblocks - = 8}, - } - }, { - . - mfr_id - = - MANUFACTURER_ATMEL, - . - dev_id - = - AT49xV16x, - . - name - = - "Atmel AT49xV16x", - . - size - = - 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - . - as_method - = - AUTOSELECT_M1, - . - numeraseregions - = 2, - . - regions - = { - {. - offset - = - 0x000000,. - erasesize - = - 0x02000,. - numblocks - = - 8}, - {. - offset - = - 0x010000,. - erasesize - = - 0x10000,. - numblocks - = - 31} - } - }, { - . - mfr_id - = - MANUFACTURER_ATMEL, - . - dev_id - = - AT49xV16xT, - . - name - = - "Atmel AT49xV16xT", - . - size - = - 0x00200000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - . - as_method - = - AUTOSELECT_M1, - . - numeraseregions - = - 2, - . - regions - = - { - {.offset = 0x000000,.erasesize = 0x10000,.numblocks = 31}, - {.offset = 0x1F0000,.erasesize = 0x02000,.numblocks = 8} - } - }, { - . - mfr_id - = - MANUFACTURER_MX, - . - dev_id - = - MX29LV400T, - . - name - = - "MX 29LV400T", - . - size - = - 0x0080000, - .interface_width = CFI_INTERFACE_X16, /* correct default? */ - . - as_method - = - AUTOSELECT_M1, - . - numeraseregions - = - 4, - . - regions - = - { - {.offset = 0x000000,.erasesize = 0x10000,.numblocks = 7}, - {.offset = 0x070000,.erasesize = 0x08000,.numblocks = 1}, - {.offset = 0x078000,.erasesize = 0x02000,.numblocks = 2}, - {.offset = 0x07c000,.erasesize = 0x04000,.numblocks = 1}, - } - }, { - . - mfr_id - = - MANUFACTURER_AMD, - . - dev_id - = - AM29LV040B, - . - name - = - "AMD AM29LV040B", - . - size - = - 0x0080000, - .interface_width = CFI_INTERFACE_X8, /* checked, ok */ - . - as_method - = - AUTOSELECT_M2, - . - numeraseregions - = - 1, - . - regions - = - { - {.offset = 0x000000,.erasesize = 0x10000,.numblocks = 8}, - } - } + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV160DT, + .name = "AMD AM29LV160DT", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, + { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV160DB, + .name = "AMD AM29LV160DB", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } + } + }, { + .mfr_id = MANUFACTURER_TOSHIBA, + .dev_id = TC58FVT160, + .name = "Toshiba TC58FVT160", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, + { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_FUJITSU, + .dev_id = MBM29LV160TE, + .name = "Fujitsu MBM29LV160TE", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, + { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_TOSHIBA, + .dev_id = TC58FVB160, + .name = "Toshiba TC58FVB160", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } + } + }, { + .mfr_id = MANUFACTURER_FUJITSU, + .dev_id = MBM29LV160BE, + .name = "Fujitsu MBM29LV160BE", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV800BB, + .name = "AMD AM29LV800BB", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29F800BB, + .name = "AMD AM29F800BB", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV800BT, + .name = "AMD AM29LV800BT", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, + { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29F800BT, + .name = "AMD AM29F800BT", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, + { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV800BB, + .name = "AMD AM29LV800BB", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, + { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_FUJITSU, + .dev_id = MBM29LV800BB, + .name = "Fujitsu MBM29LV800BB", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 } + } + }, { + .mfr_id = MANUFACTURER_ST, + .dev_id = M29W800T, + .name = "ST M29W800T", + .size = 0x00100000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, + { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_ST, + .dev_id = M29W160DT, + .name = "ST M29W160DT", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, + { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } + } + }, { + .mfr_id = MANUFACTURER_ST, + .dev_id = M29W160DB, + .name = "ST M29W160DB", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, + { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29BDS323D, + .name = "AMD AM29BDS323D", + .size = 0x00400000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 3, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 48 }, + { .offset = 0x300000, .erasesize = 0x10000, .numblocks = 15 }, + { .offset = 0x3f0000, .erasesize = 0x02000, .numblocks = 8 }, + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29BDS643D, + .name = "AMD AM29BDS643D", + .size = 0x00800000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 3, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 96 }, + { .offset = 0x600000, .erasesize = 0x10000, .numblocks = 31 }, + { .offset = 0x7f0000, .erasesize = 0x02000, .numblocks = 8 }, + } + }, { + .mfr_id = MANUFACTURER_ATMEL, + .dev_id = AT49xV16x, + .name = "Atmel AT49xV16x", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 2, + .regions = { + { .offset = 0x000000, .erasesize = 0x02000, .numblocks = 8 }, + { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } + } + }, { + .mfr_id = MANUFACTURER_ATMEL, + .dev_id = AT49xV16xT, + .name = "Atmel AT49xV16xT", + .size = 0x00200000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 2, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, + { .offset = 0x1F0000, .erasesize = 0x02000, .numblocks = 8 } + } + }, { + .mfr_id = MANUFACTURER_MX, + .dev_id = MX29LV400T, + .name = "MX 29LV400T", + .size = 0x0080000, + .interface_width = CFI_INTERFACE_X16, /* correct default? */ + .as_method = AUTOSELECT_M1, + .numeraseregions = 4, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 7 }, + { .offset = 0x070000, .erasesize = 0x08000, .numblocks = 1 }, + { .offset = 0x078000, .erasesize = 0x02000, .numblocks = 2 }, + { .offset = 0x07c000, .erasesize = 0x04000, .numblocks = 1 }, + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV040B, + .name = "AMD AM29LV040B", + .size = 0x0080000, + .interface_width = CFI_INTERFACE_X8, /* checked, ok */ + .as_method = AUTOSELECT_M2, + .numeraseregions = 1, + .regions = { + { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 8 }, + } + } }; int diff --git a/urjtag/src/flash/jedec_exp.c b/urjtag/src/flash/jedec_exp.c index 50cd55f1..cf5cbe61 100644 --- a/urjtag/src/flash/jedec_exp.c +++ b/urjtag/src/flash/jedec_exp.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include diff --git a/urjtag/src/global/Makefile.am b/urjtag/src/global/Makefile.am index e9e31377..2fbccfd9 100644 --- a/urjtag/src/global/Makefile.am +++ b/urjtag/src/global/Makefile.am @@ -26,4 +26,8 @@ include $(top_srcdir)/Makefile.rules noinst_LTLIBRARIES = libglobal.la libglobal_la_SOURCES = \ - urjtag.c + parse.c \ + urjtag.c \ + data_dir.c + +AM_CPPFLAGS = -DJTAG_BIN_DIR=\"$(bindir)\" -DJTAG_DATA_DIR=\"$(pkgdatadir)\" diff --git a/urjtag/src/cmd/cmd_jtag_data_dir.c b/urjtag/src/global/data_dir.c similarity index 88% rename from urjtag/src/cmd/cmd_jtag_data_dir.c rename to urjtag/src/global/data_dir.c index a5e2be1e..6d6fbd78 100644 --- a/urjtag/src/cmd/cmd_jtag_data_dir.c +++ b/urjtag/src/global/data_dir.c @@ -11,7 +11,7 @@ static const char *jtag_argv0; void -urj_cmd_jtag_set_argv0(const char *argv0) +urj_set_argv0(const char *argv0) { jtag_argv0 = argv0; } @@ -28,7 +28,7 @@ extern char *make_relative_prefix (const char *progname, static char *jtag_data_dir = NULL; const char * -urj_cmd_jtag_get_data_dir (void) +urj_get_data_dir (void) { if (jtag_data_dir) return jtag_data_dir; @@ -44,7 +44,7 @@ urj_cmd_jtag_get_data_dir (void) #else const char * -urj_cmd_jtag_get_data_dir (void) +urj_get_data_dir (void) { return JTAG_DATA_DIR; } diff --git a/urjtag/src/cmd/cmd_parse.c b/urjtag/src/global/parse.c similarity index 89% rename from urjtag/src/cmd/cmd_parse.c rename to urjtag/src/global/parse.c index d3a642d7..e14e6369 100644 --- a/urjtag/src/cmd/cmd_parse.c +++ b/urjtag/src/global/parse.c @@ -30,8 +30,10 @@ #include #include #include +#include #include +#include #include #include @@ -40,7 +42,7 @@ int -urj_cmd_jtag_parse_line (urj_chain_t *chain, char *line) +urj_parse_line (urj_chain_t *chain, char *line) { int l, i, r, tcnt; char **a; @@ -111,7 +113,7 @@ urj_cmd_jtag_parse_line (urj_chain_t *chain, char *line) r = urj_cmd_run (chain, a); if (urj_debug_mode & 1) - printf ("Return in urj_cmd_jtag_parse_line r=%d\n", r); + printf ("Return in urj_parse_line r=%d\n", r); free (a); free (sline); return r; @@ -119,7 +121,7 @@ urj_cmd_jtag_parse_line (urj_chain_t *chain, char *line) int -urj_cmd_jtag_parse_stream (urj_chain_t *chain, FILE * f) +urj_parse_stream (urj_chain_t *chain, FILE * f) { char inputline[MAXINPUTLINE + 1]; int go = 1, i, c, lnr, clip, found_comment; @@ -151,7 +153,7 @@ urj_cmd_jtag_parse_stream (urj_chain_t *chain, FILE * f) fprintf (stdout, "Warning: line %d exceeds %d characters, clipped\n", lnr, (int) sizeof (inputline) - 1); - go = urj_cmd_jtag_parse_line (chain, inputline); + go = urj_parse_line (chain, inputline); urj_tap_chain_flush (chain); } while (go && c != EOF); @@ -160,16 +162,20 @@ urj_cmd_jtag_parse_stream (urj_chain_t *chain, FILE * f) } int -urj_cmd_jtag_parse_file (urj_chain_t *chain, const char *filename) +urj_parse_file (urj_chain_t *chain, const char *filename) { FILE *f; int go; f = fopen (filename, "r"); if (!f) + { + urj_error_set(URJ_ERROR_IO, "Cannot open file '%s' to parse: %s", filename, strerror(errno)); + errno = 0; return -1; + } - go = urj_cmd_jtag_parse_stream (chain, f); + go = urj_parse_stream (chain, f); fclose (f); if (urj_debug_mode & 1) diff --git a/urjtag/src/part/signal.c b/urjtag/src/part/signal.c index 911705f0..53f8ee91 100644 --- a/urjtag/src/part/signal.c +++ b/urjtag/src/part/signal.c @@ -98,25 +98,6 @@ urj_part_salias_free (urj_part_salias_t *salias) free (salias); } -urj_part_t * -urj_part_active_part(urj_chain_t *chain) -{ - if (!chain->parts) - { - urj_error_set (URJ_ERROR_NO_ACTIVE_PART, - _("Run \"detect\" first.\n")); - return NULL; - } - if (chain->active_part >= chain->parts->len) - { - urj_error_set (URJ_ERROR_NO_ACTIVE_PART, - _("%s: no active part\n"), "signal"); - return NULL; - } - - return chain->parts->parts[chain->active_part]; -} - urj_part_signal_t * urj_part_signal_define_pin (urj_chain_t *chain, const char *signal_name, const char *pin_name) @@ -124,7 +105,7 @@ urj_part_signal_define_pin (urj_chain_t *chain, const char *signal_name, urj_part_t *part; urj_part_signal_t *s; - part = urj_part_active_part (chain); + part = urj_tap_chain_active_part (chain); if (urj_part_find_signal (part, signal_name) != NULL) { diff --git a/urjtag/src/svf/svf.c b/urjtag/src/svf/svf.c index de848ab6..99fa18da 100644 --- a/urjtag/src/svf/svf.c +++ b/urjtag/src/svf/svf.c @@ -40,11 +40,10 @@ #define SA_ONESHOT SA_RESETHAND #endif -#include #include #include -#include #include +#include #include #include @@ -848,9 +847,8 @@ urj_svf_sxr (urj_chain_t *chain, urj_svf_parser_priv_t *priv, urj_svf_sxr_t *sxr_params; int len, result = 1; - sxr_params = - ir_dr == - URJ_SVF_generic_ir ? &(priv->sir_params) : &(priv->sdr_params); + sxr_params = (ir_dr == URJ_SVF_generic_ir) ? + &(priv->sir_params) : &(priv->sdr_params); /* remember parameters */ urj_svf_remember_param (&sxr_params->params.tdi, params->tdi); diff --git a/urjtag/src/tap/cable.c b/urjtag/src/tap/cable.c index 75d4d8c4..15022b1a 100644 --- a/urjtag/src/tap/cable.c +++ b/urjtag/src/tap/cable.c @@ -28,13 +28,13 @@ #include +#include #include #include #include #include #include -#include #include #undef VERBOSE diff --git a/urjtag/src/tap/cable/jlink.c b/urjtag/src/tap/cable/jlink.c index 99fdacf7..64cf8f2e 100644 --- a/urjtag/src/tap/cable/jlink.c +++ b/urjtag/src/tap/cable/jlink.c @@ -43,7 +43,6 @@ #include #include -#include #include #include diff --git a/urjtag/src/tap/chain.c b/urjtag/src/tap/chain.c index 6efb0867..46daab44 100644 --- a/urjtag/src/tap/chain.c +++ b/urjtag/src/tap/chain.c @@ -282,3 +282,22 @@ urj_tap_chain_flush (urj_chain_t *chain) if (chain->cable != NULL) urj_tap_cable_flush (chain->cable, URJ_TAP_CABLE_COMPLETELY); } + +urj_part_t * +urj_tap_chain_active_part (urj_chain_t *chain) +{ + if (!chain->parts) + { + urj_error_set (URJ_ERROR_NO_ACTIVE_PART, + _("Run \"detect\" first.\n")); + return NULL; + } + if (chain->active_part >= chain->parts->len) + { + urj_error_set (URJ_ERROR_NO_ACTIVE_PART, + _("%s: no active part\n"), "signal"); + return NULL; + } + + return chain->parts->parts[chain->active_part]; +} diff --git a/urjtag/src/tap/detect.c b/urjtag/src/tap/detect.c index fe3602a3..0dbed307 100644 --- a/urjtag/src/tap/detect.c +++ b/urjtag/src/tap/detect.c @@ -40,7 +40,6 @@ #include #include -#include struct id_record { diff --git a/urjtag/src/tap/discovery.c b/urjtag/src/tap/discovery.c index 17e6dd6f..03e7b29c 100644 --- a/urjtag/src/tap/discovery.c +++ b/urjtag/src/tap/discovery.c @@ -27,11 +27,10 @@ #include #include -#include #include +#include #include -#include #define DETECT_PATTERN_SIZE 8 #define MAX_REGISTER_LENGTH 1024 diff --git a/urjtag/src/tap/idcode.c b/urjtag/src/tap/idcode.c index aed8e5bc..03398e21 100644 --- a/urjtag/src/tap/idcode.c +++ b/urjtag/src/tap/idcode.c @@ -26,14 +26,13 @@ #include #include -#include #include +#include #include -#include void -urj_tap_urj_tap_idcode (urj_chain_t *chain, unsigned int bytes) +urj_tap_idcode (urj_chain_t *chain, unsigned int bytes) { int i; int hit = 0;