+ /* bypass bits before and after */
+ int pre_bits;
+ int post_bits;
+ jtag_pre_post_bits(tap, &pre_bits, &post_bits);
+ post_bits += 2;
+
+ if ((pre_bits > 32) || (post_bits > 32)) {
+ int arm11_run_instr_data_to_core_noack_inner_default(struct jtag_tap *,
+ uint32_t, const uint32_t *, size_t);
+ return arm11_run_instr_data_to_core_noack_inner_default(tap, opcode, data, count);
+ } else {
+ static const uint8_t zero;
+
+ /* FIX!!!!!! the target_write_memory() API started this nasty problem
+ * with unaligned uint32_t * pointers... */
+ const uint8_t *t = (const uint8_t *)data;
+
+ while (--count > 0) {
+#if 1
+ /* Danger! This code doesn't update cmd_queue_cur_state, so
+ * invoking jtag_add_pathmove() before jtag_add_dr_scan() after
+ * this loop would fail!
+ */
+ shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, pre_bits, 0);
+
+ uint32_t value;
+ value = *t++;
+ value |= (*t++<<8);
+ value |= (*t++<<16);
+ value |= (*t++<<24);
+
+ shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, value);
+ /* minimum 2 bits */
+ shiftValueInner(TAP_DRSHIFT, TAP_DRPAUSE, post_bits, 0);
+
+ /* copy & paste from arm11_dbgtap.c */
+ /* TAP_DREXIT2, TAP_DRUPDATE, TAP_IDLE, TAP_IDLE, TAP_IDLE, TAP_DRSELECT,
+ * TAP_DRCAPTURE, TAP_DRSHIFT */
+ /* KLUDGE! we have to flush the fifo or the Nios CPU locks up.
+ * This is probably a bug in the Avalon bus(cross clocking bridge?)
+ * or in the jtag registers module.
+ */
+ waitIdle();
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 1);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 1);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 1);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0);
+ /* we don't have to wait for the queue to empty here */
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRSHIFT);
+ waitIdle();
+#else
+ static const tap_state_t arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay[] = {
+ TAP_DREXIT2, TAP_DRUPDATE, TAP_IDLE, TAP_IDLE, TAP_IDLE,
+ TAP_DRSELECT, TAP_DRCAPTURE, TAP_DRSHIFT
+ };
+
+ struct scan_field fields[2] = {
+ { .num_bits = 32, .out_value = t },
+ { .num_bits = 2, .out_value = &zero },
+ };
+ t += 4;
+
+ jtag_add_dr_scan(tap,
+ 2,
+ fields,
+ TAP_IDLE);
+
+ jtag_add_pathmove(ARRAY_SIZE(arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay),
+ arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay);
+#endif
+ }
+
+ struct scan_field fields[2] = {
+ { .num_bits = 32, .out_value = t },
+ { .num_bits = 2, .out_value = &zero },
+ };
+
+ /* This will happen on the last iteration updating cmd_queue_cur_state
+ * so we don't have to track it during the common code path
+ */
+ jtag_add_dr_scan(tap,
+ 2,
+ fields,
+ TAP_IDLE);
+
+ return jtag_execute_queue();
+ }
+}
+
+static const struct command_registration zy1000_commands[] = {