* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008 Øyvind Harboe *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2009 SoftPLC Corporation *
*tap = t;
}
+/* returns a pointer to the n-th device in the scan chain */
+static inline jtag_tap_t *jtag_tap_by_position(unsigned n)
+{
+ jtag_tap_t *t = jtag_all_taps();
+
+ while (t && n-- > 0)
+ t = t->next_tap;
+
+ return t;
+}
+
jtag_tap_t *jtag_tap_by_string(const char *s)
{
/* try by name first */
jtag_tap_t *t = jtag_all_taps();
+
while (t)
{
if (0 == strcmp(t->dotted_name, s))
if (parse_uint(s, &n) != ERROR_OK)
return NULL;
- return jtag_tap_by_position(n);
+ /* FIXME remove this numeric fallback code late June 2010, along
+ * with all info in the User's Guide that TAPs have numeric IDs.
+ * Also update "scan_chain" output to not display the numbers.
+ */
+ t = jtag_tap_by_position(n);
+ if (t)
+ LOG_WARNING("Specify TAP '%s' by name, not number %u",
+ t->dotted_name, n);
+
+ return t;
}
jtag_tap_t *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
return t;
}
-/* returns a pointer to the n-th device in the scan chain */
-jtag_tap_t *jtag_tap_by_position(unsigned n)
-{
- jtag_tap_t *t = jtag_all_taps();
-
- while (t && n-- > 0)
- t = t->next_tap;
-
- return t;
-}
-
jtag_tap_t* jtag_tap_next_enabled(jtag_tap_t* p)
{
p = p ? p->next_tap : jtag_all_taps();
LOG_DEBUG("cur_state=%s goal_state=%s",
tap_state_name(cur_state),
- tap_state_name(goal_state) );
+ tap_state_name(goal_state));
- if (goal_state == cur_state )
+ if (goal_state == cur_state)
; /* nothing to do */
- else if (goal_state == TAP_RESET )
+ else if (goal_state == TAP_RESET)
{
jtag_add_tlr();
}
- else if (tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state) )
+ else if (tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state))
{
unsigned tms_bits = tap_get_tms_path(cur_state, goal_state);
unsigned tms_count = tap_get_tms_path_len(cur_state, goal_state);
jtag_add_pathmove(tms_count, moves);
}
else if (tap_state_transition(cur_state, true) == goal_state
- || tap_state_transition(cur_state, false) == goal_state )
+ || tap_state_transition(cur_state, false) == goal_state)
{
jtag_add_pathmove(1, &goal_state);
}
else
compare_failed = buf_cmp(captured, in_check_value, num_bits);
- if (compare_failed){
+ if (compare_failed) {
/* An error handler could have caught the failing check
* only report a problem when there wasn't a handler, or if the handler
* acknowledged the error
log_printf_lf(level, __FILE__, __LINE__, __FUNCTION__,
"JTAG tap: %s %16.16s: 0x%08x "
"(mfg: 0x%3.3x, part: 0x%4.4x, ver: 0x%1.1x)",
- name, msg,
+ name, msg,
(unsigned int)idcode,
- (unsigned int)EXTRACT_MFG(idcode),
- (unsigned int)EXTRACT_PART(idcode),
- (unsigned int)EXTRACT_VER(idcode) );
+ (unsigned int)EXTRACT_MFG(idcode),
+ (unsigned int)EXTRACT_PART(idcode),
+ (unsigned int)EXTRACT_VER(idcode));
}
static bool jtag_idcode_is_final(uint32_t idcode)
tap = NULL;
total_ir_length = 0;
- for (;;){
+ for (;;) {
tap = jtag_tap_next_enabled(tap);
- if (tap == NULL ){
+ if (tap == NULL) {
break;
}
total_ir_length += tap->ir_length;
tap = NULL;
chain_pos = 0;
int val;
- for (;;){
+ for (;;) {
tap = jtag_tap_next_enabled(tap);
- if (tap == NULL ){
+ if (tap == NULL) {
break;
}
{
jtag_unregister_event_callback(&jtag_reset_callback, tap);
- /// @todo is anything missing? no memory leaks please
+ /// @todo is anything missing? no memory leaks please
free((void *)tap->expected_ids);
free((void *)tap->chip);
free((void *)tap->tapname);
LOG_DEBUG("Init JTAG chain");
tap = jtag_tap_next_enabled(NULL);
- if (tap == NULL ){
+ if (tap == NULL) {
LOG_ERROR("There are no enabled taps?");
return ERROR_JTAG_INIT_FAILED;
}