xvsf player fixes by Dick Hollenbeck <dick@softplc.com>

git-svn-id: svn://svn.berlios.de/openocd/trunk@1360 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
kc8apf
2009-01-23 07:10:11 +00:00
parent 6f612fb959
commit d5209daeb1
5 changed files with 122 additions and 47 deletions

View File

@@ -38,6 +38,14 @@
#include <unistd.h>
/**
* Function bitbang_stableclocks
* issues a number of clock cycles while staying in a stable state.
* Because the TMS value required to stay in the RESET state is a 1, whereas
* the TMS value required to stay in any of the other stable states is a 0,
* this function checks the current stable state to decide on the value of TMS
* to use.
*/
static void bitbang_stableclocks(int num_cycles);
@@ -162,13 +170,14 @@ void bitbang_runtest(int num_cycles)
static void bitbang_stableclocks(int num_cycles)
{
int tms = (cur_state == TAP_RESET ? 1 : 0);
int i;
/* send num_cycles clocks onto the cable */
for (i = 0; i < num_cycles; i++)
{
bitbang_interface->write(1, 0, 0);
bitbang_interface->write(0, 0, 0);
bitbang_interface->write(1, tms, 0);
bitbang_interface->write(0, tms, 0);
}
}
@@ -293,6 +302,9 @@ int bitbang_execute_queue(void)
break;
case JTAG_STABLECLOCKS:
/* this is only allowed while in a stable state. A check for a stable
* state was done in jtag_add_clocks()
*/
bitbang_stableclocks(cmd->cmd.stableclocks->num_cycles);
break;

View File

