- Cable driver helper API courtesy of Dick Hollenbeck <dick@softplc.com>

- Formatting changes from uncrustify


git-svn-id: svn://svn.berlios.de/openocd/trunk@1366 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
kc8apf 2009-02-03 05:59:17 +00:00
parent 6c0e48248a
commit ab9dfffdb5
21 changed files with 1863 additions and 1516 deletions

View File

@ -111,7 +111,7 @@ int str9xpec_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
int str9xpec_set_instr(jtag_tap_t *tap, u32 new_instr, enum tap_state end_state)
int str9xpec_set_instr(jtag_tap_t *tap, u32 new_instr, tap_state_t end_state)
{
if( tap == NULL ){
return ERROR_TARGET_INVALID;

View File

@ -193,7 +193,7 @@ int ceil_f_to_u32(float x)
char* buf_to_str(const u8 *buf, int buf_len, int radix)
{
const char *DIGITS = "0123456789abcdef";
const char *DIGITS = "0123456789ABCDEF";
float factor;
char *str;
int str_len;

View File

@ -109,6 +109,7 @@ u8 amt_jtagaccel_tap_move[6][6][2] =
{{0x1f, 0x00}, {0x0c, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x08, 0x00}, {0x00, 0x00}}, /* IRPAUSE */
};
jtag_interface_t amt_jtagaccel_interface =
{
.name = "amt_jtagaccel",
@ -157,8 +158,8 @@ int amt_jtagaccel_speed(int speed)
void amt_jtagaccel_end_state(int state)
{
if (tap_move_map[state] != -1)
end_state = state;
if (tap_is_state_stable(state))
tap_set_end_state(state);
else
{
LOG_ERROR("BUG: %i is not a valid end state", state);
@ -187,8 +188,11 @@ void amt_jtagaccel_state_move(void)
u8 aw_scan_tms_5;
u8 tms_scan[2];
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][0];
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][1];
tap_state_t cur_state = tap_get_state();
tap_state_t end_state = tap_get_end_state();
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_ndx(cur_state)][tap_move_ndx(end_state)][0];
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(cur_state)][tap_move_ndx(end_state)][1];
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
AMT_AW(aw_scan_tms_5);
@ -203,7 +207,7 @@ void amt_jtagaccel_state_move(void)
amt_wait_scan_busy();
}
cur_state = end_state;
tap_set_state(end_state);
}
void amt_jtagaccel_runtest(int num_cycles)
@ -212,10 +216,10 @@ void amt_jtagaccel_runtest(int num_cycles)
u8 aw_scan_tms_5;
u8 aw_scan_tms_1to4;
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
amt_jtagaccel_end_state(TAP_IDLE);
amt_jtagaccel_state_move();
@ -235,7 +239,7 @@ void amt_jtagaccel_runtest(int num_cycles)
}
amt_jtagaccel_end_state(saved_end_state);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
amt_jtagaccel_state_move();
}
@ -243,7 +247,7 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
{
int bits_left = scan_size;
int bit_count = 0;
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
u8 aw_tdi_option;
u8 dw_tdi_scan;
u8 dr_tdo;
@ -297,8 +301,8 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
bits_left -= 8;
}
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][0];
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][1];
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][0];
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][1];
aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (buf_get_u32(buffer, bit_count, 1) << 5);
AMT_AW(aw_tms_scan);
if (jtag_speed > 3 || rtck_enabled)
@ -318,7 +322,7 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
if (jtag_speed > 3 || rtck_enabled)
amt_wait_scan_busy();
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
int amt_jtagaccel_execute_queue(void)
@ -351,7 +355,7 @@ int amt_jtagaccel_execute_queue(void)
#endif
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;

View File

