#include "interface.h"
-bitq_interface_t* bitq_interface; /* low level bit queue interface */
+struct bitq_interface* bitq_interface; /* low level bit queue interface */
-static bitq_state_t bitq_in_state; /* state of input queue */
+/* state of input queue */
+struct bitq_state {
+ struct jtag_command *cmd; /* command currently processed */
+ int field_idx; /* index of field currently being processed */
+ int bit_pos; /* position of bit curently being processed */
+ int status; /* processing status */
+};
+static struct bitq_state bitq_in_state;
static uint8_t* bitq_in_buffer; /* buffer dynamically reallocated as needed */
static int bitq_in_bufsize = 32; /* min. buffer size */
static int in_idx; /* index of byte being scanned */
static uint8_t in_mask; /* mask of next bit to be scanned */
- scan_field_t* field;
+ struct scan_field* field;
int tdo;
/* loop through the queue */
bitq_in_bufsize *= 2;
}
/* if necessary, allocate buffer and check for malloc error */
- if (bitq_in_buffer == NULL && ( bitq_in_buffer = malloc(bitq_in_bufsize) ) == NULL)
+ if (bitq_in_buffer == NULL && (bitq_in_buffer = malloc(bitq_in_bufsize)) == NULL)
{
LOG_ERROR("malloc error");
exit(-1);
/* field scanning */
while (bitq_in_state.bit_pos < field->num_bits)
{
- if ( ( tdo = bitq_interface->in() ) < 0 )
+ if ((tdo = bitq_interface->in()) < 0)
{
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("bitq in EOF");
{
bitq_interface->out(tms, tdi, tdo_req);
/* check and process the input queue */
- if ( bitq_interface->in_rdy() )
+ if (bitq_interface->in_rdy())
bitq_in_proc();
}
}
-void bitq_path_move(pathmove_command_t* cmd)
+void bitq_path_move(struct pathmove_command* cmd)
{
int i;
bitq_io(1, 0, 0);
else
{
- LOG_ERROR( "BUG: %s -> %s isn't a valid TAP transition", tap_state_name(
- tap_get_state() ), tap_state_name(cmd->path[i]) );
+ LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(
+ tap_get_state()), tap_state_name(cmd->path[i]));
exit(-1);
}
tap_set_state(cmd->path[i]);
}
- tap_set_end_state( tap_get_state() );
+ tap_set_end_state(tap_get_state());
}
bitq_io(0, 0, 0);
/* finish in end_state */
- if ( tap_get_state() != tap_get_end_state() )
- bitq_state_move( tap_get_end_state() );
+ if (tap_get_state() != tap_get_end_state())
+ bitq_state_move(tap_get_end_state());
}
-void bitq_scan_field(scan_field_t* field, int pause)
+void bitq_scan_field(struct scan_field* field, int pause)
{
int bit_cnt;
int tdo_req;
out_ptr = field->out_value;
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
{
- bitq_io(0, ( (*out_ptr) & out_mask ) != 0, tdo_req);
+ bitq_io(0, ((*out_ptr) & out_mask) != 0, tdo_req);
if (out_mask == 0x80)
{
out_mask = 0x01;
out_mask <<= 1;
}
- bitq_io(pause, ( (*out_ptr) & out_mask ) != 0, tdo_req);
+ bitq_io(pause, ((*out_ptr) & out_mask) != 0, tdo_req);
}
if (pause)
}
-void bitq_scan(scan_command_t* cmd)
+void bitq_scan(struct scan_command* cmd)
{
int i;
int bitq_execute_queue(void)
{
- jtag_command_t* cmd = jtag_command_queue; /* currently processed command */
+ struct jtag_command* cmd = jtag_command_queue; /* currently processed command */
bitq_in_state.cmd = jtag_command_queue;
bitq_in_state.field_idx = 0;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
- if ( (cmd->cmd.reset->trst == 1) || ( cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST) ) )
+ if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
{
tap_set_state(TAP_RESET);
}
bitq_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
- if ( bitq_interface->in_rdy() )
+ if (bitq_interface->in_rdy())
bitq_in_proc();
break;
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
bitq_end_state(cmd->cmd.statemove->end_state);
- bitq_state_move( tap_get_end_state() ); /* uncoditional TAP move */
+ bitq_state_move(tap_get_end_state()); /* uncoditional TAP move */
break;
case JTAG_PATHMOVE:
#endif
bitq_end_state(cmd->cmd.scan->end_state);
bitq_scan(cmd->cmd.scan);
- if ( tap_get_state() != tap_get_end_state() )
- bitq_state_move( tap_get_end_state() );
+ if (tap_get_state() != tap_get_end_state())
+ bitq_state_move(tap_get_end_state());
break;
case JTAG_SLEEP:
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
bitq_interface->sleep(cmd->cmd.sleep->us);
- if ( bitq_interface->in_rdy() )
+ if (bitq_interface->in_rdy())
bitq_in_proc();
break;