summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-03-08 08:32:45 +0100
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-03-08 08:37:13 +0100
commit7a5c9c2f4ae409e09faf12d5b8b76af135a85e73 (patch)
tree2b0491fa15b62464ae4721faad899e05e2cc2f27 /src
parent50dc56a488c6e4d5acdfd73f12e3502e1586c51e (diff)
downloadopenocd+libswd-7a5c9c2f4ae409e09faf12d5b8b76af135a85e73.tar.gz
openocd+libswd-7a5c9c2f4ae409e09faf12d5b8b76af135a85e73.tar.bz2
openocd+libswd-7a5c9c2f4ae409e09faf12d5b8b76af135a85e73.tar.xz
openocd+libswd-7a5c9c2f4ae409e09faf12d5b8b76af135a85e73.zip
zy1000: embedded ice dcc tweak
How many bits to shift out before/after enabled tap not in bypass is calculated outside the loop. This is more of a demonstration of principle and to clarify code than a performance optimisation as such. Follows up a bit on the simplification work in jtag interface. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src')
-rw-r--r--src/jtag/zy1000/zy1000.c69
1 files changed, 48 insertions, 21 deletions
diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c
index 65d84026..005a4e02 100644
--- a/src/jtag/zy1000/zy1000.c
+++ b/src/jtag/zy1000/zy1000.c
@@ -803,34 +803,43 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
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)
+static void jtag_pre_post_bits(struct jtag_tap *tap, int *pre, int *post)
{
-// static int const reg_addr = 0x5;
- tap_state_t end_state = jtag_get_end_state();
- if (jtag_tap_next_enabled(jtag_tap_next_enabled(NULL)) == NULL)
+ /* 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)
{
- /* better performance via code duplication */
- if (little)
+ nextTap = jtag_tap_next_enabled(cur_tap);
+ if (cur_tap == tap)
{
- int i;
- for (i = 0; i < count; i++)
- {
- shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 1));
- shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr | (1 << 5));
- buffer += 4;
- }
+ found = true;
} else
{
- int i;
- for (i = 0; i < count; i++)
+ if (found)
{
- shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 0));
- shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr | (1 << 5));
- buffer += 4;
+ post_bits++;
+ } else
+ {
+ pre_bits++;
}
}
}
- else
+ *pre = pre_bits;
+ *post = post_bits;
+}
+
+void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, uint8_t *buffer, int little, int count)
+{
+
+ int pre_bits;
+ int post_bits;
+ jtag_pre_post_bits(tap, &pre_bits, &post_bits);
+
+ if ((pre_bits > 32) || (post_bits > 32))
{
int i;
for (i = 0; i < count; i++)
@@ -838,6 +847,22 @@ void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, uint8_t *buffer,
embeddedice_write_reg_inner(tap, reg_addr, fast_target_buffer_get_u32(buffer, little));
buffer += 4;
}
+ } else
+ {
+ tap_state_t end_state = jtag_get_end_state();
+ tap_state_t shift_end_state;
+ if (post_bits == 0)
+ shift_end_state = end_state;
+
+ int i;
+ for (i = 0; i < count; i++)
+ {
+ shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, pre_bits, 0);
+ shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, little));
+ shiftValueInner(TAP_DRSHIFT, shift_end_state, 6, reg_addr | (1 << 5));
+ shiftValueInner(shift_end_state, end_state, post_bits, 0);
+ buffer += 4;
+ }
}
}
@@ -858,8 +883,9 @@ int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap * tap, uint32_t opc
/* bypass bits before and after */
- int pre_bits = 0;
- int post_bits = 0;
+ int pre_bits;
+ int post_bits;
+ jtag_pre_post_bits(tap, &pre_bits, &post_bits);
bool found = false;
struct jtag_tap *cur_tap, *nextTap;
@@ -895,6 +921,7 @@ int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap * tap, uint32_t opc
value |= (*t++<<24);
shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, value);
+ /* minimum 2 bits */
shiftValueInner(TAP_DRSHIFT, TAP_DRPAUSE, post_bits, 0);
#if 1