summaryrefslogtreecommitdiff
path: root/src/svf
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-10-20 20:04:36 -0700
committerDavid Brownell <dbrownell@users.sourceforge.net>2009-10-20 20:04:36 -0700
commit7556a93aed97c3fad2c0a904a115168cd3dd61a8 (patch)
tree9ec8b3587676945e34181671fdbb4b8eb0c70344 /src/svf
parenta1609e5ad1b8df67f216d2f7c43db82c420db373 (diff)
downloadopenocd+libswd-7556a93aed97c3fad2c0a904a115168cd3dd61a8.tar.gz
openocd+libswd-7556a93aed97c3fad2c0a904a115168cd3dd61a8.tar.bz2
openocd+libswd-7556a93aed97c3fad2c0a904a115168cd3dd61a8.tar.xz
openocd+libswd-7556a93aed97c3fad2c0a904a115168cd3dd61a8.zip
XSVF: use svf_add_statemove()
XSVF improvements: - Layer parts of XSVF directly over SVF, calling svf_add_statemove() instead of expecting jtag_add_statemove() to conform to the SVF/XSVF requirements (which it doesn't). This should improve XSTATE handling a lot; it removes most users of jtag_add_statemove(), and the comments about how it should really do what svf_add_statemove() does. - Update XSTATE logic to be a closer match to the XSVF spec. The main open issue here is (still) that this implementation doesn't know how to build and submit paths from single-state transitions ... but now it will report that error case. - Update the User's Guide to mention the two utility scripts for working with XSVF, and to mention the five extension opcodes. Handling of state transition paths is, overall, still a mess. I think they should all be specified as paths not unlike SVF uses, and compiled to the bitstrings later ... so that we can actually make sense of the paths. (And see the extra clocks, detours through RUN, etc.) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'src/svf')
-rw-r--r--src/svf/svf.c26
-rw-r--r--src/svf/svf.h21
2 files changed, 38 insertions, 9 deletions
diff --git a/src/svf/svf.c b/src/svf/svf.c
index ecb0ffa4..dfbbde4b 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -31,8 +31,8 @@
#include "config.h"
#endif
-#include "svf.h"
#include "jtag.h"
+#include "svf.h"
#include "time_support.h"
@@ -311,7 +311,7 @@ static const char* tap_state_svf_name(tap_state_t state)
return ret;
}
-static int svf_add_statemove(tap_state_t state_to)
+int svf_add_statemove(tap_state_t state_to)
{
tap_state_t state_from = cmd_queue_cur_state;
uint8_t index;
@@ -619,9 +619,10 @@ static int svf_parse_cmd_string(char *str, int len, char **argus, int *num_of_ar
return ERROR_OK;
}
-static int svf_tap_state_is_stable(tap_state_t state)
+bool svf_tap_state_is_stable(tap_state_t state)
{
- return ((TAP_RESET == state) || (TAP_IDLE == state) || (TAP_DRPAUSE == state) || (TAP_IRPAUSE == state));
+ return (TAP_RESET == state) || (TAP_IDLE == state)
+ || (TAP_DRPAUSE == state) || (TAP_IRPAUSE == state);
}
static int svf_tap_state_is_valid(tap_state_t state)
@@ -1082,6 +1083,7 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
field.num_bits = i;
field.out_value = &svf_tdi_buffer[svf_buffer_index];
field.in_value = &svf_tdi_buffer[svf_buffer_index];
+ /* NOTE: doesn't use SVF-specified state paths */
jtag_add_plain_dr_scan(1, &field, svf_para.dr_end_state);
svf_buffer_index += (i + 7) >> 3;
@@ -1177,6 +1179,7 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
field.num_bits = i;
field.out_value = &svf_tdi_buffer[svf_buffer_index];
field.in_value = &svf_tdi_buffer[svf_buffer_index];
+ /* NOTE: doesn't use SVF-specified state paths */
jtag_add_plain_ir_scan(1, &field, svf_para.ir_end_state);
svf_buffer_index += (i + 7) >> 3;
@@ -1278,10 +1281,13 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
// run_state and end_state is checked to be stable state
// TODO: do runtest
#if 1
+ /* FIXME handle statemove failures */
+ int retval;
+
// enter into run_state if necessary
if (cmd_queue_cur_state != svf_para.runtest_run_state)
{
- svf_add_statemove(svf_para.runtest_run_state);
+ retval = svf_add_statemove(svf_para.runtest_run_state);
}
// call jtag_add_clocks
@@ -1290,7 +1296,7 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
// move to end_state if necessary
if (svf_para.runtest_end_state != svf_para.runtest_run_state)
{
- svf_add_statemove(svf_para.runtest_end_state);
+ retval = svf_add_statemove(svf_para.runtest_end_state);
}
#else
if (svf_para.runtest_run_state != TAP_IDLE)
@@ -1337,8 +1343,10 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
free(path);
return ERROR_FAIL;
}
+ /* OpenOCD refuses paths containing TAP_RESET */
if (TAP_RESET == path[i])
{
+ /* FIXME last state MUST be stable! */
if (i > 0)
{
jtag_add_pathmove(i, path);
@@ -1378,10 +1386,10 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
state = svf_find_string_in_array(argus[1], (char **)svf_tap_state_name, dimof(svf_tap_state_name));
if (svf_tap_state_is_stable(state))
{
- // TODO: move to state
+ LOG_DEBUG("\tmove to %s by svf_add_statemove",
+ svf_tap_state_name[state]);
+ /* FIXME handle statemove failures */
svf_add_statemove(state);
-
- LOG_DEBUG("\tmove to %s by svf_add_statemove", svf_tap_state_name[state]);
}
else
{
diff --git a/src/svf/svf.h b/src/svf/svf.h
index 822cad22..83123fc3 100644
--- a/src/svf/svf.h
+++ b/src/svf/svf.h
@@ -24,4 +24,25 @@
extern int svf_register_commands(struct command_context_s *cmd_ctx);
+/**
+ * svf_add_statemove() moves from the current state to @a goal_state.
+ *
+ * @param goal_state The final TAP state.
+ * @return ERROR_OK on success, or an error code on failure.
+ *
+ * The current and goal states must satisfy svf_tap_state_is_stable().
+ * State transition paths used by this routine are those given in the
+ * SVF specification for single-argument STATE commands (and also used
+ * for various other state transitions).
+ */
+extern int svf_add_statemove(tap_state_t goal_state);
+
+/**
+ * svf_tap_state_is_stable() returns true for stable non-SHIFT states
+ *
+ * @param state The TAP state in question
+ * @return true iff the state is stable and not a SHIFT state.
+ */
+extern bool svf_tap_state_is_stable(tap_state_t state);
+
#endif /* SVF_H */