/* 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);
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);
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 */
{
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;
}
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,
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 */
}
-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)
{
/* 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);
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
*
*
* 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);
{
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 */
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 */
#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
######################\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
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,
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);
}
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 */
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;
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: