- x = *dtc_p++;
- if ((
- rq_p->scan.type == SCAN_IN
-) && (
- rq_p->scan.offset != rq_p->scan.size - 1
-)) {
- /* extra bits were sent as a full byte with padding on the end */
+ if (dtc_queue.rq_head != NULL) {
+ /* process the reply, which empties the reply queue and frees its entries */
+ dtc_p = reply_buffer;
+
+ /* The rigamarole with the masks and doing it bit-by-bit is due to the fact that the
+ *scan buffer is LSb-first and the DTC code is MSb-first for hardware reasons. It
+ *was that or craft a function to do the reversal, and that wouldn't work with
+ *bit-stuffing (supplying extra bits to use mostly byte operations), or any other
+ *scheme which would throw the byte alignment off. */
+
+ for (
+ rq_p = dtc_queue.rq_head;
+ rq_p != NULL;
+ rq_p = rq_next
+ ) {
+ tdo_p = rq_p->scan.buffer + (rq_p->scan.offset / 8);
+ tdo_mask = 1 << (rq_p->scan.offset % 8);
+
+
+ bit_cnt = rq_p->scan.length;
+ if (bit_cnt >= 8) {
+ /* bytes */
+
+ dtc_mask = 1 << (8 - 1);
+
+ for (
+ ;
+ bit_cnt;
+ bit_cnt--
+ ) {
+ if (*dtc_p & dtc_mask)
+ *tdo_p |= tdo_mask;
+ else
+ *tdo_p &= ~tdo_mask;
+
+ dtc_mask >>= 1;
+ if (dtc_mask == 0) {
+ dtc_p++;