Commit a485ded4 authored by zwelch's avatar zwelch
Browse files

Improve encapsulation of JTAG event handling:

- Move nvp_jtag_tap_event and jtag_tap_handle_event to tcl.c.
- Change both to be static; remove declaration of function from jtag.h.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2166 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent a2d18e91
......@@ -63,13 +63,6 @@ static char* jtag_event_strings[] =
"JTAG controller reset (RESET or TRST)"
};
const Jim_Nvp nvp_jtag_tap_event[] = {
{ .value = JTAG_TAP_EVENT_ENABLE, .name = "tap-enable" },
{ .value = JTAG_TAP_EVENT_DISABLE, .name = "tap-disable" },
{ .name = NULL, .value = -1 }
};
static int jtag_trst = 0;
static int jtag_srst = 0;
......@@ -1222,37 +1215,6 @@ int jtag_srst_asserted(int *srst_asserted)
return jtag->srst_asserted(srst_asserted);
}
void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
{
jtag_tap_event_action_t * jteap;
int done;
jteap = tap->event_action;
done = 0;
while (jteap) {
if (jteap->event == e) {
done = 1;
LOG_DEBUG( "JTAG tap: %s event: %d (%s) action: %s\n",
tap->dotted_name,
e,
Jim_Nvp_value2name_simple(nvp_jtag_tap_event, e)->name,
Jim_GetString(jteap->body, NULL) );
if (Jim_EvalObj(interp, jteap->body) != JIM_OK) {
Jim_PrintErrorMessage(interp);
}
}
jteap = jteap->next;
}
if (!done) {
LOG_DEBUG( "event %d %s - no action",
e,
Jim_Nvp_value2name_simple( nvp_jtag_tap_event, e)->name);
}
}
int jtag_add_statemove(tap_state_t goal_state)
{
tap_state_t cur_state = cmd_queue_cur_state;
......
......@@ -611,8 +611,6 @@ extern void jtag_sleep(u32 us);
extern int jtag_call_event_callbacks(enum jtag_event event);
extern int jtag_register_event_callback(int (* callback)(enum jtag_event event, void* priv), void* priv);
void jtag_tap_handle_event(jtag_tap_t* tap, enum jtag_tap_event e);
/*
* The JTAG subsystem defines a number of error codes,
* using codes between -100 and -199.
......
......@@ -39,7 +39,12 @@
#include <strings.h>
#endif
extern const Jim_Nvp nvp_jtag_tap_event[];
static const Jim_Nvp nvp_jtag_tap_event[] = {
{ .value = JTAG_TAP_EVENT_ENABLE, .name = "tap-enable" },
{ .value = JTAG_TAP_EVENT_DISABLE, .name = "tap-disable" },
{ .name = NULL, .value = -1 }
};
/* jtag interfaces (parport, FTDI-USB, TI-USB, ...)
*/
......@@ -443,6 +448,38 @@ 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)
{
jtag_tap_event_action_t * jteap;
int done;
jteap = tap->event_action;
done = 0;
while (jteap) {
if (jteap->event == e) {
done = 1;
LOG_DEBUG( "JTAG tap: %s event: %d (%s) action: %s\n",
tap->dotted_name,
e,
Jim_Nvp_value2name_simple(nvp_jtag_tap_event, e)->name,
Jim_GetString(jteap->body, NULL) );
if (Jim_EvalObj(interp, jteap->body) != JIM_OK) {
Jim_PrintErrorMessage(interp);
}
}
jteap = jteap->next;
}
if (!done) {
LOG_DEBUG( "event %d %s - no action",
e,
Jim_Nvp_value2name_simple( nvp_jtag_tap_event, e)->name);
}
}
static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
{
Jim_GetOptInfo goi;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment