int usb_err;
int i;
- LOG_DEBUG(": %d/%d", command_buffer_size, reply_buffer_size);
+ LOG_DEBUG("%d/%d", command_buffer_size, reply_buffer_size);
usb_err = usb_bulk_write(
pHDev_param,
if (ep2_buffer[0] & 0x01) break;
if (!--i) {
- LOG_ERROR("%s, %d: too many retries waiting for DTC status",
- __FILE__, __LINE__
- );
+ LOG_ERROR("too many retries waiting for DTC status");
return(-ETIMEDOUT);
}
}
);
if (usb_err < (int)sizeof(ep2_buffer)) {
- LOG_ERROR("%s, %d: Read of endpoint 2 returned %d",
- __FILE__, __LINE__, usb_err
+ LOG_ERROR("Read of endpoint 2 returned %d, expected %d",
+ usb_err, reply_buffer_size
);
return(usb_err);
}
uint8_t dtc_mask, tdo_mask;
uint8_t reply_buffer[USB_EP2IN_SIZE];
+ assert((dtc_queue.rq_head != 0) == (dtc_queue.reply_index > 0));
+ assert(dtc_queue.cmd_index < USB_EP2BANK_SIZE);
+ assert(dtc_queue.reply_index <= USB_EP2IN_SIZE);
+
retval = ERROR_OK;
if (dtc_queue.cmd_index < 1) return(retval);
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP;
- /* run the cmd */
- if (dtc_queue.rq_head == NULL) {
- usb_err = dtc_run_download(pHDev,
- dtc_queue.cmd_buffer, dtc_queue.cmd_index,
- NULL, 0
- );
- if (usb_err < 0) {
- LOG_ERROR("dtc_run_download: %s", usb_strerror());
- exit(1);
- }
- } else {
- usb_err = dtc_run_download(pHDev,
- dtc_queue.cmd_buffer, dtc_queue.cmd_index,
- reply_buffer, dtc_queue.reply_index
- );
- if (usb_err < 0) {
- LOG_ERROR("dtc_run_download: %s", usb_strerror());
- exit(1);
- }
+ usb_err = dtc_run_download(pHDev,
+ dtc_queue.cmd_buffer, dtc_queue.cmd_index,
+ reply_buffer, dtc_queue.reply_index
+ );
+ if (usb_err < 0) {
+ LOG_ERROR("dtc_run_download: %s", usb_strerror());
+ exit(1);
+ }
+ if (dtc_queue.rq_head != NULL) {
/* process the reply, which empties the reply queue and frees its entries */
dtc_p = reply_buffer;
return(retval);
}
-
-
static
int
tap_state_queue_init(void) {
LOG_ERROR("enqueuing DTC reply entry: %s", strerror(errno));
exit(1);
}
+ dtc_queue.reply_index += (chunk_bits + 7) / 8;
tdi_bit_offset += chunk_bits;
}
dtc_mask >>= 1;
if (dtc_mask == 0) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x;
- dtc_queue.reply_index++;
x = 0;
dtc_mask = 1 << (8 - 1);
}
exit(1);
}
+ dtc_queue.reply_index++;
+
tdi_bit_offset += extra_bits;
if (type == SCAN_IN) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x;
}
-
- dtc_queue.reply_index++;
}
/* Schedule the last bit into the DTC command buffer */
exit(1);
}
+ dtc_queue.reply_index++;
+
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(1, (*tdi_p & tdi_mask), 1);
-
- dtc_queue.reply_index++;
}
/* Move to pause state */
}
if (dtc_start_download() < 0) {
- LOG_ERROR("%s, %d: starting DTC: %s",
- __FILE__, __LINE__,
- usb_strerror()
- );
+ LOG_ERROR("starting DTC: %s", usb_strerror());
exit(1);
}