summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-03-12 14:45:26 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-03-12 14:45:26 +0000
commit9bf8a4e48b9c84c0ccd4057537eab37b2be0a2a8 (patch)
tree823992134e9d35a702f947f98aaae50299b9a9af /src
parent10c3b1c93665fe46180103faf15276a766a706f4 (diff)
downloadopenocd+libswd-9bf8a4e48b9c84c0ccd4057537eab37b2be0a2a8.tar.gz
openocd+libswd-9bf8a4e48b9c84c0ccd4057537eab37b2be0a2a8.tar.bz2
openocd+libswd-9bf8a4e48b9c84c0ccd4057537eab37b2be0a2a8.tar.xz
openocd+libswd-9bf8a4e48b9c84c0ccd4057537eab37b2be0a2a8.zip
This moves common code into functions so as to make it clear
that all the jtag_add_xxx() are indeed intended to do the same thing. git-svn-id: svn://svn.berlios.de/openocd/trunk@504 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/jtag/jtag.c110
1 files changed, 23 insertions, 87 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index 6be63442..2503a165 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -391,7 +391,7 @@ void cmd_queue_free()
cmd_queue_pages = NULL;
}
-void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
+static void jtag_prelude1()
{
if (jtag_trst == 1)
{
@@ -400,13 +400,23 @@ void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state
return;
}
- if (state != -1)
- cmd_queue_end_state = state;
-
if (cmd_queue_end_state == TAP_TLR)
jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
+}
+
+static void jtag_prelude(enum tap_state state)
+{
+ jtag_prelude1();
+ if (state != -1)
+ cmd_queue_end_state = state;
+
cmd_queue_cur_state = cmd_queue_end_state;
+}
+
+void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
+{
+ jtag_prelude(state);
int retval=interface_jtag_add_ir_scan(num_fields, fields, cmd_queue_end_state);
if (retval!=ERROR_OK)
@@ -492,20 +502,7 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{
- if (jtag_trst == 1)
- {
- WARNING("JTAG command queued, while TRST is low (TAP in reset)");
- jtag_error=ERROR_JTAG_TRST_ASSERTED;
- return;
- }
-
- if (state != -1)
- cmd_queue_end_state = state;
-
- if (cmd_queue_end_state == TAP_TLR)
- jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
-
- cmd_queue_cur_state = cmd_queue_end_state;
+ jtag_prelude(state);
int retval=interface_jtag_add_plain_ir_scan(num_fields, fields, cmd_queue_end_state);
if (retval!=ERROR_OK)
@@ -551,20 +548,7 @@ int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *f
void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{
- if (jtag_trst == 1)
- {
- WARNING("JTAG command queued, while TRST is low (TAP in reset)");
- jtag_error=ERROR_JTAG_TRST_ASSERTED;
- return;
- }
-
- if (state != -1)
- cmd_queue_end_state = state;
-
- if (cmd_queue_end_state == TAP_TLR)
- jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
-
- cmd_queue_cur_state = cmd_queue_end_state;
+ jtag_prelude(state);
int retval=interface_jtag_add_dr_scan(num_fields, fields, cmd_queue_end_state);
if (retval!=ERROR_OK)
@@ -749,20 +733,7 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num,
void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{
- if (jtag_trst == 1)
- {
- WARNING("JTAG command queued, while TRST is low (TAP in reset)");
- jtag_error=ERROR_JTAG_TRST_ASSERTED;
- return;
- }
-
- if (state != -1)
- cmd_queue_end_state = state;
-
- if (cmd_queue_end_state == TAP_TLR)
- jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
-
- cmd_queue_cur_state = cmd_queue_end_state;
+ jtag_prelude(state);
int retval=interface_jtag_add_plain_dr_scan(num_fields, fields, cmd_queue_end_state);
if (retval!=ERROR_OK)
@@ -806,20 +777,7 @@ int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *f
}
void jtag_add_statemove(enum tap_state state)
{
- if (jtag_trst == 1)
- {
- WARNING("JTAG command queued, while TRST is low (TAP in reset)");
- jtag_error=ERROR_JTAG_TRST_ASSERTED;
- return;
- }
-
- if (state != -1)
- cmd_queue_end_state = state;
-
- if (cmd_queue_end_state == TAP_TLR)
- jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
-
- cmd_queue_cur_state = cmd_queue_end_state;
+ jtag_prelude(state);
int retval;
retval=interface_jtag_add_statemove(cmd_queue_end_state);
@@ -846,22 +804,11 @@ int MINIDRIVER(interface_jtag_add_statemove)(enum tap_state state)
void jtag_add_pathmove(int num_states, enum tap_state *path)
{
- if (jtag_trst == 1)
- {
- WARNING("JTAG command queued, while TRST is low (TAP in reset)");
- jtag_error=ERROR_JTAG_TRST_ASSERTED;
- return;
- }
-
- if (cmd_queue_end_state == TAP_TLR)
- jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
-
/* the last state has to be a stable state */
if (tap_move_map[path[num_states - 1]] == -1)
{
- ERROR("TAP path doesn't finish in a stable state");
- jtag_error=ERROR_JTAG_NOT_IMPLEMENTED;
- return;
+ ERROR("BUG: TAP path doesn't finish in a stable state");
+ exit(-1);
}
enum tap_state cur_state=cmd_queue_cur_state;
@@ -877,6 +824,8 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
cur_state = path[i];
}
+ jtag_prelude1();
+
cmd_queue_cur_state = path[num_states - 1];
int retval=interface_jtag_add_pathmove(num_states, path);
@@ -925,20 +874,7 @@ int MINIDRIVER(interface_jtag_add_runtest)(int num_cycles, enum tap_state state)
void jtag_add_runtest(int num_cycles, enum tap_state state)
{
- if (jtag_trst == 1)
- {
- WARNING("JTAG command queued, while TRST is low (TAP in reset)");
- jtag_error=ERROR_JTAG_TRST_ASSERTED;
- return;
- }
-
- if (state != -1)
- cmd_queue_end_state = state;
-
- if (cmd_queue_end_state == TAP_TLR)
- jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
-
- cmd_queue_cur_state = cmd_queue_end_state;
+ jtag_prelude(state);
/* executed by sw or hw fifo */
int retval=interface_jtag_add_runtest(num_cycles, cmd_queue_end_state);