- /*
- * End of chain (invalid manufacturer ID) some devices, such
- * as AVR will output all 1's instead of TDI input value at
- * end of chain.
- */
- if (jtag_idcode_is_final(idcode))
- {
- jtag_examine_chain_end(idcode_buffer,
- bit_count + 32, JTAG_MAX_CHAIN_SIZE * 32);
- break;
- }
+ bit_count += 32;
+ }
+ tap->idcode = idcode;
+
+ /* ensure the TAP ID matches what was expected */
+ if (!jtag_examine_chain_match_tap(tap))
+ retval = ERROR_JTAG_INIT_SOFT_FAIL;
+ }
+
+ /* Fail if too many TAPs were enabled for us to verify them all. */
+ if (tap) {
+ LOG_ERROR("Too many TAPs enabled; '%s' ignored.",
+ tap->dotted_name);
+ return ERROR_JTAG_INIT_FAILED;
+ }
+
+ /* if autoprobing, the tap list is still empty ... populate it! */
+ while (autoprobe && bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31) {
+ uint32_t idcode;
+ char buf[12];
+
+ /* Is there another TAP? */
+ idcode = buf_get_u32(idcode_buffer, bit_count, 32);
+ if (jtag_idcode_is_final(idcode))
+ break;
+
+ /* Default everything in this TAP except IR length.
+ *
+ * REVISIT create a jtag_alloc(chip, tap) routine, and
+ * share it with jim_newtap_cmd().
+ */
+ tap = calloc(1, sizeof *tap);
+ if (!tap)
+ return ERROR_FAIL;
+
+ sprintf(buf, "auto%d", tapcount++);
+ tap->chip = strdup(buf);
+ tap->tapname = strdup("tap");
+
+ sprintf(buf, "%s.%s", tap->chip, tap->tapname);
+ tap->dotted_name = strdup(buf);