David Brownell <david-b@pacbell.net>:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 16 Jun 2009 12:17:18 +0000 (12:17 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 16 Jun 2009 12:17:18 +0000 (12:17 +0000)
Extend the internal JTAG event handlers to cover enable/disable,
and use those events to make sure that targets get "examined" if
they were disabled when the scan chain was first set up:

 - Remove "enum jtag_tap_event", merge with "enum jtag_event",
   so C code can now listen for TAP enable/disable events.

 - Report those events so they can trigger callbacks.

 - During startup, make target_examine() register a handler to
   catch ENABLE events for any then-disabled targets.

This fixes bugs like "can't halt target after enabling its TAP".

One class of unresolved bugs:  if the target has an ETM hooked
up to an ETB, nothing activates the ETB.  But starting up the
ETM without access to the ETB registers fails...

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

src/jtag/core.c
src/jtag/jtag.h
src/jtag/tcl.c
src/target/target.c

index 0cec11ad35134abc429c282b70aff583c42066de..a8d65f1e59000ddf21d42a1f9a0fad55a41cf706 100644 (file)
@@ -61,6 +61,8 @@ static int jtag_error = ERROR_OK;
 static const char *jtag_event_strings[] =
 {
        [JTAG_TRST_ASSERTED] = "JTAG controller reset (RESET or TRST)",
+       [JTAG_TAP_EVENT_ENABLE] = "TAP enabled",
+       [JTAG_TAP_EVENT_DISABLE] = "TAP disabled",
 };
 
 static int jtag_trst = 0;
index 956343eea4a6099c85fa2180532f3dcee344b2a2..cddceef4a061fa86733df98d9feb57bb2c4a1a2b 100644 (file)
@@ -201,19 +201,18 @@ extern unsigned jtag_tap_count(void);
  * - SRST pulls TRST
  * - TRST asserted
  *
- **/
+ * TAP activation/deactivation is currently implemented outside the core
+ * using scripted code that understands the specific router type.
+ */
 enum jtag_event {
-       JTAG_TRST_ASSERTED
-};
-
-enum jtag_tap_event {
+       JTAG_TRST_ASSERTED,
        JTAG_TAP_EVENT_ENABLE,
-       JTAG_TAP_EVENT_DISABLE
+       JTAG_TAP_EVENT_DISABLE,
 };
 
 struct jtag_tap_event_action_s
 {
-       enum jtag_tap_event      event;
+       enum jtag_event         event;
        Jim_Obj*                 body;
        jtag_tap_event_action_t* next;
 };
index aa55809fb4f515134b7e22e96b7c4bb8f720a9ce..ec74a9e17bd29ecc40a4d6e559ba0975ba2b8854 100644 (file)
@@ -256,7 +256,7 @@ static int jtag_tap_configure_cmd( Jim_GetOptInfo *goi, jtag_tap_t * tap)
                                        jteap = tap->event_action;
                                        /* replace existing? */
                                        while (jteap) {
-                                               if (jteap->event == (enum jtag_tap_event)n->value) {
+                                               if (jteap->event == (enum jtag_event)n->value) {
                                                        break;
                                                }
                                                jteap = jteap->next;
@@ -460,7 +460,7 @@ static int jim_newtap_cmd( Jim_GetOptInfo *goi )
        return JIM_ERR;
 }
 
-static void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
+static void jtag_tap_handle_event(jtag_tap_t *tap, enum jtag_event e)
 {
        jtag_tap_event_action_t * jteap;
        int done;
@@ -594,6 +594,8 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv
                                 *  - scan chain length grew by one (this)
                                 *  - IDs and IR lengths are as expected
                                 */
+
+                               jtag_call_event_callbacks(JTAG_TAP_EVENT_ENABLE);
                                break;
                        case JTAG_CMD_TAPDISABLE:
                                if (!t->enabled)
@@ -606,6 +608,8 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv
                                 *  - scan chain length shrank by one (this)
                                 *  - IDs and IR lengths are as expected
                                 */
+
+                               jtag_call_event_callbacks(JTAG_TAP_EVENT_DISABLE);
                                break;
                        }
                        e = t->enabled;
index d0227247096c23c8b322c0780ac6c71719a62e0a..32e46b2759d11fc69369867cc05e714b7bbdefe9 100644 (file)
@@ -478,6 +478,18 @@ int target_examine_one(struct target_s *target)
        return target->type->examine(target);
 }
 
+static int jtag_enable_callback(enum jtag_event event, void *priv)
+{
+       target_t *target = priv;
+
+       if (event != JTAG_TAP_EVENT_ENABLE || !target->tap->enabled)
+               return ERROR_OK;
+
+       jtag_unregister_event_callback(jtag_enable_callback, target);
+       return target_examine_one(target);
+}
+
+
 /* Targets that correctly implement init+examine, i.e.
  * no communication with target during init:
  *
@@ -490,8 +502,12 @@ int target_examine(void)
 
        for (target = all_targets; target; target = target->next)
        {
-               if (!target->tap->enabled)
+               /* defer examination, but don't skip it */
+               if (!target->tap->enabled) {
+                       jtag_register_event_callback(jtag_enable_callback,
+                                       target);
                        continue;
+               }
                if ((retval = target_examine_one(target)) != ERROR_OK)
                        return retval;
        }

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)