@ -74,13 +74,12 @@ bitbang_interface_t *bitbang_interface;
int bitbang_execute_queue(void);
/* The bitbang driver leaves the TCK 0 when in idle */
void bitbang_end_state(enum tap_state state)
void bitbang_end_state(tap_state_t state)
{
if (tap_move_map[state] != -1)
end_state = state;
if (tap_is_state_stable(state))
tap_set_end_state(state);
else
{
LOG_ERROR("BUG: %i is not a valid end state", state);
@ -88,10 +87,10 @@ void bitbang_end_state(enum tap_state state)
}
}
void bitbang_state_move(void) {
void bitbang_state_move(void)
{
int i=0, tms=0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
for (i = 0; i < 7; i++)
{
@ -101,7 +100,7 @@ void bitbang_state_move(void) {
}
bitbang_interface->write(CLOCK_IDLE(), tms, 0);
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
void bitbang_path_move(pathmove_command_t *cmd)
@ -113,41 +112,41 @@ void bitbang_path_move(pathmove_command_t *cmd)
state_count = 0;
while (num_states)
{
if (tap_transitions[cur_state].low == cmd->path[state_count])
if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
{
tms = 0;
}
else if (tap_transitions[cur_state].high == cmd->path[state_count])
else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
{
tms = 1;
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(cmd->path[state_count]));
exit(-1);
}
bitbang_interface->write(0, tms, 0);
bitbang_interface->write(1, tms, 0);
cur_state = cmd->path[state_count];
tap_set_state(cmd->path[state_count]);
state_count++;
num_states--;
}
bitbang_interface->write(CLOCK_IDLE(), tms, 0);
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
void bitbang_runtest(int num_cycles)
{
int i;
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
bitbang_end_state(TAP_IDLE);
bitbang_state_move();
@ -163,14 +162,14 @@ void bitbang_runtest(int num_cycles)
/* finish in end_state */
bitbang_end_state(saved_end_state);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
bitbang_state_move();
}
static void bitbang_stableclocks(int num_cycles)
{
int tms = (cur_state == TAP_RESET ? 1 : 0);
int tms = (tap_get_state() == TAP_RESET ? 1 : 0);
int i;
/* send num_cycles clocks onto the cable */
@ -185,10 +184,10 @@ static void bitbang_stableclocks(int num_cycles)
void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
{
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
int bit_cnt;
if (!((!ir_scan && (cur_state == TAP_DRSHIFT)) || (ir_scan && (cur_state == TAP_IRSHIFT))))
if (!((!ir_scan && (tap_get_state() == TAP_DRSHIFT)) || (ir_scan && (tap_get_state() == TAP_IRSHIFT))))
{
if (ir_scan)
bitbang_end_state(TAP_IRSHIFT);
@ -241,11 +240,11 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
bitbang_interface->write(CLOCK_IDLE(), 0, 0);
if (ir_scan)
cur_state = TAP_IRPAUSE;
tap_set_state(TAP_IRPAUSE);
else
cur_state = TAP_DRPAUSE;
tap_set_state(TAP_DRPAUSE);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
bitbang_state_move();
}
@ -277,7 +276,7 @@ int bitbang_execute_queue(void)
{
case JTAG_END_STATE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("end_state: %s", jtag_state_name(cmd->cmd.end_state->end_state) );
LOG_DEBUG("end_state: %s", tap_state_name(cmd->cmd.end_state->end_state) );
#endif
if (cmd->cmd.end_state->end_state != -1)
bitbang_end_state(cmd->cmd.end_state->end_state);
@ -288,13 +287,13 @@ int bitbang_execute_queue(void)
#endif
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
bitbang_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, jtag_state_name(cmd->cmd.runtest->end_state) );
LOG_DEBUG("runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(cmd->cmd.runtest->end_state) );
#endif
if (cmd->cmd.runtest->end_state != -1)
bitbang_end_state(cmd->cmd.runtest->end_state);
@ -310,7 +309,7 @@ int bitbang_execute_queue(void)
case JTAG_STATEMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %s", jtag_state_name(cmd->cmd.statemove->end_state));
LOG_DEBUG("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state));
#endif
if (cmd->cmd.statemove->end_state != -1)
bitbang_end_state(cmd->cmd.statemove->end_state);
@ -319,13 +318,13 @@ int bitbang_execute_queue(void)
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %s", cmd->cmd.pathmove->num_states,
jtag_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
#endif
bitbang_path_move(cmd->cmd.pathmove);
break;
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", jtag_state_name(cmd->cmd.scan->end_state) );
LOG_DEBUG("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", tap_state_name(cmd->cmd.scan->end_state) );
#endif
if (cmd->cmd.scan->end_state != -1)
bitbang_end_state(cmd->cmd.scan->end_state);

View File

@ -57,34 +57,43 @@ void bitq_in_proc(void)
int tdo;
/* loop through the queue */
while (bitq_in_state.cmd) {
while (bitq_in_state.cmd)
{
/* only JTAG_SCAN command may return data */
if (bitq_in_state.cmd->type==JTAG_SCAN) {
if (bitq_in_state.cmd->type==JTAG_SCAN)
{
/* loop through the fields */
while (bitq_in_state.field_idx<bitq_in_state.cmd->cmd.scan->num_fields) {
while (bitq_in_state.field_idx<bitq_in_state.cmd->cmd.scan->num_fields)
{
field = &bitq_in_state.cmd->cmd.scan->fields[bitq_in_state.field_idx];
if ( field->in_value || field->in_handler) {
if (bitq_in_state.bit_pos==0) {
if (field->in_value || field->in_handler)
{
if (bitq_in_state.bit_pos==0)
{
/* initialize field scanning */
in_mask = 0x01;
in_idx = 0;
if (field->in_value) in_buff=field->in_value;
else {
if (field->in_value)
in_buff = field->in_value;
else
{
/* buffer reallocation needed? */
if (field->num_bits>bitq_in_bufsize*8) {
if (field->num_bits>bitq_in_bufsize * 8)
{
/* buffer previously allocated? */
if (bitq_in_buffer!=NULL) {
if (bitq_in_buffer!=NULL)
{
/* free it */
free(bitq_in_buffer);
bitq_in_buffer = NULL;
}
/* double the buffer size until it fits */
while (field->num_bits>bitq_in_bufsize*8) bitq_in_bufsize*=2;
while (field->num_bits>bitq_in_bufsize * 8)
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);
}
@ -93,112 +102,134 @@ void bitq_in_proc(void)
}
/* field scanning */
while (bitq_in_state.bit_pos<field->num_bits) {
if ((tdo=bitq_interface->in())<0) {
while (bitq_in_state.bit_pos<field->num_bits)
{
if ( ( tdo = bitq_interface->in() )<0 )
{
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("bitq in EOF");
#endif
return;
}
if (in_mask==0x01) in_buff[in_idx]=0;
if (tdo) in_buff[in_idx]|=in_mask;
if (in_mask==0x80) {
if (in_mask==0x01)
in_buff[in_idx] = 0;
if (tdo)
in_buff[in_idx] |= in_mask;
if (in_mask==0x80)
{
in_mask = 0x01;
in_idx++;
}
else in_mask<<=1;
else
in_mask <<= 1;
bitq_in_state.bit_pos++;
}
if (field->in_handler && bitq_in_state.status==ERROR_OK) {
if (field->in_handler && bitq_in_state.status==ERROR_OK)
{
bitq_in_state.status = (*field->in_handler)(in_buff, field->in_handler_priv, field);
}
}
bitq_in_state.field_idx++; /* advance to next field */
bitq_in_state.bit_pos = 0; /* start next field from the first bit */
}
}
bitq_in_state.cmd = bitq_in_state.cmd->next; /* advance to next command */
bitq_in_state.field_idx = 0; /* preselect first field */
}
}
void bitq_io(int tms, int tdi, int tdo_req)
{
bitq_interface->out(tms, tdi, tdo_req);
/* check and process the input queue */
if (bitq_interface->in_rdy()) bitq_in_proc();
if ( bitq_interface->in_rdy() )
bitq_in_proc();
}
void bitq_end_state(enum tap_state state)
void bitq_end_state(tap_state_t state)
{
if (state==-1)
return;
if (!tap_is_state_stable(state))
{
if (state==-1) return;
if (tap_move_map[state]==-1) {
LOG_ERROR("BUG: %i is not a valid end state", state);
exit(-1);
}
end_state = state;
tap_set_end_state(state);
}
void bitq_state_move(enum tap_state new_state)
void bitq_state_move(tap_state_t new_state)
{
int i = 0;
u8 tms_scan;
if (tap_move_map[cur_state]==-1 || tap_move_map[new_state]==-1) {
if (!tap_is_state_stable(tap_get_state()) || !tap_is_state_stable(new_state))
{
LOG_ERROR("TAP move from or to unstable state");
exit(-1);
}
tms_scan=TAP_MOVE(cur_state, new_state);
tms_scan = tap_get_tms_path(tap_get_state(), new_state);
for (i=0; i<7; i++) {
for (i = 0; i<7; i++)
{
bitq_io(tms_scan & 1, 0, 0);
tms_scan >>= 1;
}
cur_state = new_state;
tap_set_state(new_state);
}
void bitq_path_move(pathmove_command_t* cmd)
{
int i;
for (i=0; i<=cmd->num_states; i++) {
if (tap_transitions[cur_state].low == cmd->path[i])
for (i = 0; i<=cmd->num_states; i++)
{
if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[i])
bitq_io(0, 0, 0);
else if (tap_transitions[cur_state].high == cmd->path[i])
else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[i])
bitq_io(1, 0, 0);
else {
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[i]));
else
{
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);
}
cur_state = cmd->path[i];
tap_set_state(cmd->path[i]);
}
end_state = cur_state;
tap_set_end_state( tap_get_state() );
}
void bitq_runtest(int num_cycles)
{
int i;
/* only do a state_move when we're not already in IDLE */
if (cur_state != TAP_IDLE) bitq_state_move(TAP_IDLE);
if (tap_get_state() != TAP_IDLE)
bitq_state_move(TAP_IDLE);
/* execute num_cycles */
for (i = 0; i < num_cycles; i++)
bitq_io(0, 0, 0);
/* finish in end_state */
if (cur_state != end_state) bitq_state_move(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)
{
int bit_cnt;
@ -207,49 +238,66 @@ void bitq_scan_field(scan_field_t *field, int pause)
u8* out_ptr;
u8 out_mask;
if ( field->in_value || field->in_handler) tdo_req=1;
else tdo_req=0;
if (field->in_value || field->in_handler)
tdo_req = 1;
else
tdo_req = 0;
if (field->out_value==NULL) {
if (field->out_value==NULL)
{
/* just send zeros and request data from TDO */
for (bit_cnt = field->num_bits; bit_cnt>1; bit_cnt--)
bitq_io(0, 0, tdo_req);
bitq_io(pause, 0, tdo_req);
}
else {
else
{
/* send data, and optionally request TDO */
out_mask = 0x01;
out_ptr = field->out_value;
for (bit_cnt=field->num_bits; bit_cnt>1; bit_cnt--) {
for (bit_cnt = field->num_bits; bit_cnt>1; bit_cnt--)
{
bitq_io(0, ( (*out_ptr) & out_mask )!=0, tdo_req);
if (out_mask==0x80) {
if (out_mask==0x80)
{
out_mask = 0x01;
out_ptr++;
}
else out_mask<<=1;
else
out_mask <<= 1;
}
bitq_io(pause, ( (*out_ptr) & out_mask )!=0, tdo_req);
}
if (pause) {
if (pause)
{
bitq_io(0, 0, 0);
if (cur_state==TAP_IRSHIFT) cur_state=TAP_IRPAUSE;
else if (cur_state==TAP_DRSHIFT) cur_state=TAP_DRPAUSE;
if (tap_get_state()==TAP_IRSHIFT)
tap_set_state(TAP_IRPAUSE);
else if (tap_get_state()==TAP_DRSHIFT)
tap_set_state(TAP_DRPAUSE);
}
}
void bitq_scan(scan_command_t* cmd)
{
int i;
if (cmd->ir_scan) bitq_state_move(TAP_IRSHIFT);
else bitq_state_move(TAP_DRSHIFT);
if (cmd->ir_scan)
bitq_state_move(TAP_IRSHIFT);
else
bitq_state_move(TAP_DRSHIFT);
for (i = 0; i < cmd->num_fields - 1; i++)
bitq_scan_field(&cmd->fields[i], 0);
bitq_scan_field(&cmd->fields[i], 1);
}
int bitq_execute_queue(void)
{
jtag_command_t* cmd = jtag_command_queue; /* currently processed command */
@ -259,10 +307,10 @@ int bitq_execute_queue(void)
bitq_in_state.bit_pos = 0;
bitq_in_state.status = ERROR_OK;
while (cmd) {
switch (cmd->type) {
while (cmd)
{
switch (cmd->type)
{
case JTAG_END_STATE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state);
@ -276,10 +324,11 @@ int bitq_execute_queue(void)
#endif
if ( (cmd->cmd.reset->trst == 1) || ( cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST) ) )
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
bitq_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
if (bitq_interface->in_rdy()) bitq_in_proc();
if ( bitq_interface->in_rdy() )
bitq_in_proc();
break;
case JTAG_RUNTEST:
@ -295,12 +344,13 @@ int bitq_execute_queue(void)
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
bitq_end_state(cmd->cmd.statemove->end_state);
bitq_state_move(end_state); /* uncoditional TAP move */
bitq_state_move( tap_get_end_state() ); /* uncoditional TAP move */
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
#endif
bitq_path_move(cmd->cmd.pathmove);
break;
@ -308,12 +358,15 @@ int bitq_execute_queue(void)
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
if (cmd->cmd.scan->ir_scan) LOG_DEBUG("scan ir");
else LOG_DEBUG("scan dr");
if (cmd->cmd.scan->ir_scan)
LOG_DEBUG("scan ir");
else
LOG_DEBUG("scan dr");
#endif
bitq_end_state(cmd->cmd.scan->end_state);
bitq_scan(cmd->cmd.scan);
if (cur_state != end_state) bitq_state_move(end_state);
if ( tap_get_state() != tap_get_end_state() )
bitq_state_move( tap_get_end_state() );
break;
case JTAG_SLEEP:
@ -321,7 +374,8 @@ int bitq_execute_queue(void)
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
bitq_interface->sleep(cmd->cmd.sleep->us);
if (bitq_interface->in_rdy()) bitq_in_proc();
if ( bitq_interface->in_rdy() )
bitq_in_proc();
break;
default:
@ -335,11 +389,13 @@ int bitq_execute_queue(void)
bitq_interface->flush();
bitq_in_proc();
if (bitq_in_state.cmd) {
if (bitq_in_state.cmd)
{
LOG_ERROR("missing data from bitq interface");
return ERROR_JTAG_QUEUE_FAILED;
}
if (bitq_interface->in()>=0) {
if (bitq_interface->in()>=0)
{
LOG_ERROR("extra data from bitq interface");
return ERROR_JTAG_QUEUE_FAILED;
}
@ -347,6 +403,7 @@ int bitq_execute_queue(void)
return bitq_in_state.status;
}
void bitq_cleanup(void)
{
if (bitq_in_buffer!=NULL)

View File

@ -34,9 +34,6 @@ static int dummy_clock; /* edge detector */
static int clock_count; /* count clocks in any stable state, only stable states */
static tap_state_t tap_state_transition(tap_state_t cur_state, int tms);
static u32 dummy_data;
@ -105,7 +102,7 @@ void dummy_write(int tck, int tms, int tdi)
clock_count = 0;
}
LOG_DEBUG("dummy_tap: %s", jtag_state_name(dummy_state) );
LOG_DEBUG("dummy_tap: %s", tap_state_name(dummy_state) );
#if defined(DEBUG)
if(dummy_state == TAP_DRCAPTURE)
@ -131,7 +128,7 @@ void dummy_reset(int trst, int srst)
if (trst || (srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
dummy_state = TAP_RESET;
LOG_DEBUG("reset to: %s", jtag_state_name(dummy_state) );
LOG_DEBUG("reset to: %s", tap_state_name(dummy_state) );
}
static int dummy_khz(int khz, int *jtag_speed)
@ -187,106 +184,3 @@ void dummy_led(int on)
{
}
/**
* Function tap_state_transition
* takes a current TAP state and returns the next state according to the tms value.
*
* Even though there is code to duplicate this elsewhere, we do it here a little
* differently just to get a second opinion, i.e. a verification, on state tracking
* in that other logic. Plus array lookups without index checking are no favorite thing.
* This is educational for developers new to TAP controllers.
*/
static tap_state_t tap_state_transition(tap_state_t cur_state, int tms)
{
tap_state_t new_state;
if (tms)
{
switch (cur_state)
{
case TAP_RESET:
new_state = cur_state;
break;
case TAP_IDLE:
case TAP_DRUPDATE:
case TAP_IRUPDATE:
new_state = TAP_DRSELECT;
break;
case TAP_DRSELECT:
new_state = TAP_IRSELECT;
break;
case TAP_DRCAPTURE:
case TAP_DRSHIFT:
new_state = TAP_DREXIT1;
break;
case TAP_DREXIT1:
case TAP_DREXIT2:
new_state = TAP_DRUPDATE;
break;
case TAP_DRPAUSE:
new_state = TAP_DREXIT2;
break;
case TAP_IRSELECT:
new_state = TAP_RESET;
break;
case TAP_IRCAPTURE:
case TAP_IRSHIFT:
new_state = TAP_IREXIT1;
break;
case TAP_IREXIT1:
case TAP_IREXIT2:
new_state = TAP_IRUPDATE;
break;
case TAP_IRPAUSE:
new_state = TAP_IREXIT2;
break;
default:
LOG_ERROR( "fatal: invalid argument cur_state=%d", cur_state );
exit(1);
break;
}
}
else
{
switch (cur_state)
{
case TAP_RESET:
case TAP_IDLE:
case TAP_DRUPDATE:
case TAP_IRUPDATE:
new_state = TAP_IDLE;
break;
case TAP_DRSELECT:
new_state = TAP_DRCAPTURE;
break;
case TAP_DRCAPTURE:
case TAP_DRSHIFT:
case TAP_DREXIT2:
new_state = TAP_DRSHIFT;
break;
case TAP_DREXIT1:
case TAP_DRPAUSE:
new_state = TAP_DRPAUSE;
break;
case TAP_IRSELECT:
new_state = TAP_IRCAPTURE;
break;
case TAP_IRCAPTURE:
case TAP_IRSHIFT:
case TAP_IREXIT2:
new_state = TAP_IRSHIFT;
break;
case TAP_IREXIT1:
case TAP_IRPAUSE:
new_state = TAP_IRPAUSE;
break;
default:
LOG_ERROR( "fatal: invalid argument cur_state=%d", cur_state );
exit(1);
break;
}
}
return new_state;
}

View File

@ -20,6 +20,15 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* This code uses information contained in the MPSSE specification which was
* found here:
* http://www.ftdichip.com/Documents/AppNotes/AN2232C-01_MPSSE_Cmnd.pdf
* Hereafter this is called the "MPSSE Spec".
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -218,6 +227,7 @@ int ft2232_write(u8 *buf, int size, u32* bytes_written)
#endif
}
int ft2232_read(u8* buf, int size, u32* bytes_read)
{
#if BUILD_FT2232_FTD2XX == 1
@ -237,6 +247,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
}
*bytes_read += dw_bytes_read;
}
#elif BUILD_FT2232_LIBFTDI == 1
int retval;
int timeout = 100;
@ -252,6 +263,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
}
*bytes_read += retval;
}
#endif
if (*bytes_read < size)
@ -263,6 +275,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
return ERROR_OK;
}
int ft2232_speed(int speed)
{
u8 buf[3];
@ -283,6 +296,7 @@ int ft2232_speed(int speed)
return ERROR_OK;
}
int ft2232_speed_div(int speed, int* khz)
{
/* Take a look in the FT2232 manual,
@ -294,6 +308,7 @@ int ft2232_speed_div(int speed, int *khz)
return ERROR_OK;
}
int ft2232_khz(int khz, int* jtag_speed)
{
if (khz==0)
@ -301,6 +316,7 @@ int ft2232_khz(int khz, int *jtag_speed)
LOG_ERROR("RCLK not supported");
return ERROR_FAIL;
}
/* Take a look in the FT2232 manual,
* AN2232C-01 Command Processor for
* MPSSE and MCU Host Bus. Chapter 3.8
@ -333,6 +349,7 @@ int ft2232_khz(int khz, int *jtag_speed)
return ERROR_OK;
}
int ft2232_register_commands(struct command_context_s* cmd_ctx)
{
register_command(cmd_ctx, NULL, "ft2232_device_desc", ft2232_handle_device_desc_command,
@ -348,10 +365,11 @@ int ft2232_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
void ft2232_end_state(enum tap_state state)
void ft2232_end_state(tap_state_t state)
{
if (tap_move_map[state] != -1)
end_state = state;
if (tap_is_state_stable(state))
tap_set_end_state(state);
else
{
LOG_ERROR("BUG: %i is not a valid end state", state);
@ -359,6 +377,7 @@ void ft2232_end_state(enum tap_state state)
}
}
void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size)
{
int num_bytes = (scan_size + 7) / 8;
@ -380,9 +399,9 @@ void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size)
}
buffer[cur_byte] = ( buffer[cur_byte] | ( (BUFFER_READ & 0x02) << 6 ) ) >> (8 - bits_left);
}
void ft2232_debug_dump_buffer(void)
{
int i;
@ -403,6 +422,7 @@ void ft2232_debug_dump_buffer(void)
LOG_DEBUG("%s", line);
}
int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last)
{
jtag_command_t* cmd;
@ -459,15 +479,18 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last)
timeval_subtract(&d_inter2, &inter2, &start);
timeval_subtract(&d_end, &end, &start);
LOG_INFO("inter: %i.%06i, inter2: %i.%06i end: %i.%06i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec, d_inter2.tv_usec, d_end.tv_sec, d_end.tv_usec);
LOG_INFO("inter: %i.%06i, inter2: %i.%06i end: %i.%06i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec,
d_inter2.tv_usec, d_end.tv_sec,
d_end.tv_usec);
#endif
ft2232_buffer_size = bytes_read;
if (ft2232_expect_read != ft2232_buffer_size)
{
LOG_ERROR("ft2232_expect_read (%i) != ft2232_buffer_size (%i) (%i retries)", ft2232_expect_read, ft2232_buffer_size, 100 - timeout);
LOG_ERROR("ft2232_expect_read (%i) != ft2232_buffer_size (%i) (%i retries)", ft2232_expect_read,
ft2232_buffer_size,
100 - timeout);
ft2232_debug_dump_buffer();
exit(-1);
@ -504,9 +527,11 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last)
free(buffer);
}
break;
default:
break;
}
cmd = cmd->next;
}
@ -515,38 +540,40 @@ int ft2232_send_and_recv(jtag_command_t *first, jtag_command_t *last)
return retval;
}
void ft2232_add_pathmove(pathmove_command_t* cmd)
{
int num_states = cmd->num_states;
u8 tms_byte;
int state_count;
int state_count = 0;
state_count = 0;
while (num_states)
{
u8 tms_byte = 0; /* zero this on each MPSSE batch */
int bit_count = 0;
int num_states_batch = num_states > 7 ? 7 : num_states;
tms_byte = 0x0;
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* number of states remaining */
BUFFER_ADD = num_states_batch - 1;
while (num_states_batch--)
{
if (tap_transitions[cur_state].low == cmd->path[state_count])
if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
buf_set_u32(&tms_byte, bit_count++, 1, 0x0);
else if (tap_transitions[cur_state].high == cmd->path[state_count])
else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
LOG_ERROR( "BUG: %s -> %s isn't a valid TAP transition", tap_state_name(
tap_get_state() ), tap_state_name(cmd->path[state_count]) );
exit(-1);
}
cur_state = cmd->path[state_count];
tap_set_state(cmd->path[state_count]);
state_count++;
num_states--;
}
@ -554,9 +581,10 @@ void ft2232_add_pathmove(pathmove_command_t *cmd)
BUFFER_ADD = tms_byte;
}
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
void ft2232_add_scan(int ir_scan, enum scan_type type, u8* buffer, int scan_size)
{
int num_bytes = (scan_size + 7) / 8;
@ -564,22 +592,24 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size
int cur_byte = 0;
int last_bit;
if (!((!ir_scan && (cur_state == TAP_DRSHIFT)) || (ir_scan && (cur_state == TAP_IRSHIFT))))
if ( !( ( !ir_scan && (tap_get_state() == TAP_DRSHIFT) )
|| ( ir_scan && (tap_get_state() == TAP_IRSHIFT) ) ) )
{
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* scan 7 bit */
BUFFER_ADD = 0x6;
BUFFER_ADD = 0x6; /* scan 7 bits */
/* TMS data bits */
if (ir_scan)
{
BUFFER_ADD = TAP_MOVE(cur_state, TAP_IRSHIFT);
cur_state = TAP_IRSHIFT;
BUFFER_ADD = tap_get_tms_path(tap_get_state(), TAP_IRSHIFT);
tap_set_state(TAP_IRSHIFT);
}
else
{
BUFFER_ADD = TAP_MOVE(cur_state, TAP_DRSHIFT);
cur_state = TAP_DRSHIFT;
BUFFER_ADD = tap_get_tms_path(tap_get_state(), TAP_DRSHIFT);
tap_set_state(TAP_DRSHIFT);
}
/* LOG_DEBUG("added TMS scan (no read)"); */
}
@ -606,10 +636,12 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size
BUFFER_ADD = 0x28;
/* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
}
thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1);
num_bytes -= thisrun_bytes;
BUFFER_ADD = (thisrun_bytes - 1) & 0xff;
BUFFER_ADD = ( (thisrun_bytes - 1) >> 8 ) & 0xff;
if (type != SCAN_IN)
{
/* add complete bytes */
@ -658,8 +690,8 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size
BUFFER_ADD = buffer[cur_byte];
}
if ((ir_scan && (end_state == TAP_IRSHIFT)) ||
(!ir_scan && (end_state == TAP_DRSHIFT)))
if ( ( ir_scan && (tap_get_end_state() == TAP_IRSHIFT) )
|| ( !ir_scan && (tap_get_end_state() == TAP_DRSHIFT) ) )
{
if (type == SCAN_IO)
{
@ -697,12 +729,14 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size
BUFFER_ADD = 0x4b;
/* LOG_DEBUG("added TMS scan (no read)"); */
}
BUFFER_ADD = 0x6;
BUFFER_ADD = TAP_MOVE(cur_state, end_state) | (last_bit << 7);
cur_state = end_state;
BUFFER_ADD = 0x6; /* scan 7 bits */
BUFFER_ADD = tap_get_tms_path( tap_get_state(), tap_get_end_state() ) | (last_bit << 7);
tap_set_state( tap_get_end_state() );
}
}
int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, u8* buffer, int scan_size)
{
int num_bytes = (scan_size + 7) / 8;
@ -722,15 +756,16 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int
exit(-1);
}
if (cur_state != TAP_DRSHIFT)
if (tap_get_state() != TAP_DRSHIFT)
{
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* scan 7 bit */
BUFFER_ADD = 0x6;
BUFFER_ADD = 0x6; /* scan 7 bits */
/* TMS data bits */
BUFFER_ADD = TAP_MOVE(cur_state, TAP_DRSHIFT);
cur_state = TAP_DRSHIFT;
BUFFER_ADD = tap_get_tms_path(tap_get_state(), TAP_DRSHIFT);
tap_set_state(TAP_DRSHIFT);
}
if ( ( retval = ft2232_write(ft2232_buffer, ft2232_buffer_size, &bytes_written) ) != ERROR_OK )
@ -764,11 +799,13 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int
BUFFER_ADD = 0x28;
/* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
}
thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1);
thisrun_read = thisrun_bytes;
num_bytes -= thisrun_bytes;
BUFFER_ADD = (thisrun_bytes - 1) & 0xff;
BUFFER_ADD = ( (thisrun_bytes - 1) >> 8 ) & 0xff;
if (type != SCAN_IN)
{
/* add complete bytes */
@ -841,7 +878,7 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int
thisrun_read += 2;
}
if (end_state == TAP_DRSHIFT)
if (tap_get_end_state() == TAP_DRSHIFT)
{
if (type == SCAN_IO)
{
@ -880,8 +917,8 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int
/* LOG_DEBUG("added TMS scan (no read)"); */
}
BUFFER_ADD = 0x6;
BUFFER_ADD = TAP_MOVE(cur_state, end_state) | (last_bit << 7);
cur_state = end_state;
BUFFER_ADD = tap_get_tms_path( tap_get_state(), tap_get_end_state() ) | (last_bit << 7);
tap_set_state( tap_get_end_state() );
}
if (type != SCAN_OUT)
@ -909,12 +946,13 @@ int ft2232_large_scan(scan_command_t *cmd, enum scan_type type, u8 *buffer, int
return ERROR_OK;
}
int ft2232_predict_scan_out(int scan_size, enum scan_type type)
{
int predicted_size = 3;
int num_bytes = (scan_size - 1) / 8;
if (cur_state != TAP_DRSHIFT)
if (tap_get_state() != TAP_DRSHIFT)
predicted_size += 3;
if (type == SCAN_IN) /* only from device to host */
@ -935,6 +973,7 @@ int ft2232_predict_scan_out(int scan_size, enum scan_type type)
return predicted_size;
}
int ft2232_predict_scan_in(int scan_size, enum scan_type type)
{
int predicted_size = 0;
@ -943,8 +982,10 @@ int ft2232_predict_scan_in(int scan_size, enum scan_type type)
{
/* complete bytes */
predicted_size += (CEIL(scan_size, 8) > 1) ? (CEIL(scan_size, 8) - 1) : 0;
/* remaining bits - 1 */
predicted_size += ( (scan_size - 1) % 8 ) ? 1 : 0;
/* last bit (from TMS scan) */
predicted_size += 1;
}
@ -954,6 +995,7 @@ int ft2232_predict_scan_in(int scan_size, enum scan_type type)
return predicted_size;
}
void usbjtag_reset(int trst, int srst)
{
if (trst == 1)
@ -990,9 +1032,9 @@ void usbjtag_reset(int trst, int srst)
BUFFER_ADD = 0x80;
BUFFER_ADD = low_output;
BUFFER_ADD = low_direction;
}
void jtagkey_reset(int trst, int srst)
{
if (trst == 1)
@ -1029,9 +1071,11 @@ void jtagkey_reset(int trst, int srst)
BUFFER_ADD = 0x82;
BUFFER_ADD = high_output;
BUFFER_ADD = high_direction;
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
void olimex_jtag_reset(int trst, int srst)
{
if (trst == 1)
@ -1062,14 +1106,16 @@ void olimex_jtag_reset(int trst, int srst)
BUFFER_ADD = 0x82;
BUFFER_ADD = high_output;
BUFFER_ADD = high_direction;
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
void axm0432_jtag_reset(int trst, int srst)
{
if (trst == 1)
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
high_output &= ~nTRST;
}
else if (trst == 0)
@ -1090,9 +1136,11 @@ void axm0432_jtag_reset(int trst, int srst)
BUFFER_ADD = 0x82;
BUFFER_ADD = high_output;
BUFFER_ADD = high_direction;
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
void flyswatter_reset(int trst, int srst)
{
if (trst == 1)
@ -1120,6 +1168,7 @@ void flyswatter_reset(int trst, int srst)
LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
}
void turtle_reset(int trst, int srst)
{
trst = trst;
@ -1140,6 +1189,7 @@ void turtle_reset(int trst, int srst)
LOG_DEBUG("srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", srst, low_output, low_direction);
}
void comstick_reset(int trst, int srst)
{
if (trst == 1)
@ -1164,9 +1214,11 @@ void comstick_reset(int trst, int srst)
BUFFER_ADD = 0x82;
BUFFER_ADD = high_output;
BUFFER_ADD = high_direction;
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
void stm32stick_reset(int trst, int srst)
{
if (trst == 1)
@ -1196,9 +1248,11 @@ void stm32stick_reset(int trst, int srst)
BUFFER_ADD = 0x82;
BUFFER_ADD = high_output;
BUFFER_ADD = high_direction;
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
int ft2232_execute_queue()
{
jtag_command_t* cmd = jtag_command_queue; /* currently processed command */
@ -1246,7 +1300,7 @@ int ft2232_execute_queue()
if ( (cmd->cmd.reset->trst == 1) || ( cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST) ) )
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
layout->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
require_send = 1;
@ -1259,12 +1313,12 @@ int ft2232_execute_queue()
case JTAG_RUNTEST:
/* only send the maximum buffer size that FT2232C can handle */
predicted_size = 0;
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
predicted_size += 3;
predicted_size += 3 * CEIL(cmd->cmd.runtest->num_cycles, 7);
if ( (cmd->cmd.runtest->end_state != -1) && (cmd->cmd.runtest->end_state != TAP_IDLE) )
predicted_size += 3;
if ((cmd->cmd.runtest->end_state == -1) && (end_state != TAP_IDLE))
if ( (cmd->cmd.runtest->end_state == -1) && (tap_get_end_state() != TAP_IDLE) )
predicted_size += 3;
if (ft2232_buffer_size + predicted_size + 1 > FT2232_BUFFER_SIZE)
{
@ -1273,15 +1327,15 @@ int ft2232_execute_queue()
require_send = 0;
first_unsent = cmd;
}
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* scan 7 bit */
BUFFER_ADD = 0x6;
BUFFER_ADD = 0x6; /* scan 7 bits */
/* TMS data bits */
BUFFER_ADD = TAP_MOVE(cur_state, TAP_IDLE);
cur_state = TAP_IDLE;
BUFFER_ADD = tap_get_tms_path(tap_get_state(), TAP_IDLE);
tap_set_state(TAP_IDLE);
require_send = 1;
}
i = cmd->cmd.runtest->num_cycles;
@ -1289,30 +1343,34 @@ int ft2232_execute_queue()
{
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* scan 7 bit */
/* scan 7 bits */
BUFFER_ADD = (i > 7) ? 6 : (i - 1);
/* TMS data bits */
BUFFER_ADD = 0x0;
cur_state = TAP_IDLE;
tap_set_state(TAP_IDLE);
i -= (i > 7) ? 7 : i;
/* LOG_DEBUG("added TMS scan (no read)"); */
}
if (cmd->cmd.runtest->end_state != -1)
ft2232_end_state(cmd->cmd.runtest->end_state);
if (cur_state != end_state)
if ( tap_get_state() != tap_get_end_state() )
{
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* scan 7 bit */
BUFFER_ADD = 0x6;
/* TMS data bits */
BUFFER_ADD = TAP_MOVE(cur_state, end_state);
cur_state = end_state;
BUFFER_ADD = tap_get_tms_path( tap_get_state(), tap_get_end_state() );
tap_set_state( tap_get_end_state() );
/* LOG_DEBUG("added TMS scan (no read)"); */
}
require_send = 1;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest: %i, end in %s", cmd->cmd.runtest->num_cycles, jtag_state_name(end_state));
LOG_DEBUG( "runtest: %i, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name( tap_get_end_state() ) );
#endif
break;
@ -1328,17 +1386,19 @@ int ft2232_execute_queue()
}
if (cmd->cmd.statemove->end_state != -1)
ft2232_end_state(cmd->cmd.statemove->end_state);
/* command "Clock Data to TMS/CS Pin (no Read)" */
BUFFER_ADD = 0x4b;
/* scan 7 bit */
BUFFER_ADD = 0x6;
BUFFER_ADD = 0x6; /* scan 7 bits */
/* TMS data bits */
BUFFER_ADD = TAP_MOVE(cur_state, end_state);
BUFFER_ADD = tap_get_tms_path( tap_get_state(), tap_get_end_state() );
/* LOG_DEBUG("added TMS scan (no read)"); */
cur_state = end_state;
tap_set_state( tap_get_end_state() );
require_send = 1;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove: %s", jtag_state_name(end_state));
LOG_DEBUG( "statemove: %s", tap_state_name( tap_get_end_state() ) );
#endif
break;
@ -1356,7 +1416,7 @@ int ft2232_execute_queue()
require_send = 1;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG( "pathmove: %i states, end in %s", cmd->cmd.pathmove->num_states,
jtag_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]) );
#endif
break;
@ -1384,7 +1444,9 @@ int ft2232_execute_queue()
}
else if (ft2232_buffer_size + predicted_size + 1 > FT2232_BUFFER_SIZE)
{
LOG_DEBUG("ft2232 buffer size reached, sending queued commands (first_unsent: %p, cmd: %p)", first_unsent, cmd);
LOG_DEBUG("ft2232 buffer size reached, sending queued commands (first_unsent: %p, cmd: %p)",
first_unsent,
cmd);
if (ft2232_send_and_recv(first_unsent, cmd) != ERROR_OK)
retval = ERROR_JTAG_QUEUE_FAILED;
require_send = 0;
@ -1400,7 +1462,7 @@ int ft2232_execute_queue()
free(buffer);
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG( "%s scan, %i bits, end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
jtag_state_name(end_state));
tap_state_name( tap_get_end_state() ) );
#endif
break;
@ -1410,18 +1472,19 @@ int ft2232_execute_queue()
first_unsent = cmd->next;
jtag_sleep(cmd->cmd.sleep->us);
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %i usec while in %s", cmd->cmd.sleep->us, jtag_state_name(cur_state));
LOG_DEBUG( "sleep %i usec while in %s", cmd->cmd.sleep->us, tap_state_name( tap_get_state() ) );
#endif
break;
case JTAG_STABLECLOCKS:
/* this is only allowed while in a stable state. A check for a stable
* state was done in jtag_add_clocks()
*/
if (ft2232_stableclocks(cmd->cmd.stableclocks->num_cycles, cmd) != ERROR_OK)
retval = ERROR_JTAG_QUEUE_FAILED;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("clocks %i while in %s", cmd->cmd.stableclocks->num_cycles, jtag_state_name(cur_state));
LOG_DEBUG( "clocks %i while in %s", cmd->cmd.stableclocks->num_cycles, tap_state_name( tap_get_state() ) );
#endif
break;
@ -1429,6 +1492,7 @@ int ft2232_execute_queue()
LOG_ERROR("BUG: unknown JTAG command type encountered");
exit(-1);
}
cmd = cmd->next;
}
@ -1439,6 +1503,7 @@ int ft2232_execute_queue()
return retval;
}
#if BUILD_FT2232_FTD2XX == 1
static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int* try_more)
{
@ -1485,7 +1550,8 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more)
{
DWORD num_devices;
if (more) {
if (more)
{
LOG_WARNING("unable to open ftdi device (trying more): %lu", status);
*try_more = 1;
return ERROR_JTAG_INIT_FAILED;
@ -1499,6 +1565,7 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more)
for (i = 0; i < num_devices; i++)
desc_array[i] = malloc(64);
desc_array[num_devices] = NULL;
status = FT_ListDevices(desc_array, &num_devices, FT_LIST_ALL | openex_flags);
@ -1512,6 +1579,7 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more)
for (i = 0; i < num_devices; i++)
free(desc_array[i]);
free(desc_array);
}
else
@ -1552,6 +1620,7 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more)
return ERROR_OK;
}
static int ft2232_purge_ftd2xx(void)
{
FT_STATUS status;
@ -1564,6 +1633,8 @@ static int ft2232_purge_ftd2xx(void)
return ERROR_OK;
}
#endif /* BUILD_FT2232_FTD2XX == 1 */
#if BUILD_FT2232_LIBFTDI == 1
@ -1579,7 +1650,8 @@ static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int *try_more)
/* context, vendor id, product id */
if (ftdi_usb_open_desc(&ftdic, vid, pid, ft2232_device_desc,
ft2232_serial) < 0) {
ft2232_serial) < 0)
{
if (more)
LOG_WARNING("unable to open ftdi device (trying more): %s",
ftdic.error_str);
@ -1622,6 +1694,7 @@ static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int *try_more)
return ERROR_OK;
}
static int ft2232_purge_libftdi(void)
{
if (ftdi_usb_purge_buffers(&ftdic) < 0)
@ -1632,6 +1705,8 @@ static int ft2232_purge_libftdi(void)
return ERROR_OK;
}
#endif /* BUILD_FT2232_LIBFTDI == 1 */
int ft2232_init(void)
@ -1664,7 +1739,8 @@ int ft2232_init(void)
return ERROR_JTAG_INIT_FAILED;
}
for (i = 0; 1; i++) {
for (i = 0; 1; i++)
{
/*
* "more indicates that there are more IDs to try, so we should
* not print an error for an ID mismatch (but for anything
@ -1714,6 +1790,7 @@ int ft2232_init(void)
return ERROR_OK;
}
int usbjtag_init(void)
{
u8 buf[3];
@ -1788,6 +1865,7 @@ int usbjtag_init(void)
return ERROR_OK;
}
int axm0432_jtag_init(void)
{
u8 buf[3];
@ -1857,6 +1935,7 @@ int axm0432_jtag_init(void)
return ERROR_OK;
}
int jtagkey_init(void)
{
u8 buf[3];
@ -1884,8 +1963,8 @@ int jtagkey_init(void)
nSRST = 0x02;
nSRSTnOE = 0x08;
}
else if ((strcmp(layout->name, "jtagkey_prototype_v1") == 0) ||
(strcmp(layout->name, "oocdlink") == 0))
else if ( (strcmp(layout->name, "jtagkey_prototype_v1") == 0)
|| (strcmp(layout->name, "oocdlink") == 0) )
{
nTRST = 0x02;
nTRSTnOE = 0x1;
@ -1938,6 +2017,7 @@ int jtagkey_init(void)
return ERROR_OK;
}
int olimex_jtag_init(void)
{
u8 buf[3];
@ -2004,6 +2084,7 @@ int olimex_jtag_init(void)
return ERROR_OK;
}
int flyswatter_init(void)
{
u8 buf[3];
@ -2050,6 +2131,7 @@ int flyswatter_init(void)
return ERROR_OK;
}
int turtle_init(void)
{
u8 buf[3];
@ -2090,6 +2172,7 @@ int turtle_init(void)
return ERROR_OK;
}
int comstick_init(void)
{
u8 buf[3];
@ -2133,6 +2216,7 @@ int comstick_init(void)
return ERROR_OK;
}
int stm32stick_init(void)
{
u8 buf[3];
@ -2176,6 +2260,7 @@ int stm32stick_init(void)
return ERROR_OK;
}
void olimex_jtag_blink(void)
{
/* Olimex ARM-USB-OCD has a LED connected to ACBUS3
@ -2197,6 +2282,7 @@ void olimex_jtag_blink(void)
BUFFER_ADD = high_direction;
}
void turtle_jtag_blink(void)
{
/*
@ -2216,6 +2302,7 @@ void turtle_jtag_blink(void)
BUFFER_ADD = high_direction;
}
int ft2232_quit(void)
{
#if BUILD_FT2232_FTD2XX == 1
@ -2236,6 +2323,7 @@ int ft2232_quit(void)
return ERROR_OK;
}
int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
if (argc == 1)
@ -2250,6 +2338,7 @@ int ft2232_handle_device_desc_command(struct command_context_s *cmd_ctx, char *c
return ERROR_OK;
}
int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
if (argc == 1)
@ -2264,6 +2353,7 @@ int ft2232_handle_serial_command(struct command_context_s *cmd_ctx, char *cmd, c
return ERROR_OK;
}
int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
if (argc == 0)
@ -2275,11 +2365,13 @@ int ft2232_handle_layout_command(struct command_context_s *cmd_ctx, char *cmd, c
return ERROR_OK;
}
int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
int i;
if (argc > MAX_USB_IDS*2) {
if (argc > MAX_USB_IDS * 2)
{
LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
"(maximum is %d pairs)", MAX_USB_IDS);
argc = MAX_USB_IDS * 2;
@ -2291,10 +2383,12 @@ int ft2232_handle_vid_pid_command(struct command_context_s *cmd_ctx, char *cmd,
return ERROR_OK;
}
for (i = 0; i+1 < argc; i += 2) {
for (i = 0; i + 1 < argc; i += 2)
{
ft2232_vid[i >> 1] = strtol(args[i], NULL, 0);
ft2232_pid[i >> 1] = strtol(args[i + 1], NULL, 0);
}
/*
* Explicitly terminate, in case there are multiples instances of
* ft2232_vid_pid.
@ -2304,6 +2398,7 @@ int ft2232_handle_vid_pid_command(struct command_context_s *cmd_ctx, char *cmd,
return ERROR_OK;
}
int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
if (argc == 1)
@ -2324,14 +2419,13 @@ static int ft2232_stableclocks(int num_cycles, jtag_command_t *cmd)
int retval = 0;
/* 7 bits of either ones or zeros. */
u8 tms = (cur_state == TAP_RESET ? 0x7F : 0x00);
u8 tms = (tap_get_state() == TAP_RESET ? 0x7F : 0x00);
while (num_cycles > 0)
{
/* the command 0x4b, "Clock Data to TMS/CS Pin (no Read)" handles
* at most 7 bits per invocation. Here we invoke it potentially
* several times.
* see: http://www.ftdichip.com/Documents/AppNotes/AN2232C-01_MPSSE_Cmnd.pdf
*/
int bitcount_per_command = (num_cycles > 7) ? 7 : num_cycles;
@ -2359,4 +2453,3 @@ static int ft2232_stableclocks(int num_cycles, jtag_command_t *cmd)
return retval;
}

View File

@ -196,8 +196,8 @@ int gw16012_speed(int speed)
void gw16012_end_state(int state)
{
if (tap_move_map[state] != -1)
end_state = state;
if (tap_is_state_stable(state))
tap_set_end_state(state);
else
{
LOG_ERROR("BUG: %i is not a valid end state", state);
@ -208,7 +208,7 @@ void gw16012_end_state(int state)
void gw16012_state_move(void)
{
int i=0, tms=0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
gw16012_control(0x0); /* single-bit mode */
@ -218,7 +218,7 @@ void gw16012_state_move(void)
gw16012_data(tms << 1); /* output next TMS bit */
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
void gw16012_path_move(pathmove_command_t *cmd)
@ -230,35 +230,35 @@ void gw16012_path_move(pathmove_command_t *cmd)
while (num_states)
{
gw16012_control(0x0); /* single-bit mode */
if (tap_transitions[cur_state].low == cmd->path[state_count])
if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
{
gw16012_data(0x0); /* TCK cycle with TMS low */
}
else if (tap_transitions[cur_state].high == cmd->path[state_count])
else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
{
gw16012_data(0x2); /* TCK cycle with TMS high */
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(cmd->path[state_count]));
exit(-1);
}
cur_state = cmd->path[state_count];
tap_set_state(cmd->path[state_count]);
state_count++;
num_states--;
}
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
void gw16012_runtest(int num_cycles)
{
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
int i;
/* only do a state_move when we're not already in IDLE */
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
gw16012_end_state(TAP_IDLE);
gw16012_state_move();
@ -271,7 +271,7 @@ void gw16012_runtest(int num_cycles)
}
gw16012_end_state(saved_end_state);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
gw16012_state_move();
}
@ -279,11 +279,11 @@ void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
{
int bits_left = scan_size;
int bit_count = 0;
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
u8 scan_out, scan_in;
/* only if we're not already in the correct Shift state */
if (!((!ir_scan && (cur_state == TAP_DRSHIFT)) || (ir_scan && (cur_state == TAP_IRSHIFT))))
if (!((!ir_scan && (tap_get_state() == TAP_DRSHIFT)) || (ir_scan && (tap_get_state() == TAP_IRSHIFT))))
{
if (ir_scan)
gw16012_end_state(TAP_IRSHIFT);
@ -312,8 +312,8 @@ void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
if (bits_left == 0) /* last bit */
{
if ((ir_scan && (end_state == TAP_IRSHIFT))
|| (!ir_scan && (end_state == TAP_DRSHIFT)))
if ((ir_scan && (tap_get_end_state() == TAP_IRSHIFT))
|| (!ir_scan && (tap_get_end_state() == TAP_DRSHIFT)))
{
tms = 0;
}
@ -334,16 +334,16 @@ void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
bit_count++;
}
if (!((ir_scan && (end_state == TAP_IRSHIFT)) ||
(!ir_scan && (end_state == TAP_DRSHIFT))))
if (!((ir_scan && (tap_get_end_state() == TAP_IRSHIFT)) ||
(!ir_scan && (tap_get_end_state() == TAP_DRSHIFT))))
{
gw16012_data(0x0);
if (ir_scan)
cur_state = TAP_IRPAUSE;
tap_set_state(TAP_IRPAUSE);
else
cur_state = TAP_DRPAUSE;
tap_set_state(TAP_DRPAUSE);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
gw16012_state_move();
}
}
@ -378,7 +378,7 @@ int gw16012_execute_queue(void)
#endif
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;

View File

@ -88,9 +88,9 @@ int jlink_quit(void);
int jlink_handle_jlink_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* Queue command functions */
void jlink_end_state(enum tap_state state);
void jlink_end_state(tap_state_t state);
void jlink_state_move(void);
void jlink_path_move(int num_states, enum tap_state *path);
void jlink_path_move(int num_states, tap_state_t *path);
void jlink_runtest(int num_cycles);
void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command);
void jlink_reset(int trst, int srst);
@ -214,7 +214,7 @@ int jlink_execute_queue(void)
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
jlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
@ -331,11 +331,11 @@ int jlink_quit(void)
/***************************************************************************/
/* Queue command implementations */
void jlink_end_state(enum tap_state state)
void jlink_end_state(tap_state_t state)
{
if (tap_move_map[state] != -1)
if (tap_is_state_stable(state))
{
end_state = state;
tap_set_end_state(state);
}
else
{
@ -349,7 +349,7 @@ void jlink_state_move(void)
{
int i;
int tms = 0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
for (i = 0; i < 7; i++)
{
@ -357,43 +357,43 @@ void jlink_state_move(void)
jlink_tap_append_step(tms, 0);
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
void jlink_path_move(int num_states, enum tap_state *path)
void jlink_path_move(int num_states, tap_state_t *path)
{
int i;
for (i = 0; i < num_states; i++)
{
if (path[i] == tap_transitions[cur_state].low)
if (path[i] == tap_state_transition(tap_get_state(), FALSE))
{
jlink_tap_append_step(0, 0);
}
else if (path[i] == tap_transitions[cur_state].high)
else if (path[i] == tap_state_transition(tap_get_state(), TRUE))
{
jlink_tap_append_step(1, 0);
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[i]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(path[i]));
exit(-1);
}
cur_state = path[i];
tap_set_state(path[i]);
}
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
void jlink_runtest(int num_cycles)
{
int i;
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
jlink_end_state(TAP_IDLE);
jlink_state_move();
@ -407,7 +407,7 @@ void jlink_runtest(int num_cycles)
/* finish in end_state */
jlink_end_state(saved_end_state);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
{
jlink_state_move();
}
@ -415,11 +415,11 @@ void jlink_runtest(int num_cycles)
void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command)
{
enum tap_state saved_end_state;
tap_state_t saved_end_state;
jlink_tap_ensure_space(1, scan_size + 8);
saved_end_state = end_state;
saved_end_state = tap_get_end_state();
/* Move to appropriate scan state */
jlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
@ -433,9 +433,9 @@ void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, sca
/* We are in Exit1, go to Pause */
jlink_tap_append_step(0, 0);
cur_state = ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE;
tap_set_state(ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
{
jlink_state_move();
}

View File

@ -4,6 +4,10 @@
* *
* Copyright (C) 2007,2008 Øyvind Harboe *
* oyvind.harboe@zylin.com *
*
* Copyright (C) 2009 SoftPLC Corporation
* http://softplc.com
* dick@softplc.com
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -51,52 +55,6 @@ typedef struct cmd_queue_page_s
#define CMD_QUEUE_PAGE_SIZE (1024 * 1024)
static cmd_queue_page_t *cmd_queue_pages = NULL;
/* tap_move[i][j]: tap movement command to go from state i to state j
* 0: Test-Logic-Reset
* 1: Run-Test/Idle
* 2: Shift-DR
* 3: Pause-DR
* 4: Shift-IR
* 5: Pause-IR
*
* DRSHIFT->DRSHIFT and IRSHIFT->IRSHIFT have to be caught in interface specific code
*/
u8 tap_move[6][6] =
{
/* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */
{ 0x7f, 0x00, 0x17, 0x0a, 0x1b, 0x16}, /* RESET */
{ 0x7f, 0x00, 0x25, 0x05, 0x2b, 0x0b}, /* IDLE */
{ 0x7f, 0x31, 0x00, 0x01, 0x0f, 0x2f}, /* DRSHIFT */
{ 0x7f, 0x30, 0x20, 0x17, 0x1e, 0x2f}, /* DRPAUSE */
{ 0x7f, 0x31, 0x07, 0x17, 0x00, 0x01}, /* IRSHIFT */
{ 0x7f, 0x30, 0x1c, 0x17, 0x20, 0x2f} /* IRPAUSE */
};
int tap_move_map[16] = {
0, -1, -1, 2, -1, 3, -1, -1,
1, -1, -1, 4, -1, 5, -1, -1
};
tap_transition_t tap_transitions[16] =
{
{TAP_RESET, TAP_IDLE}, /* RESET */
{TAP_IRSELECT, TAP_DRCAPTURE}, /* DRSELECT */
{TAP_DREXIT1, TAP_DRSHIFT}, /* DRCAPTURE */
{TAP_DREXIT1, TAP_DRSHIFT}, /* DRSHIFT */
{TAP_DRUPDATE, TAP_DRPAUSE}, /* DREXIT1 */
{TAP_DREXIT2, TAP_DRPAUSE}, /* DRPAUSE */
{TAP_DRUPDATE, TAP_DRSHIFT}, /* DREXIT2 */
{TAP_DRSELECT, TAP_IDLE}, /* DRUPDATE */
{TAP_DRSELECT, TAP_IDLE}, /* IDLE */
{TAP_RESET, TAP_IRCAPTURE}, /* IRSELECT */
{TAP_IREXIT1, TAP_IRSHIFT}, /* IRCAPTURE */
{TAP_IREXIT1, TAP_IRSHIFT}, /* IRSHIFT */
{TAP_IRUPDATE, TAP_IRPAUSE}, /* IREXIT1 */
{TAP_IREXIT2, TAP_IRPAUSE}, /* IRPAUSE */
{TAP_IRUPDATE, TAP_IRSHIFT}, /* IREXIT2 */
{TAP_DRSELECT, TAP_IDLE} /* IRUPDATE */
};
char* jtag_event_strings[] =
{
"JTAG controller reset (RESET or TRST)"
@ -109,13 +67,6 @@ const Jim_Nvp nvp_jtag_tap_event[] = {
{ .name = NULL, .value = -1 }
};
/* kludge!!!! these are just global variables that the
* interface use internally. They really belong
* inside the drivers, but we don't want to break
* linking the drivers!!!!
*/
enum tap_state end_state = TAP_RESET;
enum tap_state cur_state = TAP_RESET;
int jtag_trst = 0;
int jtag_srst = 0;
@ -124,8 +75,8 @@ jtag_command_t **last_comand_pointer = &jtag_command_queue;
static jtag_tap_t *jtag_all_taps = NULL;
enum reset_types jtag_reset_config = RESET_NONE;
enum tap_state cmd_queue_end_state = TAP_RESET;
enum tap_state cmd_queue_cur_state = TAP_RESET;
tap_state_t cmd_queue_end_state = TAP_RESET;
tap_state_t cmd_queue_cur_state = TAP_RESET;
int jtag_verify_capture_ir = 1;
@ -257,9 +208,9 @@ jtag_interface_t *jtag_interface = NULL;
int jtag_speed = 0;
/* forward declarations */
void jtag_add_pathmove(int num_states, enum tap_state *path);
void jtag_add_runtest(int num_cycles, enum tap_state endstate);
void jtag_add_end_state(enum tap_state endstate);
void jtag_add_pathmove(int num_states, tap_state_t *path);
void jtag_add_runtest(int num_cycles, tap_state_t endstate);
void jtag_add_end_state(tap_state_t endstate);
void jtag_add_sleep(u32 us);
int jtag_execute_queue(void);
@ -550,7 +501,7 @@ static void jtag_prelude1(void)
jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
}
static void jtag_prelude(enum tap_state state)
static void jtag_prelude(tap_state_t state)
{
jtag_prelude1();
@ -560,7 +511,7 @@ static void jtag_prelude(enum tap_state state)
cmd_queue_cur_state = cmd_queue_end_state;
}
void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
void jtag_add_ir_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
int retval;
@ -571,7 +522,7 @@ void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state
jtag_error=retval;
}
int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields, enum tap_state state)
int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields, tap_state_t state)
{
jtag_command_t **last_cmd;
jtag_tap_t *tap;
@ -657,7 +608,7 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
return ERROR_OK;
}
void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
int retval;
@ -668,7 +619,7 @@ void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state
jtag_error=retval;
}
int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *fields, enum tap_state state)
int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *fields, tap_state_t state)
{
int i;
jtag_command_t **last_cmd;
@ -704,7 +655,7 @@ int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *f
return ERROR_OK;
}
void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
void jtag_add_dr_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
int retval;
@ -715,7 +666,7 @@ void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state
jtag_error=retval;
}
int MINIDRIVER(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields, enum tap_state state)
int MINIDRIVER(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields, tap_state_t state)
{
int j;
int nth_tap;
@ -818,7 +769,7 @@ void MINIDRIVER(interface_jtag_add_dr_out)(jtag_tap_t *target_tap,
int num_fields,
const int *num_bits,
const u32 *value,
enum tap_state end_state)
tap_state_t end_state)
{
int nth_tap;
int field_count = 0;
@ -912,7 +863,7 @@ void MINIDRIVER(interface_jtag_add_dr_out)(jtag_tap_t *target_tap,
}
}
void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
int retval;
@ -923,7 +874,7 @@ void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state
jtag_error=retval;
}
int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *fields, enum tap_state state)
int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *fields, tap_state_t state)
{
int i;
jtag_command_t **last_cmd = jtag_get_last_command_p();
@ -971,7 +922,7 @@ void jtag_add_tlr(void)
int MINIDRIVER(interface_jtag_add_tlr)(void)
{
enum tap_state state = TAP_RESET;
tap_state_t state = TAP_RESET;
jtag_command_t **last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
@ -986,14 +937,14 @@ int MINIDRIVER(interface_jtag_add_tlr)(void)
return ERROR_OK;
}
void jtag_add_pathmove(int num_states, enum tap_state *path)
void jtag_add_pathmove(int num_states, tap_state_t *path)
{
enum tap_state cur_state=cmd_queue_cur_state;
tap_state_t cur_state=cmd_queue_cur_state;
int i;
int retval;
/* the last state has to be a stable state */
if (tap_move_map[path[num_states - 1]] == -1)
if (!tap_is_state_stable(path[num_states - 1]))
{
LOG_ERROR("BUG: TAP path doesn't finish in a stable state");
exit(-1);
@ -1006,10 +957,10 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
exit(-1);
}
if ((tap_transitions[cur_state].low != path[i])&&
(tap_transitions[cur_state].high != path[i]))
if ( tap_state_transition(cur_state, TRUE) != path[i]
&& tap_state_transition(cur_state, FALSE) != path[i])
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[i]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[i]));
exit(-1);
}
cur_state = path[i];
@ -1023,7 +974,7 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
jtag_error=retval;
}
int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, enum tap_state *path)
int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, tap_state_t *path)
{
jtag_command_t **last_cmd = jtag_get_last_command_p();
int i;
@ -1036,7 +987,7 @@ int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, enum tap_state *path
(*last_cmd)->cmd.pathmove = cmd_queue_alloc(sizeof(pathmove_command_t));
(*last_cmd)->cmd.pathmove->num_states = num_states;
(*last_cmd)->cmd.pathmove->path = cmd_queue_alloc(sizeof(enum tap_state) * num_states);
(*last_cmd)->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states);
for (i = 0; i < num_states; i++)
(*last_cmd)->cmd.pathmove->path[i] = path[i];
@ -1044,7 +995,7 @@ int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, enum tap_state *path
return ERROR_OK;
}
int MINIDRIVER(interface_jtag_add_runtest)(int num_cycles, enum tap_state state)
int MINIDRIVER(interface_jtag_add_runtest)(int num_cycles, tap_state_t state)
{
jtag_command_t **last_cmd = jtag_get_last_command_p();
@ -1061,7 +1012,7 @@ int MINIDRIVER(interface_jtag_add_runtest)(int num_cycles, enum tap_state state)
return ERROR_OK;
}
void jtag_add_runtest(int num_cycles, enum tap_state state)
void jtag_add_runtest(int num_cycles, tap_state_t state)
{
int retval;
@ -1093,19 +1044,10 @@ void jtag_add_clocks( int num_cycles )
{
int retval;
/* "if (tap_move_map[cm_queue_cur_state] != -1)" is of no help when cur_state==TAP_IDLE */
switch(cmd_queue_cur_state)
if( !tap_is_state_stable(cmd_queue_cur_state) )
{
case TAP_DRSHIFT:
case TAP_IDLE:
case TAP_RESET:
case TAP_DRPAUSE:
case TAP_IRSHIFT:
case TAP_IRPAUSE:
break; /* above stable states are OK */
default:
LOG_ERROR( "jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
jtag_state_name(cmd_queue_cur_state) );
tap_state_name(cmd_queue_cur_state) );
jtag_error = ERROR_JTAG_NOT_STABLE_STATE;
return;
}
@ -1240,7 +1182,7 @@ int MINIDRIVER(interface_jtag_add_reset)(int req_trst, int req_srst)
return ERROR_OK;
}
void jtag_add_end_state(enum tap_state state)
void jtag_add_end_state(tap_state_t state)
{
cmd_queue_end_state = state;
if ((cmd_queue_end_state == TAP_DRSHIFT)||(cmd_queue_end_state == TAP_IRSHIFT))
@ -2708,7 +2650,7 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char *
int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
enum tap_state state;
tap_state_t state;
if (argc < 1)
{
@ -2718,14 +2660,14 @@ int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char *
{
for (state = 0; state < 16; state++)
{
if (strcmp(args[0], jtag_state_name(state)) == 0)
if (strcmp(args[0], tap_state_name(state)) == 0)
{
jtag_add_end_state(state);
jtag_execute_queue();
}
}
}
command_print(cmd_ctx, "current endstate: %s", jtag_state_name(cmd_queue_end_state));
command_print(cmd_ctx, "current endstate: %s", tap_state_name(cmd_queue_end_state));
return ERROR_OK;
}
@ -2979,8 +2921,247 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
}
/* map state number to SVF state string */
const char* jtag_state_name(enum tap_state state)
/*-----<Cable Helper API>---------------------------------------*/
/* these Cable Helper API functions are all documented in the jtag.h header file,
using a Doxygen format. And since Doxygen's configuration file "Doxyfile",
is setup to prefer its docs in the header file, no documentation is here, for
if it were, it would have to be doubly maintained.
*/
/**
* @see tap_set_state() and tap_get_state() accessors.
* Actual name is not important since accessors hide it.
*/
static tap_state_t state_follower = TAP_RESET;
void tap_set_state_impl( tap_state_t new_state )
{
/* this is the state we think the TAPs are in now, was cur_state */
state_follower = new_state;
}
tap_state_t tap_get_state()
{
return state_follower;
}
/**
* @see tap_set_end_state() and tap_get_end_state() accessors.
* Actual name is not important because accessors hide it.
*/
static tap_state_t end_state_follower = TAP_RESET;
void tap_set_end_state( tap_state_t new_end_state )
{
/* this is the state we think the TAPs will be in at completion of the
current TAP operation, was end_state
*/
end_state_follower = new_end_state;
}
tap_state_t tap_get_end_state()
{
return end_state_follower;
}
int tap_move_ndx( tap_state_t astate )
{
/* given a stable state, return the index into the tms_seqs[] array within tap_get_tms_path() */
/* old version
const static int move_map[16] =
{
0, -1, -1, 2, -1, 3, -1, -1,
1, -1, -1, 4, -1, 5, -1, -1
};
*/
int ndx;
switch( astate )
{
case TAP_RESET: ndx = 0; break;
case TAP_DRSHIFT: ndx = 2; break;
case TAP_DRPAUSE: ndx = 3; break;
case TAP_IDLE: ndx = 1; break;
case TAP_IRSHIFT: ndx = 4; break;
case TAP_IRPAUSE: ndx = 5; break;
default:
LOG_ERROR( "fatal: unstable state \"%s\" used in tap_move_ndx()", tap_state_name(astate) );
exit(1);
}
return ndx;
}
int tap_get_tms_path( tap_state_t from, tap_state_t to )
{
/* tap_move[i][j]: tap movement command to go from state i to state j
* 0: Test-Logic-Reset
* 1: Run-Test/Idle
* 2: Shift-DR
* 3: Pause-DR
* 4: Shift-IR
* 5: Pause-IR
*
* DRSHIFT->DRSHIFT and IRSHIFT->IRSHIFT have to be caught in interface specific code
*/
const static u8 tms_seqs[6][6] =
{
/* value clocked to TMS to move from one of six stable states to another */
/* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */
{ 0x7f, 0x00, 0x17, 0x0a, 0x1b, 0x16 }, /* RESET */
{ 0x7f, 0x00, 0x25, 0x05, 0x2b, 0x0b }, /* IDLE */
{ 0x7f, 0x31, 0x00, 0x01, 0x0f, 0x2f }, /* DRSHIFT */
{ 0x7f, 0x30, 0x20, 0x17, 0x1e, 0x2f }, /* DRPAUSE */
{ 0x7f, 0x31, 0x07, 0x17, 0x00, 0x01 }, /* IRSHIFT */
{ 0x7f, 0x30, 0x1c, 0x17, 0x20, 0x2f } /* IRPAUSE */
};
if( !tap_is_state_stable(from) )
{
LOG_ERROR( "fatal: tap_state \"from\" (=%s) is not stable", tap_state_name(from) );
exit(1);
}
if( !tap_is_state_stable(to) )
{
LOG_ERROR( "fatal: tap_state \"to\" (=%s) is not stable", tap_state_name(to) );
exit(1);
}
/* @todo: support other than 7 clocks ? */
return tms_seqs[tap_move_ndx(from)][tap_move_ndx(to)];
}
BOOL tap_is_state_stable(tap_state_t astate)
{
BOOL is_stable;
/* A switch() is used because it is symbol dependent
(not value dependent like an array), and can also check bounds.
*/
switch( astate )
{
case TAP_RESET:
case TAP_IDLE:
case TAP_DRSHIFT:
case TAP_DRPAUSE:
case TAP_IRSHIFT:
case TAP_IRPAUSE:
is_stable = TRUE;
break;
default:
is_stable = FALSE;
}
return is_stable;
}
tap_state_t tap_state_transition(tap_state_t cur_state, BOOL tms)
{
tap_state_t new_state;
/* A switch is used because it is symbol dependent and not value dependent
like an array. Also it can check for out of range conditions.
*/
if (tms)
{
switch (cur_state)
{
case TAP_RESET:
new_state = cur_state;
break;
case TAP_IDLE:
case TAP_DRUPDATE:
case TAP_IRUPDATE:
new_state = TAP_DRSELECT;
break;
case TAP_DRSELECT:
new_state = TAP_IRSELECT;
break;
case TAP_DRCAPTURE:
case TAP_DRSHIFT:
new_state = TAP_DREXIT1;
break;
case TAP_DREXIT1:
case TAP_DREXIT2:
new_state = TAP_DRUPDATE;
break;
case TAP_DRPAUSE:
new_state = TAP_DREXIT2;
break;
case TAP_IRSELECT:
new_state = TAP_RESET;
break;
case TAP_IRCAPTURE:
case TAP_IRSHIFT:
new_state = TAP_IREXIT1;
break;
case TAP_IREXIT1:
case TAP_IREXIT2:
new_state = TAP_IRUPDATE;
break;
case TAP_IRPAUSE:
new_state = TAP_IREXIT2;
break;
default:
LOG_ERROR( "fatal: invalid argument cur_state=%d", cur_state );
exit(1);
break;
}
}
else
{
switch (cur_state)
{
case TAP_RESET:
case TAP_IDLE:
case TAP_DRUPDATE:
case TAP_IRUPDATE:
new_state = TAP_IDLE;
break;
case TAP_DRSELECT:
new_state = TAP_DRCAPTURE;
break;
case TAP_DRCAPTURE:
case TAP_DRSHIFT:
case TAP_DREXIT2:
new_state = TAP_DRSHIFT;
break;
case TAP_DREXIT1:
case TAP_DRPAUSE:
new_state = TAP_DRPAUSE;
break;
case TAP_IRSELECT:
new_state = TAP_IRCAPTURE;
break;
case TAP_IRCAPTURE:
case TAP_IRSHIFT:
case TAP_IREXIT2:
new_state = TAP_IRSHIFT;
break;
case TAP_IREXIT1:
case TAP_IRPAUSE:
new_state = TAP_IRPAUSE;
break;
default:
LOG_ERROR( "fatal: invalid argument cur_state=%d", cur_state );
exit(1);
break;
}
}
return new_state;
}
const char* tap_state_name(tap_state_t state)
{
const char* ret;
@ -3008,3 +3189,4 @@ const char* jtag_state_name(enum tap_state state)
return ret;
}
/*-----</Cable Helper API>--------------------------------------*/

View File

@ -41,32 +41,143 @@
/* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf
*/
typedef enum tap_state
{
TAP_RESET = 0x0, TAP_IDLE = 0x8,
TAP_DRSELECT = 0x1, TAP_DRCAPTURE = 0x2, TAP_DRSHIFT = 0x3, TAP_DREXIT1 = 0x4,
TAP_DRPAUSE = 0x5, TAP_DREXIT2 = 0x6, TAP_DRUPDATE = 0x7,
TAP_IRSELECT = 0x9, TAP_IRCAPTURE = 0xa, TAP_IRSHIFT = 0xb, TAP_IREXIT1 = 0xc,
TAP_IRPAUSE = 0xd, TAP_IREXIT2 = 0xe, TAP_IRUPDATE = 0xf
} tap_state_t;
enum tap_state {
TAP_RESET = 0, TAP_IDLE = 8,
TAP_DRSELECT = 1, TAP_DRCAPTURE = 2, TAP_DRSHIFT = 3, TAP_DREXIT1 = 4,
TAP_DRPAUSE = 5, TAP_DREXIT2 = 6, TAP_DRUPDATE = 7,
TAP_IRSELECT = 9, TAP_IRCAPTURE = 10, TAP_IRSHIFT = 11, TAP_IREXIT1 = 12,
TAP_IRPAUSE = 13, TAP_IREXIT2 = 14, TAP_IRUPDATE = 15
};
typedef enum tap_state tap_state_t;
typedef unsigned BOOL;
#define TRUE 1
#define FALSE 0
typedef struct tap_transition_s
{
enum tap_state high;
enum tap_state low;
tap_state_t high;
tap_state_t low;
} tap_transition_t;
extern int tap_move_map[16]; /* map 16 TAP states to 6 stable states */
extern u8 tap_move[6][6]; /* value scanned to TMS to move from one of six stable states to another */
extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */
//extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */
extern enum tap_state end_state; /* finish DR scans in dr_end_state */
extern enum tap_state cur_state; /* current TAP state */
extern enum tap_state cmd_queue_end_state; /* finish DR scans in dr_end_state */
extern enum tap_state cmd_queue_cur_state; /* current TAP state */
/*-----<Cable Helper API>-------------------------------------------*/
#define TAP_MOVE(from, to) tap_move[tap_move_map[from]][tap_move_map[to]]
/* The "Cable Helper API" is what the cable drivers can use to help implement
* their "Cable API". So a Cable Helper API is a set of helper functions used by
* cable drivers, and this is different from a Cable API. A "Cable API" is what
* higher level code used to talk to a cable.
*/
/** implementation of wrapper function tap_set_state() */
void tap_set_state_impl(tap_state_t new_state);
/**
* Function tap_set_state
* sets the state of a "state follower" which tracks the state of the TAPs connected to the
* cable. The state follower is hopefully always in the same state as the actual
* TAPs in the jtag chain, and will be so if there are no bugs in the tracking logic within that
* cable driver. All the cable drivers call this function to indicate the state they think
* the TAPs attached to their cables are in. Because this function can also log transitions,
* it will be helpful to call this function with every transition that the TAPs being manipulated
* are expected to traverse, not just end points of a multi-step state path.
* @param new_state is the state we think the TAPs are currently in or are about to enter.
*/
#if defined(_DEBUG_JTAG_IO_)
#define tap_set_state(new_state) \
do { \
LOG_DEBUG( "tap_set_state(%s)", tap_state_name(new_state) ); \
tap_set_state_impl(new_state); \
} while (0)
#else
static inline void tap_set_state(tap_state_t new_state)
{
tap_set_state_impl(new_state);
}
#endif
/**
* Function tap_get_state
* gets the state of the "state follower" which tracks the state of the TAPs connected to
* the cable.
* @see tap_set_state
* @return tap_state_t - The state the TAPs are in now.
*/
tap_state_t tap_get_state(void);
/**
* Function tap_set_end_state
* sets the state of an "end state follower" which tracks the state that any cable driver
* thinks will be the end (resultant) state of the current TAP SIR or SDR operation. At completion
* of that TAP operation this value is copied into the state follower via tap_set_state().
* @param new_end_state is that state the TAPs should enter at completion of a pending TAP operation.
*/
void tap_set_end_state(tap_state_t new_end_state);
/**
* Function tap_get_end_state
* @see tap_set_end_state
* @return tap_state_t - The state the TAPs should be in at completion of the current TAP operation.
*/
tap_state_t tap_get_end_state(void);
/**
* Function tap_get_tms_path
* returns a 7 bit long "bit sequence" indicating what has to be done with TMS
* during a sequence of seven TAP clock cycles in order to get from
* state \a "from" to state \a "to".
* @param from is the starting state
* @param to is the resultant or final state
* @return int - a 7 bit sequence, with the first bit in the sequence at bit 0.
*/
int tap_get_tms_path(tap_state_t from, tap_state_t to);
/**
* Function tap_move_ndx
* when given a stable state, returns an index from 0-5. The index corresponds to a
* sequence of stable states which are given in this order: <p>
* { TAP_RESET, TAP_IDLE, TAP_DRSHIFT, TAP_DRPAUSE, TAP_IRSHIFT, TAP_IRPAUSE }
* <p>
* This sequence corresponds to look up tables which are used in some of the
* cable drivers.
* @param astate is the stable state to find in the sequence. If a non stable
* state is passed, this may cause the program to output an error message
* and terminate.
* @return int - the array (or sequence) index as described above
*/
int tap_move_ndx(tap_state_t astate);
/**
* Function tap_is_state_stable
* returns TRUE if the \a astate is stable.
*/
BOOL tap_is_state_stable(tap_state_t astate);
/**
* Function tap_state_transition
* takes a current TAP state and returns the next state according to the tms value.
* @param current_state is the state of a TAP currently.
* @param tms is either zero or non-zero, just like a real TMS line in a jtag interface.
* @return tap_state_t - the next state a TAP would enter.
*/
tap_state_t tap_state_transition(tap_state_t current_state, BOOL tms);
/**
* Function tap_state_name
* Returns a string suitable for display representing the JTAG tap_state
*/
const char* tap_state_name(tap_state_t state);
/*-----</Cable Helper API>------------------------------------------*/
extern tap_state_t cmd_queue_end_state; /* finish DR scans in dr_end_state */
extern tap_state_t cmd_queue_cur_state; /* current TAP state */
typedef void* error_handler_t; /* Later on we can delete error_handler_t, but keep it for now to make patches more readable */
@ -87,8 +198,7 @@ typedef struct scan_field_s
void* in_handler_priv; /* additional information for the in_handler */
} scan_field_t;
enum scan_type
{
enum scan_type {
/* IN: from device to host, OUT: from host to device */
SCAN_IN = 1, SCAN_OUT = 2, SCAN_IO = 3
};
@ -98,24 +208,24 @@ typedef struct scan_command_s
int ir_scan; /* instruction/not data scan */
int num_fields; /* number of fields in *fields array */
scan_field_t* fields; /* pointer to an array of data scan fields */
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
tap_state_t end_state; /* TAP state in which JTAG commands should finish */
} scan_command_t;
typedef struct statemove_command_s
{
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
tap_state_t end_state; /* TAP state in which JTAG commands should finish */
} statemove_command_t;
typedef struct pathmove_command_s
{
int num_states; /* number of states in *path */
enum tap_state *path; /* states that have to be passed */
tap_state_t* path; /* states that have to be passed */
} pathmove_command_t;
typedef struct runtest_command_s
{
int num_cycles; /* number of cycles that should be spent in Run-Test/Idle */
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
tap_state_t end_state; /* TAP state in which JTAG commands should finish */
} runtest_command_t;
@ -133,7 +243,7 @@ typedef struct reset_command_s
typedef struct end_state_command_s
{
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
tap_state_t end_state; /* TAP state in which JTAG commands should finish */
} end_state_command_t;
typedef struct sleep_command_s
@ -153,12 +263,14 @@ typedef union jtag_command_container_u
sleep_command_t* sleep;
} jtag_command_container_t;
enum jtag_command_type
{
enum jtag_command_type {
JTAG_SCAN = 1,
JTAG_STATEMOVE = 2, JTAG_RUNTEST = 3,
JTAG_RESET = 4, JTAG_END_STATE = 5,
JTAG_PATHMOVE = 6, JTAG_SLEEP = 7,
JTAG_STATEMOVE = 2,
JTAG_RUNTEST = 3,
JTAG_RESET = 4,
JTAG_END_STATE = 5,
JTAG_PATHMOVE = 6,
JTAG_SLEEP = 7,
JTAG_STABLECLOCKS = 8
};
@ -208,28 +320,35 @@ extern jtag_tap_t *jtag_TapByAbsPosition(int abs_position);
extern int jtag_NumEnabledTaps(void);
extern int jtag_NumTotalTaps(void);
static __inline__ jtag_tap_t *
jtag_NextEnabledTap( jtag_tap_t *p )
static __inline__ jtag_tap_t* jtag_NextEnabledTap(jtag_tap_t* p)
{
if (p == NULL)
{
if( p == NULL ){
/* start at the head of list */
p = jtag_AllTaps();
} else {
}
else
{
/* start *after* this one */
p = p->next_tap;
}
while( p ){
if( p->enabled ){
while (p)
{
if (p->enabled)
{
break;
} else {
}
else
{
p = p->next_tap;
}
}
return p;
}
enum reset_line_mode
{
enum reset_line_mode {
LINE_OPEN_DRAIN = 0x0,
LINE_PUSH_PULL = 0x1,
};
@ -248,29 +367,32 @@ typedef struct jtag_interface_s
int (*register_commands)(struct command_context_s* cmd_ctx);
int (*init)(void);
int (*quit)(void);
/* returns JTAG maxium speed for KHz. 0=RTCK. The function returns
a failure if it can't support the KHz/RTCK.
WARNING!!!! if RTCK is *slow* then think carefully about
whether you actually want to support this in the driver.
Many target scripts are written to handle the absence of RTCK
and use a fallback kHz TCK.
/* returns JTAG maxium speed for KHz. 0=RTCK. The function returns
* a failure if it can't support the KHz/RTCK.
*
* WARNING!!!! if RTCK is *slow* then think carefully about
* whether you actually want to support this in the driver.
* Many target scripts are written to handle the absence of RTCK
* and use a fallback kHz TCK.
*/
int (*khz)(int khz, int* jtag_speed);
/* returns the KHz for the provided JTAG speed. 0=RTCK. The function returns
a failure if it can't support the KHz/RTCK. */
* a failure if it can't support the KHz/RTCK. */
int (*speed_div)(int speed, int* khz);
/* Read and clear the power dropout flag. Note that a power dropout
can be transitionary, easily much less than a ms.
So to find out if the power is *currently* on, you must invoke
this method twice. Once to clear the power dropout flag and a
second time to read the current state.
Currently the default implementation is never to detect power dropout.
* can be transitionary, easily much less than a ms.
*
* So to find out if the power is *currently* on, you must invoke
* this method twice. Once to clear the power dropout flag and a
* second time to read the current state.
*
* Currently the default implementation is never to detect power dropout.
*/
int (*power_dropout)(int* power_dropout);
/* Read and clear the srst asserted detection flag.
*
* NB!!!! like power_dropout this does *not* read the current
@ -278,25 +400,23 @@ typedef struct jtag_interface_s
* less than 1ms.
*/
int (*srst_asserted)(int* srst_asserted);
} jtag_interface_t;
enum jtag_event
{
enum jtag_event {
JTAG_TRST_ASSERTED
};
extern char* jtag_event_strings[];
enum jtag_tap_event
{
enum jtag_tap_event {
JTAG_TAP_EVENT_ENABLE,
JTAG_TAP_EVENT_DISABLE
};
extern const Jim_Nvp nvp_jtag_tap_event[];
struct jtag_tap_event_action_s {
struct jtag_tap_event_action_s
{
enum jtag_tap_event event;
Jim_Obj* body;
jtag_tap_event_action_t* next;
@ -315,14 +435,11 @@ typedef struct jtag_event_callback_s
extern jtag_event_callback_t* jtag_event_callbacks;
extern jtag_interface_t* jtag; /* global pointer to configured JTAG interface */
extern enum tap_state end_state;
extern enum tap_state cur_state;
extern int jtag_speed;
extern int jtag_speed_post_reset;
enum reset_types
{
enum reset_types {
RESET_NONE = 0x0,
RESET_HAS_TRST = 0x1,
RESET_HAS_SRST = 0x2,
@ -339,10 +456,12 @@ extern enum reset_types jtag_reset_config;
* upon subsequent invocations
*/
extern int jtag_interface_init(struct command_context_s* cmd_ctx);
/* initialize JTAG chain using only a RESET reset. If init fails,
* try reset + init.
*/
extern int jtag_init(struct command_context_s* cmd_ctx);
/* reset, then initialize JTAG chain */
extern int jtag_init_reset(struct command_context_s* cmd_ctx);
extern int jtag_register_commands(struct command_context_s* cmd_ctx);
@ -359,19 +478,21 @@ extern int jtag_register_commands(struct command_context_s *cmd_ctx);
* be issued.
*
*/
extern void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
extern void jtag_add_ir_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern int interface_jtag_add_ir_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern void jtag_add_dr_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern int interface_jtag_add_dr_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern void jtag_add_plain_ir_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern void jtag_add_plain_dr_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
/* run a TAP_RESET reset. End state is TAP_RESET, regardless
* of start state.
*/
extern void jtag_add_tlr(void);
extern int interface_jtag_add_tlr(void);
/* Do not use jtag_add_pathmove() unless you need to, but do use it
* if you have to.
*
@ -402,8 +523,9 @@ extern int interface_jtag_add_tlr(void);
* a partial implementation of pathmove would have little practical
* application.
*/
extern void jtag_add_pathmove(int num_states, enum tap_state *path);
extern int interface_jtag_add_pathmove(int num_states, enum tap_state *path);
extern void jtag_add_pathmove(int num_states, tap_state_t* path);
extern int interface_jtag_add_pathmove(int num_states, tap_state_t* path);
/* go to TAP_IDLE, if we're not already there and cycle
* precisely num_cycles in the TAP_IDLE after which move
* to the end state, if it is != TAP_IDLE
@ -411,8 +533,9 @@ extern int interface_jtag_add_pathmove(int num_states, enum tap_state *path);
* nb! num_cycles can be 0, in which case the fn will navigate
* to endstate via TAP_IDLE
*/
extern void jtag_add_runtest(int num_cycles, enum tap_state endstate);
extern int interface_jtag_add_runtest(int num_cycles, enum tap_state endstate);
extern void jtag_add_runtest(int num_cycles, tap_state_t endstate);
extern int interface_jtag_add_runtest(int num_cycles, tap_state_t endstate);
/* A reset of the TAP state machine can be requested.
*
* Whether tms or trst reset is used depends on the capabilities of
@ -436,6 +559,7 @@ extern int interface_jtag_add_runtest(int num_cycles, enum tap_state endstate);
* then trst & srst *must* be asserted together.
*/
extern void jtag_add_reset(int req_tlr_or_trst, int srst);
/* this drives the actual srst and trst pins. srst will always be 0
* if jtag_reset_config & RESET_SRST_PULLS_TRST != 0 and ditto for
* trst.
@ -444,8 +568,8 @@ extern void jtag_add_reset(int req_tlr_or_trst, int srst);
* approperiate
*/
extern int interface_jtag_add_reset(int trst, int srst);
extern void jtag_add_end_state(enum tap_state endstate);
extern int interface_jtag_add_end_state(enum tap_state endstate);
extern void jtag_add_end_state(tap_state_t endstate);
extern int interface_jtag_add_end_state(tap_state_t endstate);
extern void jtag_add_sleep(u32 us);
extern int interface_jtag_add_sleep(u32 us);
@ -480,6 +604,7 @@ int interface_jtag_add_clocks( int num_cycles );
* at some time between the jtag_add_xxx() fn call and jtag_execute_queue().
*/
extern int jtag_execute_queue(void);
/* can be implemented by hw+sw */
extern int interface_jtag_execute_queue(void);
extern int jtag_power_dropout(int* dropout);
@ -519,6 +644,7 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e);
#define MINIDRIVER(a) notused ## a
#else
#define MINIDRIVER(a) a
/* jtag_add_dr_out() is a faster version of jtag_add_dr_scan()
*
* Current or end_state can not be TAP_RESET. end_state can be -1
@ -536,18 +662,13 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e);
*
* Note that this jtag_add_dr_out can be defined as an inline function.
*/
extern void interface_jtag_add_dr_out(jtag_tap_t *tap,
int num_fields,
const int *num_bits,
const u32 *value,
enum tap_state end_state);
extern void interface_jtag_add_dr_out(jtag_tap_t* tap, int num_fields, const int* num_bits, const u32* value,
tap_state_t end_state);
#endif
static __inline__ void jtag_add_dr_out(jtag_tap_t *tap,
int num_fields,
const int *num_bits,
const u32 *value,
enum tap_state end_state)
static __inline__ void jtag_add_dr_out(jtag_tap_t* tap, int num_fields, const int* num_bits, const u32* value,
tap_state_t end_state)
{
if (end_state != -1)
cmd_queue_end_state = end_state;
@ -555,11 +676,5 @@ static __inline__ void jtag_add_dr_out(jtag_tap_t *tap,
interface_jtag_add_dr_out(tap, num_fields, num_bits, value, cmd_queue_end_state);
}
/**
* Function jtag_state_name
* Returns a string suitable for display representing the JTAG tap_state
*/
const char* jtag_state_name(enum tap_state state);
#endif /* JTAG_H */

View File

@ -890,10 +890,10 @@ tap_state_queue_append(
static
void rlink_end_state(enum tap_state state)
void rlink_end_state(tap_state_t state)
{
if (tap_move_map[state] != -1)
end_state = state;
if (tap_is_state_stable(state))
tap_set_end_state(state);
else
{
LOG_ERROR("BUG: %i is not a valid end state", state);
@ -906,7 +906,7 @@ static
void rlink_state_move(void) {
int i=0, tms=0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
for (i = 0; i < 7; i++)
{
@ -914,7 +914,7 @@ void rlink_state_move(void) {
tap_state_queue_append(tms);
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
static
@ -927,28 +927,28 @@ void rlink_path_move(pathmove_command_t *cmd)
state_count = 0;
while (num_states)
{
if (tap_transitions[cur_state].low == cmd->path[state_count])
if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
{
tms = 0;
}
else if (tap_transitions[cur_state].high == cmd->path[state_count])
else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
{
tms = 1;
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(cmd->path[state_count]));
exit(-1);
}
tap_state_queue_append(tms);
cur_state = cmd->path[state_count];
tap_set_state(cmd->path[state_count]);
state_count++;
num_states--;
}
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
@ -957,10 +957,10 @@ void rlink_runtest(int num_cycles)
{
int i;
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in RTI */
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
rlink_end_state(TAP_IDLE);
rlink_state_move();
@ -974,7 +974,7 @@ void rlink_runtest(int num_cycles)
/* finish in end_state */
rlink_end_state(saved_end_state);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
rlink_state_move();
}
@ -1031,7 +1031,7 @@ rlink_scan(
int scan_size
) {
int ir_scan;
enum tap_state saved_end_state;
tap_state_t saved_end_state;
int byte_bits;
int extra_bits;
int chunk_bits;
@ -1051,11 +1051,11 @@ rlink_scan(
/* Move to the proper state before starting to shift TDI/TDO. */
if (!(
(!ir_scan && (cur_state == TAP_DRSHIFT))
(!ir_scan && (tap_get_state() == TAP_DRSHIFT))
||
(ir_scan && (cur_state == TAP_IRSHIFT))
(ir_scan && (tap_get_state() == TAP_IRSHIFT))
)) {
saved_end_state = end_state;
saved_end_state = tap_get_end_state();
rlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
rlink_state_move();
rlink_end_state(saved_end_state);
@ -1303,8 +1303,8 @@ rlink_scan(
/* Move to pause state */
tap_state_queue_append(0);
cur_state = ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE;
if (cur_state != end_state) rlink_state_move();
tap_set_state(ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE);
if (tap_get_state() != tap_get_end_state()) rlink_state_move();
return(0);
}
@ -1363,7 +1363,7 @@ int rlink_execute_queue(void)
#endif
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
rlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;

View File

@ -58,7 +58,7 @@ int usbprog_register_commands(struct command_context_s *cmd_ctx);
int usbprog_init(void);
int usbprog_quit(void);
void usbprog_end_state(enum tap_state state);
void usbprog_end_state(tap_state_t state);
void usbprog_state_move(void);
void usbprog_path_move(pathmove_command_t *cmd);
void usbprog_runtest(int num_cycles);
@ -151,7 +151,7 @@ int usbprog_execute_queue(void)
#endif
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
@ -235,10 +235,10 @@ int usbprog_quit(void)
}
/*************** jtag execute commands **********************/
void usbprog_end_state(enum tap_state state)
void usbprog_end_state(tap_state_t state)
{
if (tap_move_map[state] != -1)
end_state = state;
if (tap_is_state_stable(state))
tap_set_end_state(state);
else
{
LOG_ERROR("BUG: %i is not a valid end state", state);
@ -249,7 +249,7 @@ void usbprog_end_state(enum tap_state state)
void usbprog_state_move(void)
{
int i = 0, tms = 0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
usbprog_jtag_write_tms(usbprog_jtag_handle, (char)tms_scan);
for (i = 0; i < 7; i++)
@ -257,7 +257,7 @@ void usbprog_state_move(void)
tms = (tms_scan >> i) & 1;
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
void usbprog_path_move(pathmove_command_t *cmd)
@ -268,13 +268,13 @@ void usbprog_path_move(pathmove_command_t *cmd)
state_count = 0;
while (num_states)
{
if (tap_transitions[cur_state].low == cmd->path[state_count])
if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
{
/* LOG_INFO("1"); */
usbprog_write(0, 0, 0);
usbprog_write(1, 0, 0);
}
else if (tap_transitions[cur_state].high == cmd->path[state_count])
else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
{
/* LOG_INFO("2"); */
usbprog_write(0, 1, 0);
@ -282,16 +282,16 @@ void usbprog_path_move(pathmove_command_t *cmd)
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(cmd->path[state_count]));
exit(-1);
}
cur_state = cmd->path[state_count];
tap_set_state(cmd->path[state_count]);
state_count++;
num_states--;
}
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
void usbprog_runtest(int num_cycles)
@ -299,7 +299,7 @@ void usbprog_runtest(int num_cycles)
int i;
/* only do a state_move when we're not already in IDLE */
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
usbprog_end_state(TAP_IDLE);
usbprog_state_move();
@ -326,14 +326,14 @@ void usbprog_runtest(int num_cycles)
/* finish in end_state */
/*
usbprog_end_state(saved_end_state);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
usbprog_state_move();
*/
}
void usbprog_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
{
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
if (ir_scan)
usbprog_end_state(TAP_IRSHIFT);
@ -361,11 +361,11 @@ void usbprog_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
}
if (ir_scan)
cur_state = TAP_IRPAUSE;
tap_set_state(TAP_IRPAUSE);
else
cur_state = TAP_DRPAUSE;
tap_set_state(TAP_DRPAUSE);
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
usbprog_state_move();
}

View File

@ -92,7 +92,7 @@ static u8* vsllink_usb_out_buffer = NULL;
#define JTAG_PINMSK_TDO (1 << 7)
#define VSLLINK_TAP_MOVE(from, to) VSLLINK_tap_move[tap_move_map[from]][tap_move_map[to]]
#define VSLLINK_TAP_MOVE(from, to) VSLLINK_tap_move[tap_move_ndx(from)][tap_move_ndx(to)]
/* VSLLINK_tap_move[i][j]: tap movement command to go from state i to state j
* 0: Test-Logic-Reset
@ -202,9 +202,9 @@ int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *c
int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* Queue command functions */
void vsllink_end_state(enum tap_state state);
void vsllink_end_state(tap_state_t state);
void vsllink_state_move(void);
void vsllink_path_move(int num_states, enum tap_state *path);
void vsllink_path_move(int num_states, tap_state_t *path);
void vsllink_runtest(int num_cycles);
void vsllink_stableclocks(int num_cycles, int tms);
void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command);
@ -267,7 +267,7 @@ int vsllink_execute_queue(void)
switch (cmd->type)
{
case JTAG_END_STATE:
DEBUG_JTAG_IO("end_state: %s", jtag_state_name(cmd->cmd.end_state->end_state));
DEBUG_JTAG_IO("end_state: %s", tap_state_name(cmd->cmd.end_state->end_state));
if (cmd->cmd.end_state->end_state != -1)
{
@ -277,7 +277,7 @@ int vsllink_execute_queue(void)
case JTAG_RUNTEST:
DEBUG_JTAG_IO( "runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, \
jtag_state_name(cmd->cmd.runtest->end_state));
tap_state_name(cmd->cmd.runtest->end_state));
if (cmd->cmd.runtest->end_state != -1)
{
@ -287,7 +287,7 @@ int vsllink_execute_queue(void)
break;
case JTAG_STATEMOVE:
DEBUG_JTAG_IO("statemove end in %s", jtag_state_name(cmd->cmd.statemove->end_state));
DEBUG_JTAG_IO("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state));
if (cmd->cmd.statemove->end_state != -1)
{
@ -299,7 +299,7 @@ int vsllink_execute_queue(void)
case JTAG_PATHMOVE:
DEBUG_JTAG_IO("pathmove: %i states, end in %s", \
cmd->cmd.pathmove->num_states, \
jtag_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
vsllink_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path);
break;
@ -313,11 +313,11 @@ int vsllink_execute_queue(void)
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
if (cmd->cmd.scan->ir_scan)
{
DEBUG_JTAG_IO("JTAG Scan write IR(%d bits), end in %s:", scan_size, jtag_state_name(cmd->cmd.scan->end_state));
DEBUG_JTAG_IO("JTAG Scan write IR(%d bits), end in %s:", scan_size, tap_state_name(cmd->cmd.scan->end_state));
}
else
{
DEBUG_JTAG_IO("JTAG Scan write DR(%d bits), end in %s:", scan_size, jtag_state_name(cmd->cmd.scan->end_state));
DEBUG_JTAG_IO("JTAG Scan write DR(%d bits), end in %s:", scan_size, tap_state_name(cmd->cmd.scan->end_state));
}
#ifdef _DEBUG_JTAG_IO_
@ -336,7 +336,7 @@ int vsllink_execute_queue(void)
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_RESET;
tap_set_state(TAP_RESET);
}
vsllink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
@ -352,7 +352,7 @@ int vsllink_execute_queue(void)
case JTAG_STABLECLOCKS:
DEBUG_JTAG_IO("add %d clocks", cmd->cmd.stableclocks->num_cycles);
switch(cur_state)
switch(tap_get_state())
{
case TAP_RESET:
// tms should be '1' to stay in TAP_RESET mode
@ -368,7 +368,7 @@ int vsllink_execute_queue(void)
break; /* above stable states are OK */
default:
LOG_ERROR( "jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
jtag_state_name(cur_state) );
tap_state_name(tap_get_state()) );
exit(-1);
}
vsllink_stableclocks(cmd->cmd.stableclocks->num_cycles, scan_size);
@ -555,10 +555,11 @@ int vsllink_quit(void)
// length of VSLLINK_CMDJTAGSEQ_TMSBYTE has been set, no need to set it here.
void vsllink_append_tms(void)
{
u8 tms_scan = VSLLINK_TAP_MOVE(cur_state, end_state);
u8 tms_scan = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state());
u16 tms2;
tap_state_t end_state = tap_get_end_state();
if (((cur_state != TAP_RESET) && (cur_state != TAP_IDLE) && (cur_state != TAP_DRPAUSE) && (cur_state != TAP_IRPAUSE)) || \
if (((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_DRPAUSE) && (tap_get_state() != TAP_IRPAUSE)) || \
(vsllink_tms_data_len <= 0) || (vsllink_tms_data_len >= 8) || \
(vsllink_tms_cmd_pos == NULL))
{
@ -566,15 +567,15 @@ void vsllink_append_tms(void)
exit(-1);
}
tms2 = (tms_scan & VSLLINK_BIT_MSK[VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_map[cur_state]][tap_move_map[end_state]].insert_position]) << \
tms2 = (tms_scan & VSLLINK_BIT_MSK[VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position]) << \
vsllink_tms_data_len;
if (VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_map[cur_state]][tap_move_map[end_state]].insert_value == 1)
if (VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_value == 1)
{
tms2 |= VSLLINK_BIT_MSK[8 - vsllink_tms_data_len] << \
(vsllink_tms_data_len + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_map[cur_state]][tap_move_map[end_state]].insert_position);
(vsllink_tms_data_len + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position);
}
tms2 |= (tms_scan >> VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_map[cur_state]][tap_move_map[end_state]].insert_position) << \
(8 + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_map[cur_state]][tap_move_map[end_state]].insert_position);
tms2 |= (tms_scan >> VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position) << \
(8 + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position);
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] |= (tms2 >> 0) & 0xff;
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tms2 >> 8) & 0xff;
@ -586,11 +587,11 @@ void vsllink_append_tms(void)
/***************************************************************************/
/* Queue command implementations */
void vsllink_end_state(enum tap_state state)
void vsllink_end_state(tap_state_t state)
{
if (tap_move_map[state] != -1)
if (tap_is_state_stable(state))
{
end_state = state;
tap_set_end_state(state);
}
else
{
@ -611,14 +612,14 @@ void vsllink_state_move(void)
vsllink_tap_ensure_space(0, 2);
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE;
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(cur_state, end_state);
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state());
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
// write tms from current vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]
void vsllink_add_path(int start, int num, enum tap_state *path)
void vsllink_add_path(int start, int num, tap_state_t *path)
{
int i;
@ -633,20 +634,20 @@ void vsllink_add_path(int start, int num, enum tap_state *path)
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0;
}
if (path[i - start] == tap_transitions[cur_state].high)
if (path[i - start] == tap_state_transition(tap_get_state(), TRUE))
{
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] |= 1 << (i & 7);
}
else if (path[i - start] == tap_transitions[cur_state].low)
else if (path[i - start] == tap_state_transition(tap_get_state(), FALSE))
{
// nothing to do
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[i]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(path[i]));
exit(-1);
}
cur_state = path[i - start];
tap_set_state(path[i - start]);
}
if ((i > 0) && ((i & 7) == 0))
{
@ -654,10 +655,10 @@ void vsllink_add_path(int start, int num, enum tap_state *path)
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0;
}
end_state = cur_state;
tap_set_end_state(tap_get_state());
}
void vsllink_path_move(int num_states, enum tap_state *path)
void vsllink_path_move(int num_states, tap_state_t *path)
{
int i, tms_len, tms_cmd_pos, path_idx = 0;
@ -934,9 +935,9 @@ void vsllink_stableclocks(int num_cycles, int tms)
void vsllink_runtest(int num_cycles)
{
enum tap_state saved_end_state = end_state;
tap_state_t saved_end_state = tap_get_end_state();
if (cur_state != TAP_IDLE)
if (tap_get_state() != TAP_IDLE)
{
// enter into IDLE state
vsllink_end_state(TAP_IDLE);
@ -948,8 +949,8 @@ void vsllink_runtest(int num_cycles)
// post-process
// set end_state
vsllink_end_state(saved_end_state);
cur_state = TAP_IDLE;
if (end_state != TAP_IDLE)
tap_set_state(TAP_IDLE);
if (tap_get_end_state() != TAP_IDLE)
{
vsllink_state_move();
}
@ -957,7 +958,7 @@ void vsllink_runtest(int num_cycles)
void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command)
{
enum tap_state saved_end_state;
tap_state_t saved_end_state;
u8 bits_left, tms_tmp, tdi_len;
int i;
@ -973,14 +974,14 @@ void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, s
exit(-1);
}
saved_end_state = end_state;
saved_end_state = tap_get_end_state();
/* Move to appropriate scan state */
vsllink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
if (vsllink_tms_data_len > 0)
{
if (cur_state == end_state)
if (tap_get_state() == tap_get_end_state())
{
// already in IRSHIFT or DRSHIFT state
// merge tms data in the last tms shift command into next scan command
@ -1041,7 +1042,7 @@ void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, s
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN | 1;
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 0) & 0xff;
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1)>> 8) & 0xff;
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(cur_state, end_state);
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state());
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0;
vsllink_tap_append_scan(scan_size, buffer, command, 8);
@ -1049,7 +1050,7 @@ void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, s
vsllink_end_state(saved_end_state);
bits_left = scan_size & 0x07;
cur_state = ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE;
tap_set_state(ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE);
if (bits_left > 0)
{
@ -1060,16 +1061,16 @@ void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, s
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 1 << 7;
}
if (cur_state != end_state)
if (tap_get_state() != tap_get_end_state())
{
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(cur_state, end_state);
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state());
}
else
{
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0;
}
cur_state = end_state;
tap_set_state(tap_get_end_state());
}
void vsllink_reset(int trst, int srst)
@ -1218,9 +1219,9 @@ int vsllink_tap_execute(void)
if (vsllink_tms_data_len > 0)
{
if((cur_state != TAP_RESET) && (cur_state != TAP_IDLE) && (cur_state != TAP_IRPAUSE) && (cur_state != TAP_DRPAUSE))
if((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_IRPAUSE) && (tap_get_state() != TAP_DRPAUSE))
{
LOG_WARNING("%s is not in RESET or IDLE or PAUSR state", jtag_state_name(cur_state));
LOG_WARNING("%s is not in RESET or IDLE or PAUSR state", tap_state_name(tap_get_state()));
}
if (vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] & (1 << (vsllink_tms_data_len - 1)))

View File

@ -424,9 +424,9 @@ static cyg_uint32 getShiftValueFlip(void)
#endif
#if 0
static void shiftValueInnerFlip(const enum tap_state state, const enum tap_state endState, int repeat, cyg_uint32 value)
static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endState, int repeat, cyg_uint32 value)
{
VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", jtag_state_name(state), jtag_state_name(endState), repeat, value));
VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", tap_state_name(state), tap_state_name(endState), repeat, value));
cyg_uint32 a,b;
a=state;
b=endState;
@ -443,7 +443,7 @@ static void gotoEndState(void)
setCurrentState(cmd_queue_end_state);
}
static __inline void scanFields(int num_fields, scan_field_t *fields, enum tap_state shiftState, int pause)
static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_t shiftState, int pause)
{
int i;
int j;
@ -487,7 +487,7 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, enum tap_s
j=0;
while (j<num_bits)
{
enum tap_state pause_state;
tap_state_t pause_state;
int l;
k=num_bits-j;
pause_state=(shiftState==TAP_DRSHIFT)?TAP_DRSHIFT:TAP_IRSHIFT;
@ -544,13 +544,13 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, enum tap_s
}
}
int interface_jtag_add_end_state(enum tap_state state)
int interface_jtag_add_end_state(tap_state_t state)
{
return ERROR_OK;
}
int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
int j;
@ -614,7 +614,7 @@ int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_st
int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
scanFields(num_fields, fields, TAP_IRSHIFT, 1);
gotoEndState();
@ -624,7 +624,7 @@ int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum
/*extern jtag_command_t **jtag_get_last_command_p(void);*/
int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
int j;
@ -667,7 +667,7 @@ int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_st
return ERROR_OK;
}
int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, tap_state_t state)
{
scanFields(num_fields, fields, TAP_DRSHIFT, 1);
gotoEndState();
@ -693,7 +693,7 @@ int interface_jtag_add_reset(int req_trst, int req_srst)
return ERROR_OK;
}
static int zy1000_jtag_add_clocks(int num_cycles, enum tap_state state, enum tap_state clockstate)
static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t clockstate)
{
/* num_cycles can be 0 */
setCurrentState(clockstate);
@ -715,10 +715,10 @@ static int zy1000_jtag_add_clocks(int num_cycles, enum tap_state state, enum tap
/* finish in end_state */
setCurrentState(state);
#else
enum tap_state t=TAP_IDLE;
tap_state_t t=TAP_IDLE;
/* test manual drive code on any target */
int tms;
u8 tms_scan = TAP_MOVE(t, state);
u8 tms_scan = tap_get_tms_path(t, state);
for (i = 0; i < 7; i++)
{
@ -734,7 +734,7 @@ static int zy1000_jtag_add_clocks(int num_cycles, enum tap_state state, enum tap
return ERROR_OK;
}
int interface_jtag_add_runtest(int num_cycles, enum tap_state state)
int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
{
return zy1000_jtag_add_clocks(num_cycles, state, TAP_IDLE);
}
@ -750,7 +750,7 @@ int interface_jtag_add_sleep(u32 us)
return ERROR_OK;
}
int interface_jtag_add_pathmove(int num_states, enum tap_state *path)
int interface_jtag_add_pathmove(int num_states, tap_state_t *path)
{
int state_count;
int tms = 0;
@ -760,21 +760,21 @@ int interface_jtag_add_pathmove(int num_states, enum tap_state *path)
state_count = 0;
enum tap_state cur_state=cmd_queue_cur_state;
tap_state_t cur_state=cmd_queue_cur_state;
while (num_states)
{
if (tap_transitions[cur_state].low == path[state_count])
if (tap_state_transition(cur_state, FALSE) == path[state_count])
{
tms = 0;
}
else if (tap_transitions[cur_state].high == path[state_count])
else if (tap_state_transition(cur_state, TRUE) == path[state_count])
{
tms = 1;
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[state_count]));
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[state_count]));
exit(-1);
}
@ -796,7 +796,7 @@ int interface_jtag_add_pathmove(int num_states, enum tap_state *path)
void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, u8 *buffer, int little, int count)
{
// static int const reg_addr=0x5;
enum tap_state end_state=cmd_queue_end_state;
tap_state_t end_state=cmd_queue_end_state;
if (jtag_NextEnabledTap(jtag_NextEnabledTap(NULL))==NULL)
{
/* better performance via code duplication */

View File

@ -318,7 +318,7 @@ static int handle_svf_command(struct command_context_s *cmd_ctx, char *cmd, char
memcpy(&svf_para, &svf_para_init, sizeof(svf_para));
for (i = 0; i < dimof(svf_tap_state_name); i++)
{
svf_tap_state_name[i] = (char *)jtag_state_name(i);
svf_tap_state_name[i] = (char *)tap_state_name(i);
}
// TAP_RESET
jtag_add_tlr();

View File

@ -230,9 +230,9 @@ void arm11_dump_reg_changes(arm11_common_t * arm11);
/* internals */
void arm11_setup_field (arm11_common_t * arm11, int num_bits, void * in_data, void * out_data, scan_field_t * field);
void arm11_add_IR (arm11_common_t * arm11, u8 instr, enum tap_state state);
void arm11_add_debug_SCAN_N (arm11_common_t * arm11, u8 chain, enum tap_state state);
void arm11_add_debug_INST (arm11_common_t * arm11, u32 inst, u8 * flag, enum tap_state state);
void arm11_add_IR (arm11_common_t * arm11, u8 instr, tap_state_t state);
void arm11_add_debug_SCAN_N (arm11_common_t * arm11, u8 chain, tap_state_t state);
void arm11_add_debug_INST (arm11_common_t * arm11, u32 inst, u8 * flag, tap_state_t state);
u32 arm11_read_DSCR (arm11_common_t * arm11);
void arm11_write_DSCR (arm11_common_t * arm11, u32 dscr);
@ -249,8 +249,8 @@ void arm11_run_instr_data_from_core (arm11_common_t * arm11, u32 opcode, u32 *
void arm11_run_instr_data_from_core_via_r0 (arm11_common_t * arm11, u32 opcode, u32 * data);
void arm11_run_instr_data_to_core_via_r0 (arm11_common_t * arm11, u32 opcode, u32 data);
int arm11_add_dr_scan_vc(int num_fields, scan_field_t *fields, enum tap_state state);
int arm11_add_ir_scan_vc(int num_fields, scan_field_t *fields, enum tap_state state);
int arm11_add_dr_scan_vc(int num_fields, scan_field_t *fields, tap_state_t state);
int arm11_add_ir_scan_vc(int num_fields, scan_field_t *fields, tap_state_t state);
/** Used to make a list of read/write commands for scan chain 7
*

View File

@ -36,13 +36,13 @@
#define JTAG_DEBUG(expr ...) do {} while(0)
#endif
enum tap_state arm11_move_pi_to_si_via_ci[] =
tap_state_t arm11_move_pi_to_si_via_ci[] =
{
TAP_IREXIT2, TAP_IRUPDATE, TAP_DRSELECT, TAP_IRSELECT, TAP_IRCAPTURE, TAP_IRSHIFT
};
int arm11_add_ir_scan_vc(int num_fields, scan_field_t *fields, enum tap_state state)
int arm11_add_ir_scan_vc(int num_fields, scan_field_t *fields, tap_state_t state)
{
if (cmd_queue_cur_state == TAP_IRPAUSE)
jtag_add_pathmove(asizeof(arm11_move_pi_to_si_via_ci), arm11_move_pi_to_si_via_ci);
@ -51,12 +51,12 @@ int arm11_add_ir_scan_vc(int num_fields, scan_field_t *fields, enum tap_state st
return ERROR_OK;
}
enum tap_state arm11_move_pd_to_sd_via_cd[] =
tap_state_t arm11_move_pd_to_sd_via_cd[] =
{
TAP_DREXIT2, TAP_DRUPDATE, TAP_DRSELECT, TAP_DRCAPTURE, TAP_DRSHIFT
};
int arm11_add_dr_scan_vc(int num_fields, scan_field_t *fields, enum tap_state state)
int arm11_add_dr_scan_vc(int num_fields, scan_field_t *fields, tap_state_t state)
{
if (cmd_queue_cur_state == TAP_DRPAUSE)
jtag_add_pathmove(asizeof(arm11_move_pd_to_sd_via_cd), arm11_move_pd_to_sd_via_cd);
@ -99,7 +99,7 @@ void arm11_setup_field(arm11_common_t * arm11, int num_bits, void * out_data, vo
*
* \remarks This adds to the JTAG command queue but does \em not execute it.
*/
void arm11_add_IR(arm11_common_t * arm11, u8 instr, enum tap_state state)
void arm11_add_IR(arm11_common_t * arm11, u8 instr, tap_state_t state)
{
jtag_tap_t *tap;
tap = arm11->jtag_info.tap;
@ -167,7 +167,7 @@ static int arm11_in_handler_SCAN_N(u8 *in_value, void *priv, struct scan_field_s
* \remarks This adds to the JTAG command queue but does \em not execute it.
*/
void arm11_add_debug_SCAN_N(arm11_common_t * arm11, u8 chain, enum tap_state state)
void arm11_add_debug_SCAN_N(arm11_common_t * arm11, u8 chain, tap_state_t state)
{
JTAG_DEBUG("SCREG <= 0x%02x", chain);
@ -199,7 +199,7 @@ void arm11_add_debug_SCAN_N(arm11_common_t * arm11, u8 chain, enum tap_state sta
*
* \remarks This adds to the JTAG command queue but does \em not execute it.
*/
void arm11_add_debug_INST(arm11_common_t * arm11, u32 inst, u8 * flag, enum tap_state state)
void arm11_add_debug_INST(arm11_common_t * arm11, u32 inst, u8 * flag, tap_state_t state)
{
JTAG_DEBUG("INST <= 0x%08x", inst);
@ -471,7 +471,7 @@ void arm11_run_instr_data_to_core(arm11_common_t * arm11, u32 opcode, u32 * data
* the core but still shorter than any manually inducible delays.
*
*/
enum tap_state arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay[] =
tap_state_t arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay[] =
{
TAP_DREXIT2, TAP_DRUPDATE, TAP_IDLE, TAP_IDLE, TAP_IDLE, TAP_DRSELECT, TAP_DRCAPTURE, TAP_DRSHIFT
};

View File

@ -318,7 +318,7 @@ int xscale_receive(target_t *target, u32 *buffer, int num_words)
armv4_5_common_t *armv4_5 = target->arch_info;
xscale_common_t *xscale = armv4_5->arch_info;
enum tap_state path[3];
tap_state_t path[3];
scan_field_t fields[3];
u8 *field0 = malloc(num_words * 1);
@ -427,8 +427,8 @@ int xscale_read_tx(target_t *target, int consume)
{
armv4_5_common_t *armv4_5 = target->arch_info;
xscale_common_t *xscale = armv4_5->arch_info;
enum tap_state path[3];
enum tap_state noconsume_path[6];
tap_state_t path[3];
tap_state_t noconsume_path[6];
int retval;
struct timeval timeout, now;

View File

@ -141,7 +141,7 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
static int xsvf_fd = 0;
/* map xsvf tap state to an openocd "enum tap_state" */
/* map xsvf tap state to an openocd "tap_state_t" */
static tap_state_t xsvf_to_tap( int xsvf_state )
{
tap_state_t ret;
@ -185,7 +185,7 @@ static void xsvf_add_statemove(tap_state_t state)
tap_state_t curstate = cmd_queue_cur_state;
int i;
u8 move = TAP_MOVE(cmd_queue_cur_state, state);
u8 move = tap_get_tms_path(cmd_queue_cur_state, state);
if (state != TAP_RESET && state==cmd_queue_cur_state)
return;
@ -201,11 +201,11 @@ static void xsvf_add_statemove(tap_state_t state)
int j = (move >> i) & 1;
if (j)
{
curstate = tap_transitions[curstate].high;
curstate = tap_state_transition(curstate, TRUE);
}
else
{
curstate = tap_transitions[curstate].low;
curstate = tap_state_transition(curstate, FALSE);
}
moves[i] = curstate;
}
@ -257,7 +257,7 @@ static int xsvf_read_xstates(int fd, tap_state_t *path, int max_path, int *path_
mystate = xsvf_to_tap(uc);
LOG_DEBUG("XSTATE %02X %s", uc, jtag_state_name(mystate) );
LOG_DEBUG("XSTATE %02X %s", uc, tap_state_name(mystate) );
path[(*path_len)++] = mystate;
}
@ -581,7 +581,7 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
mystate = xsvf_to_tap(uc);
LOG_DEBUG("XSTATE 0x%02X %s", uc, jtag_state_name(mystate) );
LOG_DEBUG("XSTATE 0x%02X %s", uc, tap_state_name(mystate) );
path = calloc(XSTATE_MAX_PATH, 4);
path_len = 1;
@ -631,14 +631,14 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
/* see page 22 of XSVF spec */
mystate = uc == 1 ? TAP_IRPAUSE : TAP_IDLE;
LOG_DEBUG("XENDIR 0x%02X %s", uc, jtag_state_name(mystate));
LOG_DEBUG("XENDIR 0x%02X %s", uc, tap_state_name(mystate));
/* assuming that the XRUNTEST comes from SVF RUNTEST, then only these states
* should come here because the SVF spec only allows these with a RUNTEST
*/
if (mystate != TAP_IRPAUSE && mystate != TAP_DRPAUSE && mystate != TAP_RESET && mystate != TAP_IDLE )
{
LOG_ERROR("illegal XENDIR endstate: \"%s\"", jtag_state_name(mystate));
LOG_ERROR("illegal XENDIR endstate: \"%s\"", tap_state_name(mystate));
unsupported = 1;
break;
}
@ -659,11 +659,11 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
/* see page 22 of XSVF spec */
mystate = uc == 1 ? TAP_DRPAUSE : TAP_IDLE;
LOG_DEBUG("XENDDR %02X %s", uc, jtag_state_name(mystate));
LOG_DEBUG("XENDDR %02X %s", uc, tap_state_name(mystate));
if (mystate != TAP_IRPAUSE && mystate != TAP_DRPAUSE && mystate != TAP_RESET && mystate != TAP_IDLE )
{
LOG_ERROR("illegal XENDDR endstate: \"%s\"", jtag_state_name( mystate ));
LOG_ERROR("illegal XENDDR endstate: \"%s\"", tap_state_name( mystate ));
unsupported = 1;
break;
}
@ -798,7 +798,7 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
end_state = xsvf_to_tap(end);
delay = be_to_h_u32(delay_buf);
LOG_DEBUG("XWAIT %s %s usecs:%d", jtag_state_name(wait_state), jtag_state_name(end_state), delay);
LOG_DEBUG("XWAIT %s %s usecs:%d", tap_state_name(wait_state), tap_state_name(end_state), delay);
if (runtest_requires_tck && wait_state == TAP_IDLE )
{
@ -844,8 +844,8 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
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),
tap_state_name(wait_state),
tap_state_name(end_state),
clock_count, usecs);
/* the following states are 'stable', meaning that they have a transition
@ -855,7 +855,7 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
*/
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 ));
LOG_ERROR("illegal XWAITSTATE wait_state: \"%s\"", tap_state_name( wait_state ));
unsupported = 1;
}
@ -908,7 +908,7 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha
loop_clocks = be_to_h_u32(clock_buf);
loop_usecs = be_to_h_u32(usecs_buf);
LOG_DEBUG("LDELAY %s clocks:%d usecs:%d", jtag_state_name(loop_state), loop_clocks, loop_usecs);
LOG_DEBUG("LDELAY %s clocks:%d usecs:%d", tap_state_name(loop_state), loop_clocks, loop_usecs);
}
break;

View File

@ -704,6 +704,8 @@ try:
nextTok()
if tokVal != ';':
raise ParseError( tokLn, tokVal, "Expecting ';' after TRST trst_mode")
if doCOMMENTs:
writeComment( output, tokLn, 'TRST %s' % trst_mode )
obuf = bytearray( 2 )
obuf[0] = XTRST
obuf[1] = trst_mode_allowed.index( trst_mode ) # use the index as the binary argument to XTRST opcode