diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jtag/bitbang.c | 2 | ||||
-rw-r--r-- | src/jtag/bitq.c | 2 | ||||
-rw-r--r-- | src/jtag/ft2232.c | 2 | ||||
-rw-r--r-- | src/jtag/gw16012.c | 2 | ||||
-rw-r--r-- | src/jtag/jlink.c | 2 | ||||
-rw-r--r-- | src/jtag/jtag.c | 45 | ||||
-rw-r--r-- | src/jtag/jtag.h | 8 | ||||
-rw-r--r-- | src/jtag/usbprog.c | 2 | ||||
-rw-r--r-- | src/jtag/zy1000.c | 48 |
9 files changed, 71 insertions, 42 deletions
diff --git a/src/jtag/bitbang.c b/src/jtag/bitbang.c index 8c4a3761..2d04e108 100644 --- a/src/jtag/bitbang.c +++ b/src/jtag/bitbang.c @@ -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); } diff --git a/src/jtag/bitq.c b/src/jtag/bitq.c index f347f7dc..6dc9ec96 100644 --- a/src/jtag/bitq.c +++ b/src/jtag/bitq.c @@ -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); } diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c index 5d79dfb6..773a92e6 100644 --- a/src/jtag/ft2232.c +++ b/src/jtag/ft2232.c @@ -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); } diff --git a/src/jtag/gw16012.c b/src/jtag/gw16012.c index e03cea93..f9bdec25 100644 --- a/src/jtag/gw16012.c +++ b/src/jtag/gw16012.c @@ -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); } diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c index a764bc8c..04ce65c3 100644 --- a/src/jtag/jlink.c +++ b/src/jtag/jlink.c @@ -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); } diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index ca52872f..467ab7ae 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -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; +} + diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 16eeef54..9a2bc423 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -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 */ diff --git a/src/jtag/usbprog.c b/src/jtag/usbprog.c index 872f7339..419ad4e0 100644 --- a/src/jtag/usbprog.c +++ b/src/jtag/usbprog.c @@ -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); } diff --git a/src/jtag/zy1000.c b/src/jtag/zy1000.c index 315b7855..160a51ef 100644 --- a/src/jtag/zy1000.c +++ b/src/jtag/zy1000.c @@ -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); } |