*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();
void jtag_add_ir_scan(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
- if (jtag_verify&&jtag_verify_capture_ir)
+ if (jtag_verify && jtag_verify_capture_ir)
{
/* 8 x 32 bit id's is enough for all invocations */
/* if we are to run a verification of the ir scan, we need to get the input back.
* We may have to allocate space if the caller didn't ask for the input back.
*/
- in_fields[j].check_value=in_fields[j].tap->expected;
- in_fields[j].check_mask=in_fields[j].tap->expected_mask;
+ in_fields[j].check_value = in_fields[j].tap->expected;
+ in_fields[j].check_mask = in_fields[j].tap->expected_mask;
}
jtag_add_scan_check(jtag_add_ir_scan_noverify, in_num_fields, in_fields, state);
} else
return;
}
- if ( tap_state_transition(cur_state, true) != path[i]
+ if (tap_state_transition(cur_state, true) != path[i]
&& tap_state_transition(cur_state, false) != path[i])
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
{
tap_state_t cur_state = cmd_queue_cur_state;
- LOG_DEBUG( "cur_state=%s goal_state=%s",
+ 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 )
+ else if (tap_state_transition(cur_state, true) == goal_state
+ || tap_state_transition(cur_state, false) == goal_state)
{
jtag_add_pathmove(1, &goal_state);
}
*/
if ((jtag_reset_config & RESET_HAS_SRST)&&
(jtag_reset_config & RESET_HAS_TRST)&&
- ((jtag_reset_config & RESET_SRST_PULLS_TRST)==0))
+ ((jtag_reset_config & RESET_SRST_PULLS_TRST) == 0))
{
if (((req_tlr_or_trst&&!jtag_trst)||
- (!req_tlr_or_trst&&jtag_trst))&&
+ (!req_tlr_or_trst && jtag_trst))&&
((req_srst&&!jtag_srst)||
- (!req_srst&&jtag_srst)))
+ (!req_srst && jtag_srst)))
{
/* FIX!!! srst_pulls_trst allows 1,1 => 0,0 transition.... */
//LOG_ERROR("BUG: transition of req_tlr_or_trst and req_srst in the same jtag_add_reset() call is undefined");
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
{
assert(field->in_value != NULL);
- if (value==NULL)
+ if (value == NULL)
{
/* no checking to do */
return;
jtag_execute_queue_noclear();
- int retval=jtag_check_value_inner(field->in_value, value, mask, field->num_bits);
+ int retval = jtag_check_value_inner(field->in_value, value, mask, field->num_bits);
jtag_set_error(retval);
}
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)
static void jtag_examine_chain_end(uint8_t *idcodes, unsigned count, unsigned max)
{
bool triggered = false;
- for ( ; count < max - 31; count += 32)
+ for (; count < max - 31; count += 32)
{
uint32_t idcode = buf_get_u32(idcodes, count, 32);
// do not trigger the warning if the data looks good
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;
}
jtag_add_tlr();
- if ((retval=jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
return retval;
/* examine chain first, as this could discover the real chain layout */
{
int retval;
- if ((retval=jtag_interface_init(cmd_ctx)) != ERROR_OK)
+ if ((retval = jtag_interface_init(cmd_ctx)) != ERROR_OK)
return retval;
LOG_DEBUG("Trying to bring the JTAG controller to life by asserting TRST / RESET");
if (jtag_reset_config & RESET_HAS_SRST)
{
jtag_add_reset(1, 1);
- if ((jtag_reset_config & RESET_SRST_PULLS_TRST)==0)
+ if ((jtag_reset_config & RESET_SRST_PULLS_TRST) == 0)
jtag_add_reset(0, 1);
}
jtag_add_reset(0, 0);
int jtag_init(struct command_context_s *cmd_ctx)
{
int retval;
- if ((retval=jtag_interface_init(cmd_ctx)) != ERROR_OK)
+ if ((retval = jtag_interface_init(cmd_ctx)) != ERROR_OK)
return retval;
- if (jtag_init_inner(cmd_ctx)==ERROR_OK)
+ if (jtag_init_inner(cmd_ctx) == ERROR_OK)
{
return ERROR_OK;
}