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
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;
* - 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;
};
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;
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;
* - 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)
* - 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;
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:
*
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;
}