make jtag_add_statemove() internal to the driver.
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 31 Mar 2008 13:18:03 +0000 (13:18 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 31 Mar 2008 13:18:03 +0000 (13:18 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@527 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/jtag.c
src/jtag/jtag.h
src/pld/virtex2.c
src/target/event/xba_revA3.script
src/target/target/wi-9c.cfg
src/xsvf/xsvf.c

index 8f55ea0bff88c18181523a9d616037838ddc945b..671c7ac97cb4d4e54b2e5ce53489fa4635d1657b 100644 (file)
@@ -222,7 +222,6 @@ int jtag_speed_post_reset = 0;
 
 
 /* forward declarations */
-void jtag_add_statemove(enum tap_state endstate);
 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_reset(int trst, int srst);
@@ -245,7 +244,6 @@ int handle_scan_chain_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);
 int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-int handle_statemove_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 int handle_drscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
@@ -777,18 +775,20 @@ int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *f
 
        return ERROR_OK;
 }
-void jtag_add_statemove(enum tap_state state)
-{
-       jtag_prelude(state);
 
+void jtag_add_tms()
+{
+       jtag_prelude(TAP_TLR);
+       
        int retval;
-       retval=interface_jtag_add_statemove(cmd_queue_end_state);
+       retval=interface_jtag_add_tms();
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
 
-int MINIDRIVER(interface_jtag_add_statemove)(enum tap_state state)
+int MINIDRIVER(interface_jtag_add_tms)()
 {
+       enum tap_state state = TAP_TLR;
        jtag_command_t **last_cmd = jtag_get_last_command_p();
        
        /* allocate memory for a new list member */
@@ -943,7 +943,7 @@ void jtag_add_reset(int req_trst, int req_srst)
        {
                LOG_DEBUG("JTAG reset with tms instead of TRST");
                jtag_add_end_state(TAP_TLR);
-               jtag_add_statemove(TAP_TLR);
+               jtag_add_tms();
                jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
                return;
        }
@@ -1429,8 +1429,6 @@ int jtag_register_commands(struct command_context_s *cmd_ctx)
                COMMAND_EXEC, "toggle reset lines <trst> <srst>");
        register_command(cmd_ctx, NULL, "runtest", handle_runtest_command,
                COMMAND_EXEC, "move to Run-Test/Idle, and execute <num_cycles>");
-       register_command(cmd_ctx, NULL, "statemove", handle_statemove_command,
-               COMMAND_EXEC, "move to current endstate or [tap_state]");
        register_command(cmd_ctx, NULL, "irscan", handle_irscan_command,
                COMMAND_EXEC, "execute IR scan <device> <instr> [dev2] [instr2] ...");
        register_command(cmd_ctx, NULL, "drscan", handle_drscan_command,
@@ -1477,7 +1475,7 @@ int jtag_init(struct command_context_s *cmd_ctx)
                device = device->next;
        }
        
-       jtag_add_statemove(TAP_TLR);
+       jtag_add_tms();
        jtag_execute_queue();
 
        /* examine chain first, as this could discover the real chain layout */
@@ -1837,28 +1835,6 @@ int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **
 
 }
 
-int handle_statemove_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
-       enum tap_state state;
-
-       state = -1;
-       if (argc == 1)
-       {
-               for (state = 0; state < 16; state++)
-               {
-                       if (strcmp(args[0], tap_state_strings[state]) == 0)
-                       {
-                               break;
-                       }
-               }
-       }
-
-       jtag_add_statemove(state);
-       jtag_execute_queue();
-
-       return ERROR_OK;
-
-}
 
 int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