@@ -1415,22 +1415,9 @@ int ft2232_execute_queue()
break;
case JTAG_STABLECLOCKS:
/* "if (tap_move_map[cur_state] != -1)" is of no help when cur_state==TAP_IDLE */
switch(cur_state)
{
case TAP_DRSHIFT:
case TAP_IDLE:
case TAP_RESET:
case TAP_DRPAUSE:
case TAP_IRSHIFT:
case TAP_IRPAUSE:
break; /* above stable states are OK */
default:
LOG_ERROR( "jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
jtag_state_name(cur_state) );
retval = ERROR_JTAG_QUEUE_FAILED;
}
/* this is only allowed while in a stable state. A check for a stable
* state was done in jtag_add_clocks()
*/
if (ft2232_stableclocks(cmd->cmd.stableclocks->num_cycles, cmd) != ERROR_OK)
retval = ERROR_JTAG_QUEUE_FAILED;
#ifdef _DEBUG_JTAG_IO_
@@ -2336,11 +2323,15 @@ static int ft2232_stableclocks(int num_cycles, jtag_command_t *cmd)
{
int retval = 0;
/* 7 bits of either ones or zeros. */
u8 tms = (cur_state == TAP_RESET ? 0x7F : 0x00);
while (num_cycles > 0)
{
/* the command 0x4b, "Clock Data to TMS/CS Pin (no Read)" handles
* at most 7 bits per invocation. Here we invoke it potentially
* several times.
* see: http://www.ftdichip.com/Documents/AppNotes/AN2232C-01_MPSSE_Cmnd.pdf
*/
int bitcount_per_command = (num_cycles > 7) ? 7 : num_cycles;
@@ -2358,8 +2349,8 @@ static int ft2232_stableclocks(int num_cycles, jtag_command_t *cmd)
/* scan 7 bit */
BUFFER_ADD = bitcount_per_command - 1;
/* TMS data bits are all zeros to stay in the current stable state */
BUFFER_ADD = 0x0;
/* TMS data bits are either all zeros or ones to stay in the current stable state */
BUFFER_ADD = tms;
require_send = 1;

View File

@@ -1093,11 +1093,31 @@ void jtag_add_clocks( int num_cycles )
{
int retval;
jtag_prelude1();
/* "if (tap_move_map[cm_queue_cur_state] != -1)" is of no help when cur_state==TAP_IDLE */
switch(cmd_queue_cur_state)
{
case TAP_DRSHIFT:
case TAP_IDLE:
case TAP_RESET:
case TAP_DRPAUSE:
case TAP_IRSHIFT:
case TAP_IRPAUSE:
break; /* above stable states are OK */
default:
LOG_ERROR( "jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
jtag_state_name(cmd_queue_cur_state) );
jtag_error = ERROR_JTAG_NOT_STABLE_STATE;
return;
}
retval=interface_jtag_add_clocks(num_cycles);
if (retval!=ERROR_OK)
jtag_error=retval;
if( num_cycles > 0 )
{
jtag_prelude1();
retval=interface_jtag_add_clocks(num_cycles);
if (retval!=ERROR_OK)
jtag_error=retval;
}
}
void jtag_add_reset(int req_tlr_or_trst, int req_srst)
@@ -1287,7 +1307,7 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer)
if (cmd->fields[i].out_value)
{
#ifdef _DEBUG_JTAG_IO_
char* char_buf = buf_to_str(cmd->fields[i].out_value, (cmd->fields[i].num_bits > 64) ? 64 : cmd->fields[i].num_bits, 16);
char* char_buf = buf_to_str(cmd->fields[i].out_value, (cmd->fields[i].num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : cmd->fields[i].num_bits, 16);
#endif
buf_set_buf(cmd->fields[i].out_value, 0, *buffer, bit_count, cmd->fields[i].num_bits);
#ifdef _DEBUG_JTAG_IO_
@@ -1297,9 +1317,6 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer)
}
bit_count += cmd->fields[i].num_bits;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("bit_count totalling: %i", bit_count );
#endif
}
return bit_count;
@@ -1325,7 +1342,7 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
u8 *captured = buf_set_buf(buffer, bit_count, malloc(CEIL(num_bits, 8)), 0, num_bits);
#ifdef _DEBUG_JTAG_IO_
char *char_buf = buf_to_str(captured, (num_bits > 64) ? 64 : num_bits, 16);
char *char_buf = buf_to_str(captured, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
LOG_DEBUG("fields[%i].in_value[%i]: 0x%s", i, num_bits, char_buf);
free(char_buf);
#endif
@@ -1391,13 +1408,13 @@ int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
jtag_tap_name(field->tap));
if (compare_failed)
{
char *captured_char = buf_to_str(captured, (num_bits > 64) ? 64 : num_bits, 16);
char *in_check_value_char = buf_to_str(field->in_check_value, (num_bits > 64) ? 64 : num_bits, 16);
char *captured_char = buf_to_str(captured, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
char *in_check_value_char = buf_to_str(field->in_check_value, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
if (field->in_check_mask)
{
char *in_check_mask_char;
in_check_mask_char = buf_to_str(field->in_check_mask, (num_bits > 64) ? 64 : num_bits, 16);
in_check_mask_char = buf_to_str(field->in_check_mask, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
LOG_WARNING("value captured during scan didn't pass the requested check:");
LOG_WARNING("captured: 0x%s check_value: 0x%s check_mask: 0x%s",
captured_char, in_check_value_char, in_check_mask_char);

View File

@@ -34,6 +34,11 @@
#define _DEBUG_JTAG_IO_
#endif
#ifndef DEBUG_JTAG_IOZ
#define DEBUG_JTAG_IOZ 64
#endif
/* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf
*/
typedef enum tap_state
@@ -499,12 +504,14 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e);
* JTAG subsystem uses codes between -100 and -199 */
#define ERROR_JTAG_INIT_FAILED (-100)
#define ERROR_JTAG_INVALID_INTERFACE (-101)
#define ERROR_JTAG_INVALID_INTERFACE (-101)
#define ERROR_JTAG_NOT_IMPLEMENTED (-102)
#define ERROR_JTAG_TRST_ASSERTED (-103)
#define ERROR_JTAG_TRST_ASSERTED (-103)
#define ERROR_JTAG_QUEUE_FAILED (-104)
#define ERROR_JTAG_NOT_STABLE_STATE (-105)
#define ERROR_JTAG_DEVICE_ERROR (-107)
/* this allows JTAG devices to implement the entire jtag_xxx() layer in hw/sw */
#ifdef HAVE_JTAG_MINIDRIVER_H
/* Here a #define MINIDRIVER() and an inline version of hw fifo interface_jtag_add_dr_out can be defined */