jtag/drivers: OpenJTAG standard variant perf improvement

Calculate exact size of response expected from OpenJTAG device so that
openjtag_buf_read_standard doesn't spend 5 retry cycles waiting for
data that isn't coming.

Change-Id: Icd010d1fa4453d6592a1f9aed93fb1f01e0a19da
Signed-off-by: N S <nlshipp@yahoo.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8101
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
N S 2023-01-22 21:34:16 -08:00 committed by Antonio Borneo
parent 81a50d3e90
commit 7295ddc15c
1 changed files with 12 additions and 1 deletions

View File

@ -530,9 +530,20 @@ static int openjtag_quit(void)
static void openjtag_write_tap_buffer(void)
{
uint32_t written;
uint32_t rx_expected = 0;
/* calculate expected number of return bytes */
for (int tx_offs = 0; tx_offs < usb_tx_buf_offs; tx_offs++) {
if ((usb_tx_buf[tx_offs] & 0x0F) == 6) {
rx_expected++;
tx_offs++;
} else if ((usb_tx_buf[tx_offs] & 0x0F) == 2) {
rx_expected++;
}
}
openjtag_buf_write(usb_tx_buf, usb_tx_buf_offs, &written);
openjtag_buf_read(usb_rx_buf, usb_tx_buf_offs, &usb_rx_buf_len);
openjtag_buf_read(usb_rx_buf, rx_expected, &usb_rx_buf_len);
usb_tx_buf_offs = 0;
}