Change jtag_add_pathmove to set jtag_error rather than call exit():
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 9 Jun 2009 01:16:35 +0000 (01:16 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 9 Jun 2009 01:16:35 +0000 (01:16 +0000)
- Add new error codes to encode the possible failure conditions.
- Add documentation to describe the routine's possible error codes.

git-svn-id: svn://svn.berlios.de/openocd/trunk@2138 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/jtag.c
src/jtag/jtag.h

index 77f322578f6291fd86e186c15e4508d63308ec8a..e8b66d154f6a651edbcf71d54c221e007bb43b87 100644 (file)
@@ -613,7 +613,8 @@ void jtag_add_pathmove(int num_states, const tap_state_t *path)
        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 @@ void jtag_add_pathmove(int num_states, const tap_state_t *path)
                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 @@ void jtag_add_pathmove(int num_states, const tap_state_t *path)
                {
                        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];
        }
index 90e8ae0b25932c77319a0916c3fe052acf57b031..0913c2544eef13f85f25c9dabb58bd3ea4581167 100644 (file)
@@ -447,6 +447,12 @@ extern void jtag_add_tlr(void);
  * 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 @@ void jtag_tap_handle_event(jtag_tap_t* tap, enum jtag_tap_event e);
 #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

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)