- Update tap_state_strings to correspond to SVF state names

- Use new jtag_state_name() instead of global tap_state_strings[]


git-svn-id: svn://svn.berlios.de/openocd/trunk@1240 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
kc8apf 2008-12-14 20:33:01 +00:00
parent 4238dd5053
commit 508ed7a7c6
9 changed files with 71 additions and 42 deletions

View File

@ -109,7 +109,7 @@ void bitbang_path_move(pathmove_command_t *cmd)
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
exit(-1);
}

View File

@ -172,7 +172,7 @@ void bitq_path_move(pathmove_command_t *cmd)
if (tap_transitions[cur_state].low == cmd->path[i]) bitq_io(0, 0, 0);
else if (tap_transitions[cur_state].high == cmd->path[i]) bitq_io(1, 0, 0);
else {
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[i]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[i)]);
exit(-1);
}

View File

@ -525,7 +525,7 @@ void ft2232_add_pathmove(pathmove_command_t *cmd)
buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
exit(-1);
}

View File

@ -240,7 +240,7 @@ void gw16012_path_move(pathmove_command_t *cmd)
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
exit(-1);
}

View File

@ -376,7 +376,7 @@ void jlink_path_move(int num_states, enum tap_state *path)
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[path[i]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[i]));
exit(-1);
}

View File

@ -41,14 +41,6 @@
int jtag_error=ERROR_OK;
char* tap_state_strings[16] =
{
"tlr",
"sds", "cd", "sd", "e1d", "pd", "e2d", "ud",
"rti",
"sis", "ci", "si", "e1i", "pi", "e2i", "ui"
};
typedef struct cmd_queue_page_s
{
void *address;
@ -1004,7 +996,7 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
if ((tap_transitions[cur_state].low != path[i])&&
(tap_transitions[cur_state].high != path[i]))
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[path[i]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[i]));
exit(-1);
}
cur_state = path[i];
@ -2656,14 +2648,14 @@ int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char *
{
for (state = 0; state < 16; state++)
{
if (strcmp(args[0], tap_state_strings[state]) == 0)
if (strcmp(args[0], jtag_state_name(state)) == 0)
{
jtag_add_end_state(state);
jtag_execute_queue();
}
}
}
command_print(cmd_ctx, "current endstate: %s", tap_state_strings[cmd_queue_end_state]);
command_print(cmd_ctx, "current endstate: %s", jtag_state_name(cmd_queue_end_state));
return ERROR_OK;
}
@ -2915,3 +2907,34 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
Jim_Nvp_value2name_simple( nvp_jtag_tap_event, e)->name);
}
}
/* map state number to SVF state string */
const char* jtag_state_name(enum tap_state state)
{
const char* ret;
switch( state )
{
case TAP_RESET: ret = "RESET"; break;
case TAP_IDLE: ret = "IDLE"; break;
case TAP_DRSELECT: ret = "DRSELECT"; break;
case TAP_DRCAPTURE: ret = "DRCAPTURE"; break;
case TAP_DRSHIFT: ret = "DRSHIFT"; break;
case TAP_DREXIT1: ret = "DREXIT1"; break;
case TAP_DRPAUSE: ret = "DRPAUSE"; break;
case TAP_DREXIT2: ret = "DREXIT2"; break;
case TAP_DRUPDATE: ret = "DRUPDATE"; break;
case TAP_IRSELECT: ret = "IRSELECT"; break;
case TAP_IRCAPTURE: ret = "IRCAPTURE"; break;
case TAP_IRSHIFT: ret = "IRSHIFT"; break;
case TAP_IREXIT1: ret = "IREXIT1"; break;
case TAP_IRPAUSE: ret = "IRPAUSE"; break;
case TAP_IREXIT2: ret = "IREXIT2"; break;
case TAP_IRUPDATE: ret = "IRUPDATE"; break;
default: ret = "???";
}
return ret;
}

View File

@ -50,7 +50,6 @@ typedef struct tap_transition_s
enum tap_state low;
} tap_transition_t;
extern char* tap_state_strings[16];
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 */
@ -529,4 +528,11 @@ 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

@ -282,7 +282,7 @@ void usbprog_path_move(pathmove_command_t *cmd)
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[state_count]));
exit(-1);
}

View File

@ -266,51 +266,51 @@ int zy1000_quit(void)
int loadFile(const char *fileName, void **data, int *len)
{
FILE * pFile;
pFile = fopen (fileName,"rb");
pFile = fopen(fileName,"rb");
if (pFile==NULL)
{
LOG_ERROR("Can't open %s\n", fileName);
return ERROR_JTAG_DEVICE_ERROR;
}
if (fseek (pFile, 0, SEEK_END)!=0)
{
if (fseek(pFile, 0, SEEK_END)!=0)
{
LOG_ERROR("Can't open %s\n", fileName);
fclose(pFile);
return ERROR_JTAG_DEVICE_ERROR;
}
*len=ftell (pFile);
if (*len==-1)
{
}
*len=ftell(pFile);
if (*len==-1)
{
LOG_ERROR("Can't open %s\n", fileName);
fclose(pFile);
return ERROR_JTAG_DEVICE_ERROR;
}
}
if (fseek (pFile, 0, SEEK_SET)!=0)
{
if (fseek(pFile, 0, SEEK_SET)!=0)
{
LOG_ERROR("Can't open %s\n", fileName);
fclose(pFile);
return ERROR_JTAG_DEVICE_ERROR;
}
*data=malloc(*len+1);
if (*data==NULL)
{
}
*data=malloc(*len+1);
if (*data==NULL)
{
LOG_ERROR("Can't open %s\n", fileName);
fclose(pFile);
return ERROR_JTAG_DEVICE_ERROR;
}
}
if (fread(*data, 1, *len, pFile)!=*len)
{
if (fread(*data, 1, *len, pFile)!=*len)
{
fclose(pFile);
free(*data);
LOG_ERROR("Can't open %s\n", fileName);
return ERROR_JTAG_DEVICE_ERROR;
}
fclose (pFile);
*(((char *)(*data))+*len)=0; /* sentinel */
}
fclose(pFile);
*(((char *)(*data))+*len)=0; /* sentinel */
return ERROR_OK;
return ERROR_OK;
@ -365,7 +365,7 @@ static cyg_uint32 getShiftValueFlip()
#if 0
static void shiftValueInnerFlip(const enum tap_state state, const enum tap_state endState, int repeat, cyg_uint32 value)
{
VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", tap_state_strings[state], tap_state_strings[endState], repeat, value));
VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", jtag_state_name(state), jtag_state_name(endState), repeat, value));
cyg_uint32 a,b;
a=state;
b=endState;
@ -476,7 +476,7 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, enum tap_s
int r=fields[i].in_handler(inBuffer, fields[i].in_handler_priv, fields+i);
if (r!=ERROR_OK)
{
/* this will cause jtag_execute_queue() to return an error */
/* this will cause jtag_execute_queue() to return an error */
jtag_error=r;
}
}
@ -703,7 +703,7 @@ int interface_jtag_add_pathmove(int num_states, enum tap_state *path)
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[path[state_count]]);
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[state_count)]);
exit(-1);
}