index 4d482f063227f82b0a40d7082cbb05ad1333d8aa..2c186e9cbc3b028a4543a41ae9a2d49d8a15f2d0 100644 (file)
@@ -248,7 +248,14 @@ extern int jtag_register_commands(struct command_context_s *cmd_ctx);
 /* JTAG interface, can be implemented with a software or hardware fifo
  * 
  * TAP_SD and TAP_SI are illegal end states. TAP_SD/SI as end states
- * can be emulated by using a larger scan. 
+ * can be emulated by using a larger scan.
+ *
+ * Code that is relatively insensitive to the path(as long
+ * as it is JTAG compliant) taken through state machine can use 
+ * endstate for jtag_add_xxx_scan(). Otherwise the pause state must be 
+ * specified as end state and a subsequent jtag_add_pathmove() must 
+ * 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);
@@ -258,30 +265,24 @@ extern void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum ta
 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);
-/* execute a state transition within the JTAG standard, but the exact path
- * path that is taken is undefined. Many implementations use precisely
- * 7 clocks to perform a transition, but it could be more or less
- * than that.
- *
- * The following assertions are made about certain common state moves:
- *
- * - A state move from Pause-[ID]R to Pause-[ID]R should always go through 
- *   Update-[ID]R and Capture-[ID]R before returning to Pause-[ID]R, otherwise 
- *   there's no way force a register update, if you can't go to Run-Test/Idle for 
- *   some reason.
+/* run a TAP_TLR reset. End state is TAP_TLR, regardless
+ * of start state.
+ */
+extern void jtag_add_tms();
+extern int interface_jtag_add_tms();
+/* Do not use jtag_add_pathmove() unless you need to, but do use it
+ * if you have to. 
  *
- *   - A state move from Pause-[ID]R to Shift-[ID]R must not go through 
- *   Update-[ID]R.
+ * DANGER! If the target is dependent upon a particular sequence
+ * of transitions for things to work correctly(e.g. as a workaround 
+ * for an errata that contradicts the JTAG standard), then pathmove 
+ * must be used, even if some jtag interfaces happen to use the 
+ * desired path. Worse, the jtag interface used for testing a 
+ * particular implementation, could happen to use the "desired" 
+ * path when transitioning to/from end
+ * state.
  *
- *   - Run-Test/Idle must not be entered unless requested, because R-T/I may have 
- *   side effects.
- * 
- * NB! a jtag_add_statemove() to the current state is not
- * a no-operation.
- */
-extern void jtag_add_statemove(enum tap_state endstate);
-extern int interface_jtag_add_statemove(enum tap_state endstate);
-/* A list of unambigious single clock state transitions, not
+ * A list of unambigious single clock state transitions, not
  * all drivers can support this, but it is required for e.g.
  * XScale and Xilinx support
  * 
@@ -289,6 +290,15 @@ extern int interface_jtag_add_statemove(enum tap_state endstate);
  * 
  * Note that the first on the list must be reachable 
  * via a single transition from the current state. 
+ *
+ * All drivers are required to implement jtag_add_pathmove().
+ * However, if the pathmove sequence can not be precisely
+ * executed, an interface_jtag_add_pathmove() or jtag_execute_queue()
+ * must return an error. It is legal, but not recommended, that
+ * a driver returns an error in all cases for a pathmove if it
+ * can only implement a few transitions and therefore
+ * 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);
index 45c39ae43fe80a84ce068346ba8682473f556730..997f60d5f04301807e1ecd9a0eecdf08a750d021 100644 (file)
@@ -137,7 +137,7 @@ int virtex2_read_stat(struct pld_device_s *pld_device, u32 *status)
 {
        u32 data[5];
        
-       jtag_add_statemove(TAP_TLR);
+       jtag_add_tms();
        
        data[0] = 0xaa995566; /* synch word */
        data[1] = 0x2800E001; /* Type 1, read, address 7, 1 word */
@@ -192,7 +192,7 @@ int virtex2_load(struct pld_device_s *pld_device, char *filename)
        jtag_add_dr_scan(1, &field, TAP_PD);
        jtag_execute_queue();
        
-       jtag_add_statemove(TAP_TLR);
+       jtag_add_tms();
        
        jtag_add_end_state(TAP_RTI);
        virtex2_set_instr(virtex2_info->chain_pos, 0xc); /* JSTART */
index b58c7a231eba93abb1c3f4ea2f92f0e6f2eb11db..3d0110149c758bd6e2f62b0cc221e4cdb67e2f78 100644 (file)
@@ -34,6 +34,9 @@ mww 0xCC000008     1 # Mode Select CL3
 #mww 0xc4000020  0xffffee # CFG0: remove expansion bus boot flash\r
 #mirror at 0x00000000\r
 \r
+#big endian\r
+reg XSCALE_CTRL 0xF8\r
+\r
 #\r
 # detect flash\r
 #\r
index f18b1e0f9273bff11bd1a91f1a19bcddb4240636..2bc7d9369db65439a82f793ac60adedfa0e0bbfa 100644 (file)
@@ -15,7 +15,7 @@ jtag_ntrst_delay 0
 ######################\r
 \r
 #target <type> <endianess> <reset mode> <JTAG pos> <variant>\r
-target arm926ejs little reset_init 0 arm926ejs\r
+target arm926ejs big reset_init 0 arm926ejs\r
 \r
 target_script 0 reset event/wi-9c_reset.script\r
 run_and_halt_time 0 30\r
