]> git.sur5r.net Git - openocd/commitdiff
- Update tap_state_strings to correspond to SVF state names
authorkc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 14 Dec 2008 20:33:01 +0000 (20:33 +0000)
committerkc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 14 Dec 2008 20:33:01 +0000 (20:33 +0000)
- 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

src/jtag/bitbang.c
src/jtag/bitq.c
src/jtag/ft2232.c
src/jtag/gw16012.c
src/jtag/jlink.c
src/jtag/jtag.c
src/jtag/jtag.h
src/jtag/usbprog.c
src/jtag/zy1000.c

index 8c4a3761c984f9ca24d9fe9ca1f217aa8fca7cb3..2d04e108af49d185c595dff9c9b15165dd58e004 100644 (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);
                }
 
index f347f7dc8753bdb02aabf601bc8b85a9b5169ae1..6dc9ec9690e3976c678cc02b81ee600294100602 100644 (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);
                }
 
index 5d79dfb613683db8e855a49e89a156c05d227ed6..773a92e6942196963f48bca5535154aad9675990 100644 (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);
                        }
 
index e03cea93ac4deea46cd33c8131cb37b088aa0134..f9bdec259b5b0bd7fd27b4c4e8e44a4f2d961786 100644 (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);
                }
 
index a764bc8cf1b7d22fbab393cac76f80fdabda9a94..04ce65c31f4f60675a428dd37398eb7ef0269503 100644 (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);
                }
 
index ca52872f113b6dc499fd5e4fc2d7954d5d560ef3..467ab7ae8e190cabaa9a52b89f2a7ecd6d7d52fa 100644 (file)
 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;
+}
+
index 16eeef5440c8e11eb4d297d93b1bc0f35be4a8c7..9a2bc423779b23054a5fa6381cfb6a4a4f19e306 100644 (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 */
index 872f7339455ae5fce2c376d798712f2abb855d46..419ad4e06fe0816ddba60db35727a6d8b1261080 100644 (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);
                }
 
index 315b785525ca7dff9737eea60292ae88b66330e5..160a51ef81a795432dd60032464217f337818b69 100644 (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);
                }