+ /* expected in stream:
+ XWAITSTATE <u8 wait_state> <u8 end_state> <u32 clock_count> <u32 usecs>
+ */
+
+ u8 clock_buf[4];
+ u8 usecs_buf[4];
+ u8 wait;
+ u8 end;
+ tap_state_t wait_state;
+ tap_state_t end_state;
+ int clock_count;
+ int usecs;
+
+ if ( read(xsvf_fd, &wait, 1) < 0
+ || read(xsvf_fd, &end, 1) < 0
+ || read(xsvf_fd, clock_buf, 4) < 0
+ || read(xsvf_fd, usecs_buf, 4) < 0 )
+ {
+ do_abort = 1;
+ break;
+ }
+
+ wait_state = xsvf_to_tap( wait );
+ end_state = xsvf_to_tap( end );
+
+ clock_count = be_to_h_u32(clock_buf);
+ usecs = be_to_h_u32(usecs_buf);
+
+ LOG_DEBUG("XWAITSTATE %s %s clocks:%i usecs:%i",
+ jtag_state_name(wait_state),
+ jtag_state_name(end_state),
+ clock_count, usecs);
+
+ /* the following states are 'stable', meaning that they have a transition
+ * in the state diagram back to themselves. This is necessary because we will
+ * be issuing a number of clocks in this state. This set of allowed states is also
+ * determined by the SVF RUNTEST command's allowed states.
+ */
+ if (wait_state != TAP_IRPAUSE && wait_state != TAP_DRPAUSE && wait_state != TAP_RESET && wait_state != TAP_IDLE)
+ {
+ LOG_ERROR("illegal XWAITSTATE wait_state: \"%s\"", jtag_state_name( wait_state ));
+ unsupported = 1;
+ }
+
+ xsvf_add_statemove( wait_state );
+
+ jtag_add_clocks( clock_count );
+
+ jtag_add_sleep( usecs );
+
+ xsvf_add_statemove( end_state );
+ }
+ break;
+
+ case LCOUNT:
+ {
+ /* expected in stream:
+ LCOUNT <u32 loop_count>
+ */
+ u8 count_buf[4];
+
+ if ( read(xsvf_fd, count_buf, 4) < 0 )
+ {
+ do_abort = 1;
+ break;
+ }
+
+ loop_count = be_to_h_u32(count_buf);
+ LOG_DEBUG("LCOUNT %d", loop_count);