diff --git a/jtag/ChangeLog b/jtag/ChangeLog index c0681339..2ea1ddbe 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,5 +1,10 @@ 2008-12-21 Kolja Waschk + * src/tap/cable/ft2232.c, src/tap/cable/cmd_xfer.c, + src/tap/cable/cmd_xfer.h: limit maximum number of bytes queued + into one cmd buffer. Should fix problems with high clocks count for + SVF runtest execution (Bug 2456024 - FTD2XX fails with certain SVF file) + * configure.ac, src/tap/parport/direct.c: added detection of InpOut32 library and support for using it for I/O port access even under Vista diff --git a/jtag/src/tap/cable/cmd_xfer.c b/jtag/src/tap/cable/cmd_xfer.c index 756284d5..91006d5d 100644 --- a/jtag/src/tap/cable/cmd_xfer.c +++ b/jtag/src/tap/cable/cmd_xfer.c @@ -61,6 +61,38 @@ extend_cmd_buffer( cx_cmd_t *cmd ) } +/***************************************************************************** + * cx_cmd_space( cmd, max_len ) + * + * Return the difference between actually allocated bytes in the buffer of + * the current last command and max_len. If there are already more bytes + * allocated than max_len, this function will return zero. + * + * cmd : pointer to cx_cmd_t struct + * max_len : upper limit for the space to allocate + * + * Return value: + * 0 : No space left + * >0: Number of bytes left + * + ****************************************************************************/ +int +cx_cmd_space( cx_cmd_root_t *cmd_root, int max_len ) +{ + int n; + cx_cmd_t *cmd = cmd_root->last; + + if (!cmd) + return max_len; + + n = max_len - cmd->buf_pos; + if (n < 0) + return 0; + + return n; +} + + /***************************************************************************** * cx_cmd_push( cmd, d ) * diff --git a/jtag/src/tap/cable/cmd_xfer.h b/jtag/src/tap/cable/cmd_xfer.h index c10c2b2a..20b96ec6 100644 --- a/jtag/src/tap/cable/cmd_xfer.h +++ b/jtag/src/tap/cable/cmd_xfer.h @@ -47,6 +47,7 @@ struct cx_cmd_root { }; typedef struct cx_cmd_root cx_cmd_root_t; +int cx_cmd_space( cx_cmd_root_t *cmd_root, int max_len ); int cx_cmd_push( cx_cmd_root_t *cmd_root, uint8_t d); cx_cmd_t *cx_cmd_dequeue( cx_cmd_root_t *cmd_root ); void cx_cmd_free( cx_cmd_t *cmd ); diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index cae8e4f9..e2630da6 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -931,6 +931,12 @@ ft2232_clock_schedule( cable_t *cable, int tms, int tdi, int n ) cx_cmd_queue( cmd_root, 0 ); while (n > 0) { + if (cx_cmd_space( cmd_root, 4096 ) < 3) + { + cx_xfer( cmd_root, &imm_cmd, cable, COMPLETELY ); + cx_cmd_queue( cmd_root, 0 ); + } + /* Clock Data to TMS/CS Pin (no Read) */ cx_cmd_push( cmd_root, MPSSE_WRITE_TMS | MPSSE_LSB | MPSSE_BITMODE | MPSSE_WRITE_NEG );