|
From: <zw...@ma...> - 2009-06-09 03:16:41
|
Author: zwelch
Date: 2009-06-09 03:16:35 +0200 (Tue, 09 Jun 2009)
New Revision: 2138
Modified:
trunk/src/jtag/jtag.c
trunk/src/jtag/jtag.h
Log:
Change jtag_add_pathmove to set jtag_error rather than call exit():
- Add new error codes to encode the possible failure conditions.
- Add documentation to describe the routine's possible error codes.
Modified: trunk/src/jtag/jtag.c
===================================================================
--- trunk/src/jtag/jtag.c 2009-06-09 01:16:19 UTC (rev 2137)
+++ trunk/src/jtag/jtag.c 2009-06-09 01:16:35 UTC (rev 2138)
@@ -613,7 +613,8 @@
if (!tap_is_state_stable(path[num_states - 1]))
{
LOG_ERROR("BUG: TAP path doesn't finish in a stable state");
- exit(-1);
+ jtag_set_error(ERROR_JTAG_NOT_STABLE_STATE);
+ return;
}
for (int i = 0; i < num_states; i++)
@@ -621,7 +622,8 @@
if (path[i] == TAP_RESET)
{
LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
- exit(-1);
+ jtag_set_error(ERROR_JTAG_STATE_INVALID);
+ return;
}
if ( tap_state_transition(cur_state, true) != path[i]
@@ -629,7 +631,8 @@
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
tap_state_name(cur_state), tap_state_name(path[i]));
- exit(-1);
+ jtag_set_error(ERROR_JTAG_TRANSITION_INVALID);
+ return;
}
cur_state = path[i];
}
Modified: trunk/src/jtag/jtag.h
===================================================================
--- trunk/src/jtag/jtag.h 2009-06-09 01:16:19 UTC (rev 2137)
+++ trunk/src/jtag/jtag.h 2009-06-09 01:16:35 UTC (rev 2138)
@@ -447,6 +447,12 @@
* can only implement a few transitions and therefore
* a partial implementation of pathmove would have little practical
* application.
+ *
+ * If an error occurs, jtag_error will contain one of these error codes:
+ * - ERROR_JTAG_NOT_STABLE_STATE -- The final state was not stable.
+ * - ERROR_JTAG_STATE_INVALID -- The path passed through TAP_RESET.
+ * - ERROR_JTAG_TRANSITION_INVALID -- The path includes invalid
+ * state transitions.
*/
extern void jtag_add_pathmove(int num_states, const tap_state_t* path);
@@ -606,6 +612,8 @@
#define ERROR_JTAG_QUEUE_FAILED (-104)
#define ERROR_JTAG_NOT_STABLE_STATE (-105)
#define ERROR_JTAG_DEVICE_ERROR (-107)
+#define ERROR_JTAG_STATE_INVALID (-108)
+#define ERROR_JTAG_TRANSITION_INVALID (-109)
/**
* jtag_add_dr_out() is a version of jtag_add_dr_scan() which
|