index d9b63163037c55a39675e40e82b27bf6c0501425..09736af6d185933ce1b2eaa0cd5b734108b80868 100644 (file)
@@ -66,6 +66,37 @@ int tap_to_xsvf[] =
        0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x1, 0x9, 0xa, 0xb, 0xc, 0xe, 0xf
 };
 
+
+/* xsvf has it's own definition of a statemove. This needs
+ * to be handled according to the specs, which has nothing
+ * to do with the JTAG spec or OpenOCD as such.
+ * 
+ * Implemented via jtag_add_pathmove().
+ */
+void xsvf_add_statemove(enum tap_state state)
+{
+       enum tap_state moves[7]; /* max # of transitions */
+       int i; 
+       enum tap_state curstate=cmd_queue_cur_state;
+       u8 move=tap_move[cmd_queue_cur_state][state];
+       
+       if ((state!=TAP_TLR)&&(state==cmd_queue_cur_state))
+               return;
+       for (i=0; i<7; i++)
+       {
+               int j=(move>>i)&1;
+               if (j)
+               {
+                       curstate=tap_transitions[curstate].high;
+               } else
+               {
+                       curstate=tap_transitions[curstate].low;
+               }
+               moves[i]=curstate;
+       }
+       jtag_add_pathmove(7, moves);
+}
+
 int xsvf_register_commands(struct command_context_s *cmd_ctx)
 {
        register_command(cmd_ctx, NULL, "xsvf", handle_xsvf_command,
@@ -203,13 +234,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
                                                                jtag_add_runtest(xruntest, xsvf_to_tap[xendir]);
                                                        else
                                                        {
-                                                               jtag_add_statemove(TAP_RTI);
+                                                               xsvf_add_statemove(TAP_RTI);
                                                                jtag_add_sleep(xruntest);
-                                                               jtag_add_statemove(xsvf_to_tap[xendir]);
+                                                               xsvf_add_statemove(xsvf_to_tap[xendir]);
                                                        }
                                                }
                                                else if (xendir != 0xd) /* Pause-IR */
-                                                       jtag_add_statemove(xsvf_to_tap[xendir]);
+                                                       xsvf_add_statemove(xsvf_to_tap[xendir]);
                                        }
                                        free(ir_buf);
                                }
@@ -242,13 +273,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
                                                        jtag_add_runtest(xruntest, xsvf_to_tap[xenddr]);
                                                else
                                                {
-                                                       jtag_add_statemove(TAP_RTI);
+                                                       xsvf_add_statemove(TAP_RTI);
                                                        jtag_add_sleep(xruntest);
-                                                       jtag_add_statemove(xsvf_to_tap[xenddr]);
+                                                       xsvf_add_statemove(xsvf_to_tap[xenddr]);
                                                }
                                        }
                                        else if (xendir != 0x6) /* Pause-DR */
-                                               jtag_add_statemove(xsvf_to_tap[xenddr]);
+                                               xsvf_add_statemove(xsvf_to_tap[xenddr]);
                                }
                                break;
                        case 0x04:      /* XRUNTEST */
@@ -316,13 +347,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
                                                                jtag_add_runtest(xruntest, xsvf_to_tap[xenddr]);
                                                        else
                                                        {
-                                                               jtag_add_statemove(TAP_RTI);
+                                                               xsvf_add_statemove(TAP_RTI);
                                                                jtag_add_sleep(xruntest);
-                                                               jtag_add_statemove(xsvf_to_tap[xenddr]);
+                                                               xsvf_add_statemove(xsvf_to_tap[xenddr]);
                                                        }
                                                }
                                                else if (xendir != 0x6) /* Pause-DR */
-                                                       jtag_add_statemove(xsvf_to_tap[xenddr]);
+                                                       xsvf_add_statemove(xsvf_to_tap[xenddr]);
                                        }
                                }
                                break;
@@ -451,10 +482,10 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
                                        do_abort = 1;
                                else
                                {
-                                       jtag_add_statemove(xsvf_to_tap[uc]);
+                                       xsvf_add_statemove(xsvf_to_tap[uc]);
                                        ui = be_to_h_u32(buf4);
                                        jtag_add_sleep(ui);
-                                       jtag_add_statemove(xsvf_to_tap[uc2]);
+                                       xsvf_add_statemove(xsvf_to_tap[uc2]);
                                }
                                break;
                        default:

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)