David Brownell <david-b@pacbell.net>:
Minor jtag cleanup: - remove hidden assumption about JTAG event numbering - move function declarations to a header - some end'o'line whitespace - use "calloc" not "malloc + memset" git-svn-id: svn://svn.berlios.de/openocd/trunk@2244 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
cc9488008a
commit
c7cfb3417b
|
@ -58,9 +58,9 @@ static void jtag_add_scan_check(void (*jtag_add_scan)(int in_num_fields, const s
|
||||||
*/
|
*/
|
||||||
static int jtag_error = ERROR_OK;
|
static int jtag_error = ERROR_OK;
|
||||||
|
|
||||||
static char* jtag_event_strings[] =
|
static const char *jtag_event_strings[] =
|
||||||
{
|
{
|
||||||
"JTAG controller reset (RESET or TRST)"
|
[JTAG_TRST_ASSERTED] = "JTAG controller reset (RESET or TRST)",
|
||||||
};
|
};
|
||||||
|
|
||||||
static int jtag_trst = 0;
|
static int jtag_trst = 0;
|
||||||
|
|
|
@ -175,6 +175,10 @@ struct jtag_tap_s
|
||||||
|
|
||||||
jtag_tap_t* next_tap;
|
jtag_tap_t* next_tap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void jtag_tap_init(jtag_tap_t *tap);
|
||||||
|
void jtag_tap_free(jtag_tap_t *tap);
|
||||||
|
|
||||||
extern jtag_tap_t* jtag_all_taps(void);
|
extern jtag_tap_t* jtag_all_taps(void);
|
||||||
extern const char *jtag_tap_name(const jtag_tap_t *tap);
|
extern const char *jtag_tap_name(const jtag_tap_t *tap);
|
||||||
extern jtag_tap_t* jtag_tap_by_string(const char* dotted_name);
|
extern jtag_tap_t* jtag_tap_by_string(const char* dotted_name);
|
||||||
|
@ -185,16 +189,16 @@ extern unsigned jtag_tap_count_enabled(void);
|
||||||
extern unsigned jtag_tap_count(void);
|
extern unsigned jtag_tap_count(void);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are three cases when JTAG_TRST_ASSERTED callback is invoked. The
|
* There are three cases when JTAG_TRST_ASSERTED callback is invoked. The
|
||||||
* event is invoked *after* TRST is asserted(or queued rather). It is illegal
|
* event is invoked *after* TRST is asserted(or queued rather). It is illegal
|
||||||
* to communicate with the JTAG interface during the callback(as there is
|
* to communicate with the JTAG interface during the callback(as there is
|
||||||
* currently a queue being built).
|
* currently a queue being built).
|
||||||
*
|
*
|
||||||
* - TMS reset
|
* - TMS reset
|
||||||
* - SRST pulls TRST
|
* - SRST pulls TRST
|
||||||
* - TRST asserted
|
* - TRST asserted
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
enum jtag_event {
|
enum jtag_event {
|
||||||
JTAG_TRST_ASSERTED
|
JTAG_TRST_ASSERTED
|
||||||
|
@ -235,7 +239,7 @@ extern int jtag_call_event_callbacks(enum jtag_event event);
|
||||||
int jtag_get_speed(void);
|
int jtag_get_speed(void);
|
||||||
/**
|
/**
|
||||||
* Given a @a speed setting, use the interface @c speed_div callback to
|
* Given a @a speed setting, use the interface @c speed_div callback to
|
||||||
* adjust the setting.
|
* adjust the setting.
|
||||||
* @param speed The speed setting to convert back to readable KHz.
|
* @param speed The speed setting to convert back to readable KHz.
|
||||||
* @returns ERROR_OK if the interface has not been initialized or on success;
|
* @returns ERROR_OK if the interface has not been initialized or on success;
|
||||||
* otherwise, the error code produced by the @c speed_div callback.
|
* otherwise, the error code produced by the @c speed_div callback.
|
||||||
|
@ -507,7 +511,7 @@ extern void jtag_add_pathmove(int num_states, const tap_state_t* path);
|
||||||
* @param goal_state The final TAP state.
|
* @param goal_state The final TAP state.
|
||||||
* @return ERROR_OK on success, or an error code on failure.
|
* @return ERROR_OK on success, or an error code on failure.
|
||||||
*
|
*
|
||||||
* Moves from the current state to the goal \a state.
|
* Moves from the current state to the goal \a state.
|
||||||
*
|
*
|
||||||
* This needs to be handled according to the xsvf spec, see the XSTATE
|
* This needs to be handled according to the xsvf spec, see the XSTATE
|
||||||
* command description. From the XSVF spec, pertaining to XSTATE:
|
* command description. From the XSVF spec, pertaining to XSTATE:
|
||||||
|
|
|
@ -306,9 +306,6 @@ static int is_bad_irval(int ir_length, jim_wide w)
|
||||||
return (w & v) != 0;
|
return (w & v) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void jtag_tap_init(jtag_tap_t *tap);
|
|
||||||
extern void jtag_tap_free(jtag_tap_t *tap);
|
|
||||||
|
|
||||||
static int jim_newtap_cmd( Jim_GetOptInfo *goi )
|
static int jim_newtap_cmd( Jim_GetOptInfo *goi )
|
||||||
{
|
{
|
||||||
jtag_tap_t *pTap;
|
jtag_tap_t *pTap;
|
||||||
|
@ -334,12 +331,12 @@ static int jim_newtap_cmd( Jim_GetOptInfo *goi )
|
||||||
{ .name = NULL , .value = -1 },
|
{ .name = NULL , .value = -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
pTap = malloc( sizeof(jtag_tap_t) );
|
pTap = calloc(1, sizeof(jtag_tap_t));
|
||||||
memset( pTap, 0, sizeof(*pTap) );
|
if (!pTap) {
|
||||||
if( !pTap ){
|
Jim_SetResult_sprintf(goi->interp, "no memory");
|
||||||
Jim_SetResult_sprintf( goi->interp, "no memory");
|
|
||||||
return JIM_ERR;
|
return JIM_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we expect CHIP + TAP + OPTIONS
|
* we expect CHIP + TAP + OPTIONS
|
||||||
* */
|
* */
|
||||||
|
|
Loading…
Reference in New Issue