From 7ef6a54da2cf7ab0e0473a4fdf62d701fffbc34a Mon Sep 17 00:00:00 2001 From: Franck Jullien Date: Thu, 3 Oct 2013 23:22:32 +0200 Subject: [PATCH] jtag_vpi: fix path move function Change-Id: I82bf6f733e0d9cb5c86553d0827c558fa98aa247 Signed-off-by: Franck Jullien Reviewed-on: http://openocd.zylin.com/1672 Tested-by: jenkins Reviewed-by: Andreas Fritiofson --- src/jtag/drivers/jtag_vpi.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c index 84cd94706..d0e90e2af 100644 --- a/src/jtag/drivers/jtag_vpi.c +++ b/src/jtag/drivers/jtag_vpi.c @@ -123,23 +123,17 @@ static int jtag_vpi_tms_seq(const uint8_t *bits, int nb_bits) static int jtag_vpi_path_move(struct pathmove_command *cmd) { - uint16_t trans = 0; - int retval; - int i; + uint8_t trans[DIV_ROUND_UP(cmd->num_states, 8)]; - for (i = 0; i < cmd->num_states; i++) { + memset(trans, 0, DIV_ROUND_UP(cmd->num_states, 8)); + + for (int i = 0; i < cmd->num_states; i++) { if (tap_state_transition(tap_get_state(), true) == cmd->path[i]) - trans = trans | 1; - trans = trans << 1; + buf_set_u32(trans, i, 1, 1); + tap_set_state(cmd->path[i]); } - retval = jtag_vpi_tms_seq((uint8_t *)&trans, 1); - if (retval != ERROR_OK) - return retval; - - tap_set_state(cmd->path[i]); - - return ERROR_OK; + return jtag_vpi_tms_seq(trans, cmd->num_states); } /**