/***************************************************************************
- * Copyright (C) 2007-2009 by Øyvind Harboe *
+ * Copyright (C) 2007-2010 by Øyvind Harboe *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
if (!found)
{
/* if a device isn't listed, set it to BYPASS */
- uint8_t ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
-
- struct scan_field tmp;
- memset(&tmp, 0, sizeof(tmp));
- tmp.out_value = ones;
- tmp.num_bits = scan_size;
- scanFields(1, &tmp, TAP_IRSHIFT, pause);
- /* update device information */
- buf_cpy(tmp.out_value, tap->cur_instr, scan_size);
+ assert(scan_size <= 32);
+ shiftValueInner(TAP_IRSHIFT, pause?TAP_IRPAUSE:TAP_IRSHIFT, scan_size, 0xffffffff);
+
tap->bypass = 1;
}
}
return ERROR_OK;
}
+int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state state)
+{
+ /*wait for the fifo to be empty*/
+ waitIdle();
+
+ for (unsigned i = 0; i < num_bits; i++)
+ {
+ int tms;
+
+ if (((seq[i/8] >> (i % 8)) & 1) == 0)
+ {
+ tms = 0;
+ }
+ else
+ {
+ tms = 1;
+ }
+
+ waitIdle();
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
+ }
+
+ waitIdle();
+ if (state != TAP_INVALID)
+ {
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, state);
+ } else
+ {
+ /* this would be normal if we are switching to SWD mode */
+ }
+ return ERROR_OK;
+}
+
int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
{
int state_count;
int tms = 0;
- /*wait for the fifo to be empty*/
- waitIdle();
-
state_count = 0;
tap_state_t cur_state = cmd_queue_cur_state;
+ uint8_t seq[16];
+ memset(seq, 0, sizeof(seq));
+ assert(num_states < (sizeof(seq) * 8));
+
while (num_states)
{
if (tap_state_transition(cur_state, false) == path[state_count])
exit(-1);
}
- waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
+ seq[state_count/8] = seq[state_count/8] | (tms << (state_count % 8));
cur_state = path[state_count];
state_count++;
num_states--;
}
- waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, cur_state);
- return ERROR_OK;
-}
-
-int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq)
-{
- /* FIXME just implement this, like pathmove but without
- * JTAG-specific state transition checking. Then update
- * zy1000_interface to report that it's supported.
- *
- * Eventually interface_jtag_add_pathmove() could vanish.
- */
- return ERROR_JTAG_NOT_IMPLEMENTED;
+ return interface_add_tms_seq(state_count, seq, cur_state);
}
void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, uint8_t *buffer, int little, int count)
* with unaligned uint32_t * pointers... */
const uint8_t *t = (const uint8_t *)data;
- while (count--)
- {
- values[0] = *t++;
- values[0] |= (*t++<<8);
- values[0] |= (*t++<<16);
- values[0] |= (*t++<<24);
- if (count > 0)
+ /* bypass bits before and after */
+ int pre_bits = 0;
+ int post_bits = 0;
+
+ bool found = false;
+ struct jtag_tap *cur_tap, *nextTap;
+ for (cur_tap = jtag_tap_next_enabled(NULL); cur_tap!= NULL; cur_tap = nextTap)
+ {
+ nextTap = jtag_tap_next_enabled(cur_tap);
+ if (cur_tap == tap)
+ {
+ found = true;
+ } else
{
- jtag_add_dr_out(tap,
- 2,
- bits,
- values,
- TAP_DRPAUSE);
+ if (found)
+ {
+ post_bits++;
+ } else
+ {
+ pre_bits++;
+ }
+ }
+ }
+
+ post_bits+=2;
+
+
+ while (--count > 0)
+ {
+ 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);
+ shiftValueInner(TAP_DRSHIFT, TAP_DRPAUSE, post_bits, 0);
#if 1
- /* copy & paste from arm11_dbgtap.c */
- //TAP_DREXIT2, TAP_DRUPDATE, TAP_IDLE, TAP_IDLE, TAP_IDLE, TAP_DRSELECT, TAP_DRCAPTURE, TAP_DRSHIFT
-
- 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);
- waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRSHIFT);
+ /* copy & paste from arm11_dbgtap.c */
+ //TAP_DREXIT2, TAP_DRUPDATE, TAP_IDLE, TAP_IDLE, TAP_IDLE, TAP_DRSELECT, TAP_DRCAPTURE, TAP_DRSHIFT
+
+ 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. waitIdle(); */
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRSHIFT);
#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
- };
+ 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
+ };
- jtag_add_pathmove(ARRAY_SIZE(arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay),
- arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay);
+ jtag_add_pathmove(ARRAY_SIZE(arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay),
+ arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay);
#endif
- } else
- {
- /* This will happen on the last iteration updating the current tap state
- * so we don't have to track it during the common code path */
- jtag_add_dr_out(tap,
- 2,
- bits,
- values,
- TAP_IDLE);
- }
}
+ values[0] = *t++;
+ values[0] |= (*t++<<8);
+ values[0] |= (*t++<<16);
+ values[0] |= (*t++<<24);
+
+ /* This will happen on the last iteration updating the current tap state
+ * so we don't have to track it during the common code path */
+ jtag_add_dr_out(tap,
+ 2,
+ bits,
+ values,
+ TAP_IDLE);
+
return jtag_execute_queue();
#endif
}
struct jtag_interface zy1000_interface =
{
.name = "ZY1000",
+ .supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = NULL,
.speed = zy1000_speed,
.commands = zy1000_commands,