X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fjtag%2Fvsllink.c;h=4af92e0f3059bee266f88125204b56437aca7f93;hb=8dab0ecf2334330cd470f3fa483aadf78ee2a543;hp=54a6eb64f7e3e5c889a402d67d4fee9276545c76;hpb=e5afb1424166206474694b3f90ff9d68a1b20923;p=openocd.git diff --git a/src/jtag/vsllink.c b/src/jtag/vsllink.c index 54a6eb64f7..4af92e0f30 100644 --- a/src/jtag/vsllink.c +++ b/src/jtag/vsllink.c @@ -26,29 +26,14 @@ #include "config.h" #endif -#include "replacements.h" - +#define INCLUDE_JTAG_INTERFACE_H #include "jtag.h" #include -#include -#include "log.h" //#define _VSLLINK_IN_DEBUG_MODE_ -/* enable this to view USB communication - */ -#if 0 -#define _DEBUG_USB_COMMS_ -#endif - -#ifdef _DEBUG_JTAG_IO_ -#define DEBUG_JTAG_IO(expr ...) LOG_DEBUG(expr) -#else -#define DEBUG_JTAG_IO(expr ...) -#endif - #define VSLLINK_MODE_NORMAL 0 #define VSLLINK_MODE_DMA 1 @@ -220,9 +205,9 @@ static void vsllink_runtest(int num_cycles); static void vsllink_stableclocks_dma(int num_cycles, int tms); static void vsllink_stableclocks_normal(int num_cycles, int tms); static void (*vsllink_stableclocks)(int num_cycles, int tms); -static void vsllink_scan_dma(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); -static void vsllink_scan_normal(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); -static void (*vsllink_scan)(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void vsllink_scan_dma(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void vsllink_scan_normal(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void (*vsllink_scan)(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); static void vsllink_reset(int trst, int srst); static void vsllink_simple_command(u8 command); static int vsllink_connect(void); @@ -254,7 +239,7 @@ static int vsllink_usb_message(vsllink_jtag_t *vsllink_jtag, int out_length, int static int vsllink_usb_write(vsllink_jtag_t *vsllink_jtag, int out_length); static int vsllink_usb_read(vsllink_jtag_t *vsllink_jtag); -#ifdef _DEBUG_USB_COMMS_ +#if defined _DEBUG_USB_COMMS_ || defined _DEBUG_JTAG_IO_ static void vsllink_debug_buffer(u8 *buffer, int length); #endif @@ -312,33 +297,18 @@ static int vsllink_execute_queue(void) { switch (cmd->type) { - case JTAG_END_STATE: - DEBUG_JTAG_IO("end_state: %s", tap_state_name(cmd->cmd.end_state->end_state)); - - if (cmd->cmd.end_state->end_state != TAP_INVALID) - { - vsllink_end_state(cmd->cmd.end_state->end_state); - } - break; - case JTAG_RUNTEST: DEBUG_JTAG_IO( "runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, \ tap_state_name(cmd->cmd.runtest->end_state)); - if (cmd->cmd.runtest->end_state != TAP_INVALID) - { - vsllink_end_state(cmd->cmd.runtest->end_state); - } + vsllink_end_state(cmd->cmd.runtest->end_state); vsllink_runtest(cmd->cmd.runtest->num_cycles); break; case JTAG_STATEMOVE: DEBUG_JTAG_IO("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state)); - if (cmd->cmd.statemove->end_state != TAP_INVALID) - { - vsllink_end_state(cmd->cmd.statemove->end_state); - } + vsllink_end_state(cmd->cmd.statemove->end_state); vsllink_state_move(); break; @@ -351,10 +321,7 @@ static int vsllink_execute_queue(void) break; case JTAG_SCAN: - if (cmd->cmd.scan->end_state != TAP_INVALID) - { - vsllink_end_state(cmd->cmd.scan->end_state); - } + vsllink_end_state(cmd->cmd.scan->end_state); scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); if (cmd->cmd.scan->ir_scan) @@ -726,10 +693,10 @@ static void vsllink_state_move_dma(void) &VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())]; u8 tms_scan = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state()); - vsllink_tap_ensure_space(0, 8); - if (tap_get_state() == TAP_RESET) { + vsllink_tap_ensure_space(0, 8); + for (i = 0; i < 8; i++) { vsllink_tap_append_step(1, 0); @@ -1205,7 +1172,7 @@ static void vsllink_runtest(int num_cycles) } } -static void vsllink_scan_normal(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +static void vsllink_scan_normal(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) { tap_state_t saved_end_state; u8 bits_left, tms_tmp, tdi_len; @@ -1255,7 +1222,7 @@ static void vsllink_scan_normal(int ir_scan, enum scan_type type, u8 *buffer, in // which is merged from the last tms shift command vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN | 1; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 0) & 0xff; - vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1)>> 8) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 8) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = tms_tmp; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = buffer[0] << (8 - vsllink_tms_data_len); @@ -1321,7 +1288,7 @@ static void vsllink_scan_normal(int ir_scan, enum scan_type type, u8 *buffer, in tap_set_state(tap_get_end_state()); } -static void vsllink_scan_dma(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +static void vsllink_scan_dma(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) { tap_state_t saved_end_state; @@ -1334,7 +1301,6 @@ static void vsllink_scan_dma(int ir_scan, enum scan_type type, u8 *buffer, int s vsllink_end_state(saved_end_state); /* Scan */ - vsllink_tap_ensure_space(1, (scan_size + 7) & ~0x00000007); vsllink_tap_append_scan_dma(scan_size, buffer, command); tap_set_state(ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE); @@ -1597,20 +1563,37 @@ static void vsllink_tap_append_scan_normal(int length, u8 *buffer, scan_command_ } static void vsllink_tap_append_scan_dma(int length, u8 *buffer, scan_command_t *command) { - pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; - int i; + pending_scan_result_t *pending_scan_result; + int len_tmp, len_all, i; - pending_scan_result->offset = tap_length; - pending_scan_result->length = length; - pending_scan_result->command = command; - pending_scan_result->buffer = buffer; - - for (i = 0; i < length; i++) + len_all = 0; + while (len_all < length) { - vsllink_tap_append_step((i < length-1 ? 0 : 1), (buffer[i/8] >> (i%8)) & 1); + if ((length - len_all) > tap_buffer_size * 8) + { + len_tmp = tap_buffer_size * 8; + } + else + { + len_tmp = length - len_all; + } + + vsllink_tap_ensure_space(1, (len_tmp + 7) & ~7); + + pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; + pending_scan_result->offset = tap_length; + pending_scan_result->length = len_tmp; + pending_scan_result->command = command; + pending_scan_result->buffer = buffer + len_all / 8; + + for (i = 0; i < len_tmp; i++) + { + vsllink_tap_append_step(((len_all+i) < length-1 ? 0 : 1), (buffer[(len_all+i)/8] >> ((len_all+i)%8)) & 1); + } + + pending_scan_results_length++; + len_all += len_tmp; } - - pending_scan_results_length++; } /* Pad and send a tap sequence to the device, and receive the answer. @@ -1929,7 +1912,7 @@ static int vsllink_usb_read(vsllink_jtag_t *vsllink_jtag) #define BYTES_PER_LINE 16 -#ifdef _DEBUG_USB_COMMS_ +#if defined _DEBUG_USB_COMMS_ || defined _DEBUG_JTAG_IO_ static void vsllink_debug_buffer(u8 *buffer, int length) { char line[81]; @@ -1948,4 +1931,4 @@ static void vsllink_debug_buffer(u8 *buffer, int length) LOG_DEBUG("%s", line); } } -#endif // _DEBUG_USB_COMMS_ +#endif // _DEBUG_USB_COMMS_ || _DEBUG_JTAG_IO_