From a3a3426e869ca4d3ef51731a655cc536361b0209 Mon Sep 17 00:00:00 2001 From: oharboe Date: Mon, 31 Mar 2008 13:18:03 +0000 Subject: make jtag_add_statemove() internal to the driver. git-svn-id: svn://svn.berlios.de/openocd/trunk@527 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/jtag.c | 42 +++++++++--------------------------------- src/jtag/jtag.h | 56 +++++++++++++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 56 deletions(-) (limited to 'src/jtag') diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index 8f55ea0b..671c7ac9 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -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 "); register_command(cmd_ctx, NULL, "runtest", handle_runtest_command, COMMAND_EXEC, "move to Run-Test/Idle, and execute "); - 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 [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) { diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 4d482f06..2c186e9c 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -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); -- cgit v1.2.3