jtag/commands: Use 'unsigned int' data type

This patch modifies as little code as possible in order to simplify the
review. Data types that are affected by these changes will be addresses
in following patches.

While at it, apply coding style fixes if these are not too extensive.

Change-Id: Ie048b3d472f546fecb6733f17f9d0f17fda40187
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8404
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Marc Schink 2024-07-17 17:35:42 +02:00 committed by Antonio Borneo
parent 42450345dd
commit 0847a4d7fb
31 changed files with 201 additions and 239 deletions

View File

@ -166,10 +166,9 @@ void jtag_scan_field_clone(struct scan_field *dst, const struct scan_field *src)
enum scan_type jtag_scan_type(const struct scan_command *cmd) enum scan_type jtag_scan_type(const struct scan_command *cmd)
{ {
int i;
int type = 0; int type = 0;
for (i = 0; i < cmd->num_fields; i++) { for (unsigned int i = 0; i < cmd->num_fields; i++) {
if (cmd->fields[i].in_value) if (cmd->fields[i].in_value)
type |= SCAN_IN; type |= SCAN_IN;
if (cmd->fields[i].out_value) if (cmd->fields[i].out_value)
@ -182,10 +181,9 @@ enum scan_type jtag_scan_type(const struct scan_command *cmd)
int jtag_scan_size(const struct scan_command *cmd) int jtag_scan_size(const struct scan_command *cmd)
{ {
int bit_count = 0; int bit_count = 0;
int i;
/* count bits in scan command */ /* count bits in scan command */
for (i = 0; i < cmd->num_fields; i++) for (unsigned int i = 0; i < cmd->num_fields; i++)
bit_count += cmd->fields[i].num_bits; bit_count += cmd->fields[i].num_bits;
return bit_count; return bit_count;
@ -194,18 +192,17 @@ int jtag_scan_size(const struct scan_command *cmd)
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer) int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
{ {
int bit_count = 0; int bit_count = 0;
int i;
bit_count = jtag_scan_size(cmd); bit_count = jtag_scan_size(cmd);
*buffer = calloc(1, DIV_ROUND_UP(bit_count, 8)); *buffer = calloc(1, DIV_ROUND_UP(bit_count, 8));
bit_count = 0; bit_count = 0;
LOG_DEBUG_IO("%s num_fields: %i", LOG_DEBUG_IO("%s num_fields: %u",
cmd->ir_scan ? "IRSCAN" : "DRSCAN", cmd->ir_scan ? "IRSCAN" : "DRSCAN",
cmd->num_fields); cmd->num_fields);
for (i = 0; i < cmd->num_fields; i++) { for (unsigned int i = 0; i < cmd->num_fields; i++) {
if (cmd->fields[i].out_value) { if (cmd->fields[i].out_value) {
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) { if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) {
char *char_buf = buf_to_hex_str(cmd->fields[i].out_value, char *char_buf = buf_to_hex_str(cmd->fields[i].out_value,
@ -213,14 +210,14 @@ int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
? DEBUG_JTAG_IOZ ? DEBUG_JTAG_IOZ
: cmd->fields[i].num_bits); : cmd->fields[i].num_bits);
LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i, LOG_DEBUG("fields[%u].out_value[%i]: 0x%s", i,
cmd->fields[i].num_bits, char_buf); cmd->fields[i].num_bits, char_buf);
free(char_buf); free(char_buf);
} }
buf_set_buf(cmd->fields[i].out_value, 0, *buffer, buf_set_buf(cmd->fields[i].out_value, 0, *buffer,
bit_count, cmd->fields[i].num_bits); bit_count, cmd->fields[i].num_bits);
} else { } else {
LOG_DEBUG_IO("fields[%i].out_value[%i]: NULL", LOG_DEBUG_IO("fields[%u].out_value[%i]: NULL",
i, cmd->fields[i].num_bits); i, cmd->fields[i].num_bits);
} }
@ -234,14 +231,13 @@ int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd) int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
{ {
int i;
int bit_count = 0; int bit_count = 0;
int retval; int retval;
/* we return ERROR_OK, unless a check fails, or a handler reports a problem */ /* we return ERROR_OK, unless a check fails, or a handler reports a problem */
retval = ERROR_OK; retval = ERROR_OK;
for (i = 0; i < cmd->num_fields; i++) { for (unsigned int i = 0; i < cmd->num_fields; i++) {
/* if neither in_value nor in_handler /* if neither in_value nor in_handler
* are specified we don't have to examine this field * are specified we don't have to examine this field
*/ */
@ -256,7 +252,7 @@ int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
? DEBUG_JTAG_IOZ ? DEBUG_JTAG_IOZ
: num_bits); : num_bits);
LOG_DEBUG("fields[%i].in_value[%i]: 0x%s", LOG_DEBUG("fields[%u].in_value[%i]: 0x%s",
i, num_bits, char_buf); i, num_bits, char_buf);
free(char_buf); free(char_buf);
} }

View File

@ -36,7 +36,7 @@ struct scan_command {
/** instruction/not data scan */ /** instruction/not data scan */
bool ir_scan; bool ir_scan;
/** number of fields in *fields array */ /** number of fields in *fields array */
int num_fields; unsigned int num_fields;
/** pointer to an array of data scan fields */ /** pointer to an array of data scan fields */
struct scan_field *fields; struct scan_field *fields;
/** state in which JTAG commands should finish */ /** state in which JTAG commands should finish */
@ -50,14 +50,14 @@ struct statemove_command {
struct pathmove_command { struct pathmove_command {
/** number of states in *path */ /** number of states in *path */
int num_states; unsigned int num_states;
/** states that have to be passed */ /** states that have to be passed */
tap_state_t *path; tap_state_t *path;
}; };
struct runtest_command { struct runtest_command {
/** number of cycles to spend in Run-Test/Idle state */ /** number of cycles to spend in Run-Test/Idle state */
int num_cycles; unsigned int num_cycles;
/** state in which JTAG commands should finish */ /** state in which JTAG commands should finish */
tap_state_t end_state; tap_state_t end_state;
}; };
@ -65,7 +65,7 @@ struct runtest_command {
struct stableclocks_command { struct stableclocks_command {
/** number of clock cycles that should be sent */ /** number of clock cycles that should be sent */
int num_cycles; unsigned int num_cycles;
}; };
@ -100,7 +100,7 @@ struct sleep_command {
*/ */
struct tms_command { struct tms_command {
/** How many bits should be clocked out. */ /** How many bits should be clocked out. */
unsigned num_bits; unsigned int num_bits;
/** The bits to clock out; the LSB is bit 0 of bits[0]. */ /** The bits to clock out; the LSB is bit 0 of bits[0]. */
const uint8_t *bits; const uint8_t *bits;
}; };

View File

@ -514,7 +514,7 @@ int jtag_add_tms_seq(unsigned nbits, const uint8_t *seq, enum tap_state state)
return retval; return retval;
} }
void jtag_add_pathmove(int num_states, const tap_state_t *path) void jtag_add_pathmove(unsigned int num_states, const tap_state_t *path)
{ {
tap_state_t cur_state = cmd_queue_cur_state; tap_state_t cur_state = cmd_queue_cur_state;
@ -525,7 +525,7 @@ void jtag_add_pathmove(int num_states, const tap_state_t *path)
return; return;
} }
for (int i = 0; i < num_states; i++) { for (unsigned int i = 0; i < num_states; i++) {
if (path[i] == TAP_RESET) { if (path[i] == TAP_RESET) {
LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences"); LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
jtag_set_error(ERROR_JTAG_STATE_INVALID); jtag_set_error(ERROR_JTAG_STATE_INVALID);
@ -589,14 +589,14 @@ int jtag_add_statemove(tap_state_t goal_state)
return ERROR_OK; return ERROR_OK;
} }
void jtag_add_runtest(int num_cycles, tap_state_t state) void jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
{ {
jtag_prelude(state); jtag_prelude(state);
jtag_set_error(interface_jtag_add_runtest(num_cycles, state)); jtag_set_error(interface_jtag_add_runtest(num_cycles, state));
} }
void jtag_add_clocks(int num_cycles) void jtag_add_clocks(unsigned int num_cycles)
{ {
if (!tap_is_state_stable(cmd_queue_cur_state)) { if (!tap_is_state_stable(cmd_queue_cur_state)) {
LOG_ERROR("jtag_add_clocks() called with TAP in unstable state \"%s\"", LOG_ERROR("jtag_add_clocks() called with TAP in unstable state \"%s\"",
@ -960,7 +960,7 @@ int default_interface_jtag_execute_queue(void)
LOG_DEBUG_IO("JTAG %s SCAN to %s", LOG_DEBUG_IO("JTAG %s SCAN to %s",
cmd->cmd.scan->ir_scan ? "IR" : "DR", cmd->cmd.scan->ir_scan ? "IR" : "DR",
tap_state_name(cmd->cmd.scan->end_state)); tap_state_name(cmd->cmd.scan->end_state));
for (int i = 0; i < cmd->cmd.scan->num_fields; i++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) {
struct scan_field *field = cmd->cmd.scan->fields + i; struct scan_field *field = cmd->cmd.scan->fields + i;
if (field->out_value) { if (field->out_value) {
char *str = buf_to_hex_str(field->out_value, field->num_bits); char *str = buf_to_hex_str(field->out_value, field->num_bits);

View File

@ -203,7 +203,7 @@ static void amt_jtagaccel_state_move(void)
tap_set_state(end_state); tap_set_state(end_state);
} }
static void amt_jtagaccel_runtest(int num_cycles) static void amt_jtagaccel_runtest(unsigned int num_cycles)
{ {
int i = 0; int i = 0;
uint8_t aw_scan_tms_5; uint8_t aw_scan_tms_5;

View File

@ -1836,15 +1836,17 @@ static int angie_reset(int trst, int srst)
*/ */
static int angie_queue_pathmove(struct angie *device, struct jtag_command *cmd) static int angie_queue_pathmove(struct angie *device, struct jtag_command *cmd)
{ {
int ret, i, num_states, batch_size, state_count; int ret, state_count;
tap_state_t *path; tap_state_t *path;
uint8_t tms_sequence; uint8_t tms_sequence;
num_states = cmd->cmd.pathmove->num_states; unsigned int num_states = cmd->cmd.pathmove->num_states;
path = cmd->cmd.pathmove->path; path = cmd->cmd.pathmove->path;
state_count = 0; state_count = 0;
while (num_states > 0) { while (num_states > 0) {
unsigned int batch_size;
tms_sequence = 0; tms_sequence = 0;
/* Determine batch size */ /* Determine batch size */
@ -1853,7 +1855,7 @@ static int angie_queue_pathmove(struct angie *device, struct jtag_command *cmd)
else else
batch_size = num_states; batch_size = num_states;
for (i = 0; i < batch_size; i++) { for (unsigned int i = 0; i < batch_size; i++) {
if (tap_state_transition(tap_get_state(), false) == path[state_count]) { if (tap_state_transition(tap_get_state(), false) == path[state_count]) {
/* Append '0' transition: clear bit 'i' in tms_sequence */ /* Append '0' transition: clear bit 'i' in tms_sequence */
buf_set_u32(&tms_sequence, i, 1, 0x0); buf_set_u32(&tms_sequence, i, 1, 0x0);
@ -1908,14 +1910,13 @@ static int angie_queue_sleep(struct angie *device, struct jtag_command *cmd)
static int angie_queue_stableclocks(struct angie *device, struct jtag_command *cmd) static int angie_queue_stableclocks(struct angie *device, struct jtag_command *cmd)
{ {
int ret; int ret;
unsigned int num_cycles;
if (!tap_is_state_stable(tap_get_state())) { if (!tap_is_state_stable(tap_get_state())) {
LOG_ERROR("JTAG_STABLECLOCKS: state not stable"); LOG_ERROR("JTAG_STABLECLOCKS: state not stable");
return ERROR_FAIL; return ERROR_FAIL;
} }
num_cycles = cmd->cmd.stableclocks->num_cycles; unsigned int num_cycles = cmd->cmd.stableclocks->num_cycles;
/* TMS stays either high (Test Logic Reset state) or low (all other states) */ /* TMS stays either high (Test Logic Reset state) or low (all other states) */
if (tap_get_state() == TAP_RESET) if (tap_get_state() == TAP_RESET)

View File

@ -44,8 +44,8 @@ static uint8_t usb_out_buffer[ARMJTAGEW_OUT_BUFFER_SIZE];
/* Queue command functions */ /* Queue command functions */
static void armjtagew_end_state(tap_state_t state); static void armjtagew_end_state(tap_state_t state);
static void armjtagew_state_move(void); static void armjtagew_state_move(void);
static void armjtagew_path_move(int num_states, tap_state_t *path); static void armjtagew_path_move(unsigned int num_states, tap_state_t *path);
static void armjtagew_runtest(int num_cycles); static void armjtagew_runtest(unsigned int num_cycles);
static void armjtagew_scan(bool ir_scan, static void armjtagew_scan(bool ir_scan,
enum scan_type type, enum scan_type type,
uint8_t *buffer, uint8_t *buffer,
@ -95,7 +95,7 @@ static int armjtagew_execute_queue(struct jtag_command *cmd_queue)
while (cmd) { while (cmd) {
switch (cmd->type) { switch (cmd->type) {
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i", LOG_DEBUG_IO("runtest %u cycles, end in %i",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state); cmd->cmd.runtest->end_state);
@ -111,7 +111,7 @@ static int armjtagew_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %i", LOG_DEBUG_IO("pathmove: %u states, end in %i",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@ -279,11 +279,9 @@ static void armjtagew_state_move(void)
tap_set_state(tap_get_end_state()); tap_set_state(tap_get_end_state());
} }
static void armjtagew_path_move(int num_states, tap_state_t *path) static void armjtagew_path_move(unsigned int num_states, tap_state_t *path)
{ {
int i; for (unsigned int i = 0; i < num_states; i++) {
for (i = 0; i < num_states; i++) {
/* /*
* TODO: The ARM-JTAG-EW hardware delays TDI with 3 TCK cycles when in RTCK mode. * TODO: The ARM-JTAG-EW hardware delays TDI with 3 TCK cycles when in RTCK mode.
* Either handle that here, or update the documentation with examples * Either handle that here, or update the documentation with examples
@ -305,10 +303,8 @@ static void armjtagew_path_move(int num_states, tap_state_t *path)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void armjtagew_runtest(int num_cycles) static void armjtagew_runtest(unsigned int num_cycles)
{ {
int i;
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
@ -318,7 +314,7 @@ static void armjtagew_runtest(int num_cycles)
} }
/* execute num_cycles */ /* execute num_cycles */
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
armjtagew_tap_append_step(0, 0); armjtagew_tap_append_step(0, 0);
/* finish in end_state */ /* finish in end_state */

View File

@ -33,7 +33,7 @@
* this function checks the current stable state to decide on the value of TMS * this function checks the current stable state to decide on the value of TMS
* to use. * to use.
*/ */
static int bitbang_stableclocks(int num_cycles); static int bitbang_stableclocks(unsigned int num_cycles);
static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk); static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk);
@ -95,7 +95,7 @@ static int bitbang_execute_tms(struct jtag_command *cmd)
unsigned num_bits = cmd->cmd.tms->num_bits; unsigned num_bits = cmd->cmd.tms->num_bits;
const uint8_t *bits = cmd->cmd.tms->bits; const uint8_t *bits = cmd->cmd.tms->bits;
LOG_DEBUG_IO("TMS: %d bits", num_bits); LOG_DEBUG_IO("TMS: %u bits", num_bits);
int tms = 0; int tms = 0;
for (unsigned i = 0; i < num_bits; i++) { for (unsigned i = 0; i < num_bits; i++) {
@ -113,7 +113,7 @@ static int bitbang_execute_tms(struct jtag_command *cmd)
static int bitbang_path_move(struct pathmove_command *cmd) static int bitbang_path_move(struct pathmove_command *cmd)
{ {
int num_states = cmd->num_states; unsigned int num_states = cmd->num_states;
int state_count; int state_count;
int tms = 0; int tms = 0;
@ -147,10 +147,8 @@ static int bitbang_path_move(struct pathmove_command *cmd)
return ERROR_OK; return ERROR_OK;
} }
static int bitbang_runtest(int num_cycles) static int bitbang_runtest(unsigned int num_cycles)
{ {
int i;
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
@ -161,7 +159,7 @@ static int bitbang_runtest(int num_cycles)
} }
/* execute num_cycles */ /* execute num_cycles */
for (i = 0; i < num_cycles; i++) { for (unsigned int i = 0; i < num_cycles; i++) {
if (bitbang_interface->write(0, 0, 0) != ERROR_OK) if (bitbang_interface->write(0, 0, 0) != ERROR_OK)
return ERROR_FAIL; return ERROR_FAIL;
if (bitbang_interface->write(1, 0, 0) != ERROR_OK) if (bitbang_interface->write(1, 0, 0) != ERROR_OK)
@ -179,13 +177,12 @@ static int bitbang_runtest(int num_cycles)
return ERROR_OK; return ERROR_OK;
} }
static int bitbang_stableclocks(int num_cycles) static int bitbang_stableclocks(unsigned int num_cycles)
{ {
int tms = (tap_get_state() == TAP_RESET ? 1 : 0); int tms = (tap_get_state() == TAP_RESET ? 1 : 0);
int i;
/* send num_cycles clocks onto the cable */ /* send num_cycles clocks onto the cable */
for (i = 0; i < num_cycles; i++) { for (unsigned int i = 0; i < num_cycles; i++) {
if (bitbang_interface->write(1, tms, 0) != ERROR_OK) if (bitbang_interface->write(1, tms, 0) != ERROR_OK)
return ERROR_FAIL; return ERROR_FAIL;
if (bitbang_interface->write(0, tms, 0) != ERROR_OK) if (bitbang_interface->write(0, tms, 0) != ERROR_OK)
@ -319,7 +316,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
while (cmd) { while (cmd) {
switch (cmd->type) { switch (cmd->type) {
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %s", LOG_DEBUG_IO("runtest %u cycles, end in %s",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state)); tap_state_name(cmd->cmd.runtest->end_state));
bitbang_end_state(cmd->cmd.runtest->end_state); bitbang_end_state(cmd->cmd.runtest->end_state);
@ -343,7 +340,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
return ERROR_FAIL; return ERROR_FAIL;
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %s", LOG_DEBUG_IO("pathmove: %u states, end in %s",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK) if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK)

View File

@ -18,7 +18,7 @@ struct bitq_interface *bitq_interface; /* low level bit queue interface */
/* state of input queue */ /* state of input queue */
struct bitq_state { struct bitq_state {
struct jtag_command *cmd; /* command currently processed */ struct jtag_command *cmd; /* command currently processed */
int field_idx; /* index of field currently being processed */ unsigned int field_idx; /* index of field currently being processed */
int bit_pos; /* position of bit currently being processed */ int bit_pos; /* position of bit currently being processed */
int status; /* processing status */ int status; /* processing status */
}; };
@ -108,9 +108,7 @@ static void bitq_state_move(tap_state_t new_state)
static void bitq_path_move(struct pathmove_command *cmd) static void bitq_path_move(struct pathmove_command *cmd)
{ {
int i; for (unsigned int i = 0; i < cmd->num_states; i++) {
for (i = 0; i < cmd->num_states; i++) {
if (tap_state_transition(tap_get_state(), false) == cmd->path[i]) if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
bitq_io(0, 0, 0); bitq_io(0, 0, 0);
else if (tap_state_transition(tap_get_state(), true) == cmd->path[i]) else if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
@ -127,16 +125,14 @@ static void bitq_path_move(struct pathmove_command *cmd)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void bitq_runtest(int num_cycles) static void bitq_runtest(unsigned int num_cycles)
{ {
int i;
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
if (tap_get_state() != TAP_IDLE) if (tap_get_state() != TAP_IDLE)
bitq_state_move(TAP_IDLE); bitq_state_move(TAP_IDLE);
/* execute num_cycles */ /* execute num_cycles */
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
bitq_io(0, 0, 0); bitq_io(0, 0, 0);
/* finish in end_state */ /* finish in end_state */
@ -190,13 +186,12 @@ static void bitq_scan_field(struct scan_field *field, int do_pause)
static void bitq_scan(struct scan_command *cmd) static void bitq_scan(struct scan_command *cmd)
{ {
int i;
if (cmd->ir_scan) if (cmd->ir_scan)
bitq_state_move(TAP_IRSHIFT); bitq_state_move(TAP_IRSHIFT);
else else
bitq_state_move(TAP_DRSHIFT); bitq_state_move(TAP_DRSHIFT);
unsigned int i;
for (i = 0; i < cmd->num_fields - 1; i++) for (i = 0; i < cmd->num_fields - 1; i++)
bitq_scan_field(&cmd->fields[i], 0); bitq_scan_field(&cmd->fields[i], 0);
@ -226,7 +221,7 @@ int bitq_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
bitq_end_state(cmd->cmd.runtest->end_state); bitq_end_state(cmd->cmd.runtest->end_state);
bitq_runtest(cmd->cmd.runtest->num_cycles); bitq_runtest(cmd->cmd.runtest->num_cycles);
break; break;
@ -238,7 +233,7 @@ int bitq_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, LOG_DEBUG_IO("pathmove: %u states, end in %i", cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
bitq_path_move(cmd->cmd.pathmove); bitq_path_move(cmd->cmd.pathmove);
break; break;

View File

@ -27,11 +27,11 @@ static int buspirate_reset(int trst, int srst);
static void buspirate_end_state(tap_state_t state); static void buspirate_end_state(tap_state_t state);
static void buspirate_state_move(void); static void buspirate_state_move(void);
static void buspirate_path_move(int num_states, tap_state_t *path); static void buspirate_path_move(unsigned int num_states, tap_state_t *path);
static void buspirate_runtest(int num_cycles); static void buspirate_runtest(unsigned int num_cycles);
static void buspirate_scan(bool ir_scan, enum scan_type type, static void buspirate_scan(bool ir_scan, enum scan_type type,
uint8_t *buffer, int scan_size, struct scan_command *command); uint8_t *buffer, int scan_size, struct scan_command *command);
static void buspirate_stableclocks(int num_cycles); static void buspirate_stableclocks(unsigned int num_cycles);
#define CMD_UNKNOWN 0x00 #define CMD_UNKNOWN 0x00
#define CMD_PORT_MODE 0x01 #define CMD_PORT_MODE 0x01
@ -162,7 +162,7 @@ static int buspirate_execute_queue(struct jtag_command *cmd_queue)
while (cmd) { while (cmd) {
switch (cmd->type) { switch (cmd->type) {
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %s", LOG_DEBUG_IO("runtest %u cycles, end in %s",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest tap_state_name(cmd->cmd.runtest
->end_state)); ->end_state));
@ -180,7 +180,7 @@ static int buspirate_execute_queue(struct jtag_command *cmd_queue)
buspirate_state_move(); buspirate_state_move();
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %s", LOG_DEBUG_IO("pathmove: %u states, end in %s",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove tap_state_name(cmd->cmd.pathmove
->path[cmd->cmd.pathmove ->path[cmd->cmd.pathmove
@ -210,7 +210,7 @@ static int buspirate_execute_queue(struct jtag_command *cmd_queue)
jtag_sleep(cmd->cmd.sleep->us); jtag_sleep(cmd->cmd.sleep->us);
break; break;
case JTAG_STABLECLOCKS: case JTAG_STABLECLOCKS:
LOG_DEBUG_IO("stable clock %i cycles", cmd->cmd.stableclocks->num_cycles); LOG_DEBUG_IO("stable clock %u cycles", cmd->cmd.stableclocks->num_cycles);
buspirate_stableclocks(cmd->cmd.stableclocks->num_cycles); buspirate_stableclocks(cmd->cmd.stableclocks->num_cycles);
break; break;
default: default:
@ -580,11 +580,9 @@ static void buspirate_state_move(void)
tap_set_state(tap_get_end_state()); tap_set_state(tap_get_end_state());
} }
static void buspirate_path_move(int num_states, tap_state_t *path) static void buspirate_path_move(unsigned int num_states, tap_state_t *path)
{ {
int i; for (unsigned int i = 0; i < num_states; i++) {
for (i = 0; i < num_states; i++) {
if (tap_state_transition(tap_get_state(), false) == path[i]) { if (tap_state_transition(tap_get_state(), false) == path[i]) {
buspirate_tap_append(0, 0); buspirate_tap_append(0, 0);
} else if (tap_state_transition(tap_get_state(), true) } else if (tap_state_transition(tap_get_state(), true)
@ -604,10 +602,8 @@ static void buspirate_path_move(int num_states, tap_state_t *path)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void buspirate_runtest(int num_cycles) static void buspirate_runtest(unsigned int num_cycles)
{ {
int i;
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
@ -616,7 +612,7 @@ static void buspirate_runtest(int num_cycles)
buspirate_state_move(); buspirate_state_move();
} }
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
buspirate_tap_append(0, 0); buspirate_tap_append(0, 0);
LOG_DEBUG_IO("runtest: cur_state %s end_state %s", LOG_DEBUG_IO("runtest: cur_state %s end_state %s",
@ -658,14 +654,13 @@ static void buspirate_scan(bool ir_scan, enum scan_type type,
buspirate_state_move(); buspirate_state_move();
} }
static void buspirate_stableclocks(int num_cycles) static void buspirate_stableclocks(unsigned int num_cycles)
{ {
int i;
int tms = (tap_get_state() == TAP_RESET ? 1 : 0); int tms = (tap_get_state() == TAP_RESET ? 1 : 0);
buspirate_tap_make_space(0, num_cycles); buspirate_tap_make_space(0, num_cycles);
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
buspirate_tap_append(tms, 0); buspirate_tap_append(tms, 0);
} }

View File

@ -1752,7 +1752,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
LOG_DEBUG("discarding trailing empty field"); LOG_DEBUG("discarding trailing empty field");
} }
if (cmd->cmd.scan->num_fields == 0) { if (!cmd->cmd.scan->num_fields) {
LOG_DEBUG("empty scan, doing nothing"); LOG_DEBUG("empty scan, doing nothing");
return; return;
} }
@ -1774,9 +1774,9 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
struct scan_field *field = cmd->cmd.scan->fields; struct scan_field *field = cmd->cmd.scan->fields;
unsigned scan_size = 0; unsigned scan_size = 0;
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
scan_size += field->num_bits; scan_size += field->num_bits;
LOG_DEBUG_IO("%s%s field %d/%d %d bits", LOG_DEBUG_IO("%s%s field %u/%u %d bits",
field->in_value ? "in" : "", field->in_value ? "in" : "",
field->out_value ? "out" : "", field->out_value ? "out" : "",
i, i,
@ -1872,16 +1872,16 @@ static void cmsis_dap_execute_pathmove(struct jtag_command *cmd)
cmsis_dap_pathmove(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path); cmsis_dap_pathmove(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path);
} }
static void cmsis_dap_stableclocks(int num_cycles) static void cmsis_dap_stableclocks(unsigned int num_cycles)
{ {
uint8_t tms = tap_get_state() == TAP_RESET; uint8_t tms = tap_get_state() == TAP_RESET;
/* TODO: Perform optimizations? */ /* TODO: Perform optimizations? */
/* Execute num_cycles. */ /* Execute num_cycles. */
for (int i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
cmsis_dap_add_tms_sequence(&tms, 1); cmsis_dap_add_tms_sequence(&tms, 1);
} }
static void cmsis_dap_runtest(int num_cycles) static void cmsis_dap_runtest(unsigned int num_cycles)
{ {
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
@ -1901,7 +1901,7 @@ static void cmsis_dap_runtest(int num_cycles)
static void cmsis_dap_execute_runtest(struct jtag_command *cmd) static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
{ {
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state); cmd->cmd.runtest->end_state);
cmsis_dap_end_state(cmd->cmd.runtest->end_state); cmsis_dap_end_state(cmd->cmd.runtest->end_state);
@ -1910,13 +1910,13 @@ static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
static void cmsis_dap_execute_stableclocks(struct jtag_command *cmd) static void cmsis_dap_execute_stableclocks(struct jtag_command *cmd)
{ {
LOG_DEBUG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles); LOG_DEBUG_IO("stableclocks %u cycles", cmd->cmd.runtest->num_cycles);
cmsis_dap_stableclocks(cmd->cmd.runtest->num_cycles); cmsis_dap_stableclocks(cmd->cmd.runtest->num_cycles);
} }
static void cmsis_dap_execute_tms(struct jtag_command *cmd) static void cmsis_dap_execute_tms(struct jtag_command *cmd)
{ {
LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits); LOG_DEBUG_IO("TMS: %u bits", cmd->cmd.tms->num_bits);
cmsis_dap_cmd_dap_swj_sequence(cmd->cmd.tms->num_bits, cmd->cmd.tms->bits); cmsis_dap_cmd_dap_swj_sequence(cmd->cmd.tms->num_bits, cmd->cmd.tms->bits);
} }

View File

@ -259,7 +259,7 @@ int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state
return ERROR_OK; return ERROR_OK;
} }
int interface_jtag_add_pathmove(int num_states, const tap_state_t *path) int interface_jtag_add_pathmove(unsigned int num_states, const tap_state_t *path)
{ {
/* allocate memory for a new list member */ /* allocate memory for a new list member */
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command)); struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
@ -272,13 +272,13 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
cmd->cmd.pathmove->num_states = num_states; cmd->cmd.pathmove->num_states = num_states;
cmd->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states); cmd->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states);
for (int i = 0; i < num_states; i++) for (unsigned int i = 0; i < num_states; i++)
cmd->cmd.pathmove->path[i] = path[i]; cmd->cmd.pathmove->path[i] = path[i];
return ERROR_OK; return ERROR_OK;
} }
int interface_jtag_add_runtest(int num_cycles, tap_state_t state) int interface_jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
{ {
/* allocate memory for a new list member */ /* allocate memory for a new list member */
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command)); struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
@ -294,7 +294,7 @@ int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
return ERROR_OK; return ERROR_OK;
} }
int interface_jtag_add_clocks(int num_cycles) int interface_jtag_add_clocks(unsigned int num_cycles)
{ {
/* allocate memory for a new list member */ /* allocate memory for a new list member */
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command)); struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));

View File

@ -657,7 +657,7 @@ static int syncbb_execute_tms(struct jtag_command *cmd)
unsigned num_bits = cmd->cmd.tms->num_bits; unsigned num_bits = cmd->cmd.tms->num_bits;
const uint8_t *bits = cmd->cmd.tms->bits; const uint8_t *bits = cmd->cmd.tms->bits;
LOG_DEBUG_IO("TMS: %d bits", num_bits); LOG_DEBUG_IO("TMS: %u bits", num_bits);
int tms = 0; int tms = 0;
for (unsigned i = 0; i < num_bits; i++) { for (unsigned i = 0; i < num_bits; i++) {
@ -672,7 +672,7 @@ static int syncbb_execute_tms(struct jtag_command *cmd)
static void syncbb_path_move(struct pathmove_command *cmd) static void syncbb_path_move(struct pathmove_command *cmd)
{ {
int num_states = cmd->num_states; unsigned int num_states = cmd->num_states;
int state_count; int state_count;
int tms = 0; int tms = 0;
@ -702,9 +702,8 @@ static void syncbb_path_move(struct pathmove_command *cmd)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void syncbb_runtest(int num_cycles) static void syncbb_runtest(unsigned int num_cycles)
{ {
int i;
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
@ -715,7 +714,7 @@ static void syncbb_runtest(int num_cycles)
} }
/* execute num_cycles */ /* execute num_cycles */
for (i = 0; i < num_cycles; i++) { for (unsigned int i = 0; i < num_cycles; i++) {
ft232r_write(0, 0, 0); ft232r_write(0, 0, 0);
ft232r_write(1, 0, 0); ft232r_write(1, 0, 0);
} }
@ -735,13 +734,12 @@ static void syncbb_runtest(int num_cycles)
* this function checks the current stable state to decide on the value of TMS * this function checks the current stable state to decide on the value of TMS
* to use. * to use.
*/ */
static void syncbb_stableclocks(int num_cycles) static void syncbb_stableclocks(unsigned int num_cycles)
{ {
int tms = (tap_get_state() == TAP_RESET ? 1 : 0); int tms = (tap_get_state() == TAP_RESET ? 1 : 0);
int i;
/* send num_cycles clocks onto the cable */ /* send num_cycles clocks onto the cable */
for (i = 0; i < num_cycles; i++) { for (unsigned int i = 0; i < num_cycles; i++) {
ft232r_write(1, tms, 0); ft232r_write(1, tms, 0);
ft232r_write(0, tms, 0); ft232r_write(0, tms, 0);
} }
@ -832,7 +830,7 @@ static int syncbb_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, LOG_DEBUG_IO("runtest %u cycles, end in %s", cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state)); tap_state_name(cmd->cmd.runtest->end_state));
syncbb_end_state(cmd->cmd.runtest->end_state); syncbb_end_state(cmd->cmd.runtest->end_state);
@ -854,7 +852,7 @@ static int syncbb_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %s", cmd->cmd.pathmove->num_states, LOG_DEBUG_IO("pathmove: %u states, end in %s", cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
syncbb_path_move(cmd->cmd.pathmove); syncbb_path_move(cmd->cmd.pathmove);

View File

@ -311,10 +311,9 @@ static void ftdi_end_state(tap_state_t state)
static void ftdi_execute_runtest(struct jtag_command *cmd) static void ftdi_execute_runtest(struct jtag_command *cmd)
{ {
int i;
uint8_t zero = 0; uint8_t zero = 0;
LOG_DEBUG_IO("runtest %i cycles, end in %s", LOG_DEBUG_IO("runtest %u cycles, end in %s",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state)); tap_state_name(cmd->cmd.runtest->end_state));
@ -322,7 +321,7 @@ static void ftdi_execute_runtest(struct jtag_command *cmd)
move_to_state(TAP_IDLE); move_to_state(TAP_IDLE);
/* TODO: Reuse ftdi_execute_stableclocks */ /* TODO: Reuse ftdi_execute_stableclocks */
i = cmd->cmd.runtest->num_cycles; unsigned int i = cmd->cmd.runtest->num_cycles;
while (i > 0) { while (i > 0) {
/* there are no state transitions in this code, so omit state tracking */ /* there are no state transitions in this code, so omit state tracking */
unsigned this_len = i > 7 ? 7 : i; unsigned this_len = i > 7 ? 7 : i;
@ -335,7 +334,7 @@ static void ftdi_execute_runtest(struct jtag_command *cmd)
if (tap_get_state() != tap_get_end_state()) if (tap_get_state() != tap_get_end_state())
move_to_state(tap_get_end_state()); move_to_state(tap_get_end_state());
LOG_DEBUG_IO("runtest: %i, end in %s", LOG_DEBUG_IO("runtest: %u, end in %s",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
tap_state_name(tap_get_end_state())); tap_state_name(tap_get_end_state()));
} }
@ -358,7 +357,7 @@ static void ftdi_execute_statemove(struct jtag_command *cmd)
*/ */
static void ftdi_execute_tms(struct jtag_command *cmd) static void ftdi_execute_tms(struct jtag_command *cmd)
{ {
LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits); LOG_DEBUG_IO("TMS: %u bits", cmd->cmd.tms->num_bits);
/* TODO: Missing tap state tracking, also missing from ft2232.c! */ /* TODO: Missing tap state tracking, also missing from ft2232.c! */
mpsse_clock_tms_cs_out(mpsse_ctx, mpsse_clock_tms_cs_out(mpsse_ctx,
@ -372,9 +371,9 @@ static void ftdi_execute_tms(struct jtag_command *cmd)
static void ftdi_execute_pathmove(struct jtag_command *cmd) static void ftdi_execute_pathmove(struct jtag_command *cmd)
{ {
tap_state_t *path = cmd->cmd.pathmove->path; tap_state_t *path = cmd->cmd.pathmove->path;
int num_states = cmd->cmd.pathmove->num_states; unsigned int num_states = cmd->cmd.pathmove->num_states;
LOG_DEBUG_IO("pathmove: %i states, current: %s end: %s", num_states, LOG_DEBUG_IO("pathmove: %u states, current: %s end: %s", num_states,
tap_state_name(tap_get_state()), tap_state_name(tap_get_state()),
tap_state_name(path[num_states-1])); tap_state_name(path[num_states-1]));
@ -432,7 +431,7 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
LOG_DEBUG_IO("discarding trailing empty field"); LOG_DEBUG_IO("discarding trailing empty field");
} }
if (cmd->cmd.scan->num_fields == 0) { if (!cmd->cmd.scan->num_fields) {
LOG_DEBUG_IO("empty scan, doing nothing"); LOG_DEBUG_IO("empty scan, doing nothing");
return; return;
} }
@ -450,9 +449,9 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
struct scan_field *field = cmd->cmd.scan->fields; struct scan_field *field = cmd->cmd.scan->fields;
unsigned scan_size = 0; unsigned scan_size = 0;
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
scan_size += field->num_bits; scan_size += field->num_bits;
LOG_DEBUG_IO("%s%s field %d/%d %d bits", LOG_DEBUG_IO("%s%s field %u/%u %d bits",
field->in_value ? "in" : "", field->in_value ? "in" : "",
field->out_value ? "out" : "", field->out_value ? "out" : "",
i, i,
@ -576,7 +575,7 @@ static void ftdi_execute_stableclocks(struct jtag_command *cmd)
/* this is only allowed while in a stable state. A check for a stable /* this is only allowed while in a stable state. A check for a stable
* state was done in jtag_add_clocks() * state was done in jtag_add_clocks()
*/ */
int num_cycles = cmd->cmd.stableclocks->num_cycles; unsigned int num_cycles = cmd->cmd.stableclocks->num_cycles;
/* 7 bits of either ones or zeros. */ /* 7 bits of either ones or zeros. */
uint8_t tms = tap_get_state() == TAP_RESET ? 0x7f : 0x00; uint8_t tms = tap_get_state() == TAP_RESET ? 0x7f : 0x00;
@ -590,7 +589,7 @@ static void ftdi_execute_stableclocks(struct jtag_command *cmd)
num_cycles -= this_len; num_cycles -= this_len;
} }
LOG_DEBUG_IO("clocks %i while in %s", LOG_DEBUG_IO("clocks %u while in %s",
cmd->cmd.stableclocks->num_cycles, cmd->cmd.stableclocks->num_cycles,
tap_state_name(tap_get_state())); tap_state_name(tap_get_state()));
} }

View File

@ -185,10 +185,9 @@ static void gw16012_path_move(struct pathmove_command *cmd)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void gw16012_runtest(int num_cycles) static void gw16012_runtest(unsigned int num_cycles)
{ {
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
int i;
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
if (tap_get_state() != TAP_IDLE) { if (tap_get_state() != TAP_IDLE) {
@ -196,7 +195,7 @@ static void gw16012_runtest(int num_cycles)
gw16012_state_move(); gw16012_state_move();
} }
for (i = 0; i < num_cycles; i++) { for (unsigned int i = 0; i < num_cycles; i++) {
gw16012_control(0x0); /* single-bit mode */ gw16012_control(0x0); /* single-bit mode */
gw16012_data(0x0); /* TMS cycle with TMS low */ gw16012_data(0x0); /* TMS cycle with TMS low */
} }
@ -292,7 +291,7 @@ static int gw16012_execute_queue(struct jtag_command *cmd_queue)
gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break; break;
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state); cmd->cmd.runtest->end_state);
gw16012_end_state(cmd->cmd.runtest->end_state); gw16012_end_state(cmd->cmd.runtest->end_state);
gw16012_runtest(cmd->cmd.runtest->num_cycles); gw16012_runtest(cmd->cmd.runtest->num_cycles);

View File

@ -80,9 +80,9 @@ static struct device_config tmp_config;
/* Queue command functions */ /* Queue command functions */
static void jlink_end_state(tap_state_t state); static void jlink_end_state(tap_state_t state);
static void jlink_state_move(void); static void jlink_state_move(void);
static void jlink_path_move(int num_states, tap_state_t *path); static void jlink_path_move(unsigned int num_states, tap_state_t *path);
static void jlink_stableclocks(int num_cycles); static void jlink_stableclocks(unsigned int num_cycles);
static void jlink_runtest(int num_cycles); static void jlink_runtest(unsigned int num_cycles);
static void jlink_reset(int trst, int srst); static void jlink_reset(int trst, int srst);
static int jlink_reset_safe(int trst, int srst); static int jlink_reset_safe(int trst, int srst);
static int jlink_swd_run_queue(void); static int jlink_swd_run_queue(void);
@ -140,7 +140,7 @@ static void jlink_execute_statemove(struct jtag_command *cmd)
static void jlink_execute_pathmove(struct jtag_command *cmd) static void jlink_execute_pathmove(struct jtag_command *cmd)
{ {
LOG_DEBUG_IO("pathmove: %i states, end in %i", LOG_DEBUG_IO("pathmove: %u states, end in %i",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@ -159,7 +159,7 @@ static void jlink_execute_scan(struct jtag_command *cmd)
LOG_DEBUG("discarding trailing empty field"); LOG_DEBUG("discarding trailing empty field");
} }
if (cmd->cmd.scan->num_fields == 0) { if (!cmd->cmd.scan->num_fields) {
LOG_DEBUG("empty scan, doing nothing"); LOG_DEBUG("empty scan, doing nothing");
return; return;
} }
@ -181,9 +181,9 @@ static void jlink_execute_scan(struct jtag_command *cmd)
struct scan_field *field = cmd->cmd.scan->fields; struct scan_field *field = cmd->cmd.scan->fields;
unsigned scan_size = 0; unsigned scan_size = 0;
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
scan_size += field->num_bits; scan_size += field->num_bits;
LOG_DEBUG_IO("%s%s field %d/%d %d bits", LOG_DEBUG_IO("%s%s field %u/%u %d bits",
field->in_value ? "in" : "", field->in_value ? "in" : "",
field->out_value ? "out" : "", field->out_value ? "out" : "",
i, i,
@ -885,12 +885,11 @@ static void jlink_state_move(void)
tap_set_state(tap_get_end_state()); tap_set_state(tap_get_end_state());
} }
static void jlink_path_move(int num_states, tap_state_t *path) static void jlink_path_move(unsigned int num_states, tap_state_t *path)
{ {
int i;
uint8_t tms = 0xff; uint8_t tms = 0xff;
for (i = 0; i < num_states; i++) { for (unsigned int i = 0; i < num_states; i++) {
if (path[i] == tap_state_transition(tap_get_state(), false)) if (path[i] == tap_state_transition(tap_get_state(), false))
jlink_clock_data(NULL, 0, NULL, 0, NULL, 0, 1); jlink_clock_data(NULL, 0, NULL, 0, NULL, 0, 1);
else if (path[i] == tap_state_transition(tap_get_state(), true)) else if (path[i] == tap_state_transition(tap_get_state(), true))
@ -907,17 +906,15 @@ static void jlink_path_move(int num_states, tap_state_t *path)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void jlink_stableclocks(int num_cycles) static void jlink_stableclocks(unsigned int num_cycles)
{ {
int i;
uint8_t tms = tap_get_state() == TAP_RESET; uint8_t tms = tap_get_state() == TAP_RESET;
/* Execute num_cycles. */ /* Execute num_cycles. */
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
jlink_clock_data(NULL, 0, &tms, 0, NULL, 0, 1); jlink_clock_data(NULL, 0, &tms, 0, NULL, 0, 1);
} }
static void jlink_runtest(int num_cycles) static void jlink_runtest(unsigned int num_cycles)
{ {
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();

View File

@ -163,7 +163,7 @@ out:
return ret; return ret;
} }
static int jtag_dpi_runtest(int cycles) static int jtag_dpi_runtest(unsigned int num_cycles)
{ {
char buf[20]; char buf[20];
uint8_t *data_buf = last_ir_buf, *read_scan; uint8_t *data_buf = last_ir_buf, *read_scan;
@ -189,7 +189,7 @@ static int jtag_dpi_runtest(int cycles)
return ERROR_FAIL; return ERROR_FAIL;
} }
snprintf(buf, sizeof(buf), "ib %d\n", num_bits); snprintf(buf, sizeof(buf), "ib %d\n", num_bits);
while (cycles > 0) { while (num_cycles > 0) {
ret = write_sock(buf, strlen(buf)); ret = write_sock(buf, strlen(buf));
if (ret != ERROR_OK) { if (ret != ERROR_OK) {
LOG_ERROR("write_sock() fail, file %s, line %d", LOG_ERROR("write_sock() fail, file %s, line %d",
@ -209,7 +209,7 @@ static int jtag_dpi_runtest(int cycles)
goto out; goto out;
} }
cycles -= num_bits + 6; num_cycles -= num_bits + 6;
} }
out: out:
@ -217,9 +217,9 @@ out:
return ret; return ret;
} }
static int jtag_dpi_stableclocks(int cycles) static int jtag_dpi_stableclocks(unsigned int num_cycles)
{ {
return jtag_dpi_runtest(cycles); return jtag_dpi_runtest(num_cycles);
} }
static int jtag_dpi_execute_queue(struct jtag_command *cmd_queue) static int jtag_dpi_execute_queue(struct jtag_command *cmd_queue)

View File

@ -254,7 +254,7 @@ static int jtag_vpi_path_move(struct pathmove_command *cmd)
memset(trans, 0, DIV_ROUND_UP(cmd->num_states, 8)); memset(trans, 0, DIV_ROUND_UP(cmd->num_states, 8));
for (int i = 0; i < cmd->num_states; i++) { for (unsigned int i = 0; i < cmd->num_states; i++) {
if (tap_state_transition(tap_get_state(), true) == cmd->path[i]) if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
buf_set_u32(trans, i, 1, 1); buf_set_u32(trans, i, 1, 1);
tap_set_state(cmd->path[i]); tap_set_state(cmd->path[i]);
@ -440,7 +440,7 @@ static int jtag_vpi_scan(struct scan_command *cmd)
return ERROR_OK; return ERROR_OK;
} }
static int jtag_vpi_runtest(int cycles, tap_state_t state) static int jtag_vpi_runtest(unsigned int num_cycles, tap_state_t state)
{ {
int retval; int retval;
@ -448,23 +448,21 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
retval = jtag_vpi_queue_tdi(NULL, cycles, NO_TAP_SHIFT); retval = jtag_vpi_queue_tdi(NULL, num_cycles, NO_TAP_SHIFT);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
return jtag_vpi_state_move(state); return jtag_vpi_state_move(state);
} }
static int jtag_vpi_stableclocks(int cycles) static int jtag_vpi_stableclocks(unsigned int num_cycles)
{ {
uint8_t tms_bits[4]; uint8_t tms_bits[4];
int cycles_remain = cycles; unsigned int cycles_remain = num_cycles;
int nb_bits; int nb_bits;
int retval; int retval;
const int CYCLES_ONE_BATCH = sizeof(tms_bits) * 8; const int CYCLES_ONE_BATCH = sizeof(tms_bits) * 8;
assert(cycles >= 0);
/* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */ /* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */
memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits)); memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits));

View File

@ -106,8 +106,8 @@ static int opendous_quit(void);
/* Queue command functions */ /* Queue command functions */
static void opendous_end_state(tap_state_t state); static void opendous_end_state(tap_state_t state);
static void opendous_state_move(void); static void opendous_state_move(void);
static void opendous_path_move(int num_states, tap_state_t *path); static void opendous_path_move(unsigned int num_states, tap_state_t *path);
static void opendous_runtest(int num_cycles); static void opendous_runtest(unsigned int num_cycles);
static void opendous_scan(int ir_scan, enum scan_type type, uint8_t *buffer, static void opendous_scan(int ir_scan, enum scan_type type, uint8_t *buffer,
int scan_size, struct scan_command *command); int scan_size, struct scan_command *command);
static void opendous_reset(int trst, int srst); static void opendous_reset(int trst, int srst);
@ -248,7 +248,7 @@ static int opendous_execute_queue(struct jtag_command *cmd_queue)
while (cmd) { while (cmd) {
switch (cmd->type) { switch (cmd->type) {
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state); cmd->cmd.runtest->end_state);
if (cmd->cmd.runtest->end_state != -1) if (cmd->cmd.runtest->end_state != -1)
@ -265,7 +265,7 @@ static int opendous_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %i", LOG_DEBUG_IO("pathmove: %u states, end in %i",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@ -419,11 +419,9 @@ void opendous_state_move(void)
tap_set_state(tap_get_end_state()); tap_set_state(tap_get_end_state());
} }
void opendous_path_move(int num_states, tap_state_t *path) void opendous_path_move(unsigned int num_states, tap_state_t *path)
{ {
int i; for (unsigned int i = 0; i < num_states; i++) {
for (i = 0; i < num_states; i++) {
if (path[i] == tap_state_transition(tap_get_state(), false)) if (path[i] == tap_state_transition(tap_get_state(), false))
opendous_tap_append_step(0, 0); opendous_tap_append_step(0, 0);
else if (path[i] == tap_state_transition(tap_get_state(), true)) else if (path[i] == tap_state_transition(tap_get_state(), true))
@ -440,10 +438,8 @@ void opendous_path_move(int num_states, tap_state_t *path)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
void opendous_runtest(int num_cycles) void opendous_runtest(unsigned int num_cycles)
{ {
int i;
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
@ -453,7 +449,7 @@ void opendous_runtest(int num_cycles)
} }
/* execute num_cycles */ /* execute num_cycles */
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
opendous_tap_append_step(0, 0); opendous_tap_append_step(0, 0);
/* finish in end_state */ /* finish in end_state */

View File

@ -760,15 +760,17 @@ static void openjtag_execute_runtest(struct jtag_command *cmd)
if (openjtag_variant != OPENJTAG_VARIANT_CY7C65215 || if (openjtag_variant != OPENJTAG_VARIANT_CY7C65215 ||
cmd->cmd.runtest->num_cycles) { cmd->cmd.runtest->num_cycles) {
uint8_t command; uint8_t command;
int cycles = cmd->cmd.runtest->num_cycles; unsigned int num_cycles = cmd->cmd.runtest->num_cycles;
do { do {
const unsigned int num_cycles_cmd = MIN(num_cycles, 16);
command = 7; command = 7;
command |= (((cycles > 16 ? 16 : cycles) - 1) & 0x0F) << 4; command |= ((num_cycles_cmd - 1) & 0x0F) << 4;
openjtag_add_byte(command); openjtag_add_byte(command);
cycles -= 16; num_cycles -= num_cycles_cmd;
} while (cycles > 0); } while (num_cycles > 0);
} }
tap_set_end_state(end_state); tap_set_end_state(end_state);

View File

@ -381,7 +381,7 @@ static int osbdm_quit(void)
static int osbdm_add_pathmove( static int osbdm_add_pathmove(
struct queue *queue, struct queue *queue,
tap_state_t *path, tap_state_t *path,
int num_states) unsigned int num_states)
{ {
assert(num_states <= 32); assert(num_states <= 32);
@ -392,7 +392,7 @@ static int osbdm_add_pathmove(
} }
uint32_t tms = 0; uint32_t tms = 0;
for (int i = 0; i < num_states; i++) { for (unsigned int i = 0; i < num_states; i++) {
if (tap_state_transition(tap_get_state(), 1) == path[i]) { if (tap_state_transition(tap_get_state(), 1) == path[i]) {
tms |= (1 << i); tms |= (1 << i);
} else if (tap_state_transition(tap_get_state(), 0) == path[i]) { } else if (tap_state_transition(tap_get_state(), 0) == path[i]) {
@ -451,7 +451,7 @@ static int osbdm_add_statemove(
static int osbdm_add_stableclocks( static int osbdm_add_stableclocks(
struct queue *queue, struct queue *queue,
int count) unsigned int count)
{ {
if (!tap_is_state_stable(tap_get_state())) { if (!tap_is_state_stable(tap_get_state())) {
LOG_ERROR("BUG: current state (%s) is not stable", LOG_ERROR("BUG: current state (%s) is not stable",
@ -489,7 +489,7 @@ static int osbdm_add_tms(
static int osbdm_add_scan( static int osbdm_add_scan(
struct queue *queue, struct queue *queue,
struct scan_field *fields, struct scan_field *fields,
int num_fields, unsigned int num_fields,
tap_state_t end_state, tap_state_t end_state,
bool ir_scan) bool ir_scan)
{ {
@ -508,7 +508,7 @@ static int osbdm_add_scan(
/* Add scan */ /* Add scan */
tap_set_end_state(end_state); tap_set_end_state(end_state);
for (int idx = 0; idx < num_fields; idx++) { for (unsigned int idx = 0; idx < num_fields; idx++) {
struct sequence *next = queue_add_tail(queue, fields[idx].num_bits); struct sequence *next = queue_add_tail(queue, fields[idx].num_bits);
if (!next) { if (!next) {
LOG_ERROR("Can't allocate bit sequence"); LOG_ERROR("Can't allocate bit sequence");
@ -536,7 +536,7 @@ static int osbdm_add_scan(
static int osbdm_add_runtest( static int osbdm_add_runtest(
struct queue *queue, struct queue *queue,
int num_cycles, unsigned int num_cycles,
tap_state_t end_state) tap_state_t end_state)
{ {
if (osbdm_add_statemove(queue, TAP_IDLE, 0) != ERROR_OK) if (osbdm_add_statemove(queue, TAP_IDLE, 0) != ERROR_OK)

View File

@ -869,7 +869,7 @@ static void rlink_state_move(void)
static void rlink_path_move(struct pathmove_command *cmd) static void rlink_path_move(struct pathmove_command *cmd)
{ {
int num_states = cmd->num_states; unsigned int num_states = cmd->num_states;
int state_count; int state_count;
int tms = 0; int tms = 0;
@ -896,10 +896,8 @@ static void rlink_path_move(struct pathmove_command *cmd)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void rlink_runtest(int num_cycles) static void rlink_runtest(unsigned int num_cycles)
{ {
int i;
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();
/* only do a state_move when we're not already in RTI */ /* only do a state_move when we're not already in RTI */
@ -909,7 +907,7 @@ static void rlink_runtest(int num_cycles)
} }
/* execute num_cycles */ /* execute num_cycles */
for (i = 0; i < num_cycles; i++) for (unsigned int i = 0; i < num_cycles; i++)
tap_state_queue_append(0); tap_state_queue_append(0);
/* finish in end_state */ /* finish in end_state */
@ -1323,7 +1321,7 @@ static int rlink_execute_queue(struct jtag_command *cmd_queue)
rlink_state_move(); rlink_state_move();
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %i", LOG_DEBUG_IO("pathmove: %u states, end in %i",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
rlink_path_move(cmd->cmd.pathmove); rlink_path_move(cmd->cmd.pathmove);

View File

@ -1701,15 +1701,17 @@ static int ulink_queue_reset(struct ulink *device, struct jtag_command *cmd)
*/ */
static int ulink_queue_pathmove(struct ulink *device, struct jtag_command *cmd) static int ulink_queue_pathmove(struct ulink *device, struct jtag_command *cmd)
{ {
int ret, i, num_states, batch_size, state_count; int ret, state_count;
tap_state_t *path; tap_state_t *path;
uint8_t tms_sequence; uint8_t tms_sequence;
num_states = cmd->cmd.pathmove->num_states; unsigned int num_states = cmd->cmd.pathmove->num_states;
path = cmd->cmd.pathmove->path; path = cmd->cmd.pathmove->path;
state_count = 0; state_count = 0;
while (num_states > 0) { while (num_states > 0) {
unsigned int batch_size;
tms_sequence = 0; tms_sequence = 0;
/* Determine batch size */ /* Determine batch size */
@ -1718,7 +1720,7 @@ static int ulink_queue_pathmove(struct ulink *device, struct jtag_command *cmd)
else else
batch_size = num_states; batch_size = num_states;
for (i = 0; i < batch_size; i++) { for (unsigned int i = 0; i < batch_size; i++) {
if (tap_state_transition(tap_get_state(), false) == path[state_count]) { if (tap_state_transition(tap_get_state(), false) == path[state_count]) {
/* Append '0' transition: clear bit 'i' in tms_sequence */ /* Append '0' transition: clear bit 'i' in tms_sequence */
buf_set_u32(&tms_sequence, i, 1, 0x0); buf_set_u32(&tms_sequence, i, 1, 0x0);
@ -1774,14 +1776,13 @@ static int ulink_queue_sleep(struct ulink *device, struct jtag_command *cmd)
static int ulink_queue_stableclocks(struct ulink *device, struct jtag_command *cmd) static int ulink_queue_stableclocks(struct ulink *device, struct jtag_command *cmd)
{ {
int ret; int ret;
unsigned num_cycles;
if (!tap_is_state_stable(tap_get_state())) { if (!tap_is_state_stable(tap_get_state())) {
LOG_ERROR("JTAG_STABLECLOCKS: state not stable"); LOG_ERROR("JTAG_STABLECLOCKS: state not stable");
return ERROR_FAIL; return ERROR_FAIL;
} }
num_cycles = cmd->cmd.stableclocks->num_cycles; unsigned int num_cycles = cmd->cmd.stableclocks->num_cycles;
/* TMS stays either high (Test Logic Reset state) or low (all other states) */ /* TMS stays either high (Test Logic Reset state) or low (all other states) */
if (tap_get_state() == TAP_RESET) if (tap_get_state() == TAP_RESET)

View File

@ -474,11 +474,9 @@ static void ublast_tms(struct tms_command *cmd)
*/ */
static void ublast_path_move(struct pathmove_command *cmd) static void ublast_path_move(struct pathmove_command *cmd)
{ {
int i; LOG_DEBUG_IO("(num_states=%u, last_state=%d)",
LOG_DEBUG_IO("(num_states=%d, last_state=%d)",
cmd->num_states, cmd->path[cmd->num_states - 1]); cmd->num_states, cmd->path[cmd->num_states - 1]);
for (i = 0; i < cmd->num_states; i++) { for (unsigned int i = 0; i < cmd->num_states; i++) {
if (tap_state_transition(tap_get_state(), false) == cmd->path[i]) if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
ublast_clock_tms(0); ublast_clock_tms(0);
if (tap_state_transition(tap_get_state(), true) == cmd->path[i]) if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
@ -675,19 +673,19 @@ static void ublast_queue_tdi(uint8_t *bits, int nb_bits, enum scan_type scan)
ublast_idle_clock(); ublast_idle_clock();
} }
static void ublast_runtest(int cycles, tap_state_t state) static void ublast_runtest(unsigned int num_cycles, tap_state_t state)
{ {
LOG_DEBUG_IO("%s(cycles=%i, end_state=%d)", __func__, cycles, state); LOG_DEBUG_IO("%s(cycles=%u, end_state=%d)", __func__, num_cycles, state);
ublast_state_move(TAP_IDLE, 0); ublast_state_move(TAP_IDLE, 0);
ublast_queue_tdi(NULL, cycles, SCAN_OUT); ublast_queue_tdi(NULL, num_cycles, SCAN_OUT);
ublast_state_move(state, 0); ublast_state_move(state, 0);
} }
static void ublast_stableclocks(int cycles) static void ublast_stableclocks(unsigned int num_cycles)
{ {
LOG_DEBUG_IO("%s(cycles=%i)", __func__, cycles); LOG_DEBUG_IO("%s(cycles=%u)", __func__, num_cycles);
ublast_queue_tdi(NULL, cycles, SCAN_OUT); ublast_queue_tdi(NULL, num_cycles, SCAN_OUT);
} }
/** /**

View File

@ -37,7 +37,7 @@
static void usbprog_end_state(tap_state_t state); static void usbprog_end_state(tap_state_t state);
static void usbprog_state_move(void); static void usbprog_state_move(void);
static void usbprog_path_move(struct pathmove_command *cmd); static void usbprog_path_move(struct pathmove_command *cmd);
static void usbprog_runtest(int num_cycles); static void usbprog_runtest(unsigned int num_cycles);
static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size); static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size);
#define UNKNOWN_COMMAND 0x00 #define UNKNOWN_COMMAND 0x00
@ -101,7 +101,7 @@ static int usbprog_execute_queue(struct jtag_command *cmd_queue)
usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break; break;
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i", LOG_DEBUG_IO("runtest %u cycles, end in %i",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state); cmd->cmd.runtest->end_state);
usbprog_end_state(cmd->cmd.runtest->end_state); usbprog_end_state(cmd->cmd.runtest->end_state);
@ -113,7 +113,7 @@ static int usbprog_execute_queue(struct jtag_command *cmd_queue)
usbprog_state_move(); usbprog_state_move();
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %i", LOG_DEBUG_IO("pathmove: %u states, end in %i",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
usbprog_path_move(cmd->cmd.pathmove); usbprog_path_move(cmd->cmd.pathmove);
@ -189,7 +189,7 @@ static void usbprog_state_move(void)
static void usbprog_path_move(struct pathmove_command *cmd) static void usbprog_path_move(struct pathmove_command *cmd)
{ {
int num_states = cmd->num_states; unsigned int num_states = cmd->num_states;
int state_count; int state_count;
/* There may be queued transitions, and before following a specified /* There may be queued transitions, and before following a specified
@ -222,10 +222,8 @@ static void usbprog_path_move(struct pathmove_command *cmd)
tap_set_end_state(tap_get_state()); tap_set_end_state(tap_get_state());
} }
static void usbprog_runtest(int num_cycles) static void usbprog_runtest(unsigned int num_cycles)
{ {
int i;
/* only do a state_move when we're not already in IDLE */ /* only do a state_move when we're not already in IDLE */
if (tap_get_state() != TAP_IDLE) { if (tap_get_state() != TAP_IDLE) {
usbprog_end_state(TAP_IDLE); usbprog_end_state(TAP_IDLE);
@ -241,7 +239,7 @@ static void usbprog_runtest(int num_cycles)
/* LOG_INFO("NUM CYCLES %i",num_cycles); */ /* LOG_INFO("NUM CYCLES %i",num_cycles); */
} }
for (i = 0; i < num_cycles; i++) { for (unsigned int i = 0; i < num_cycles; i++) {
usbprog_write(1, 0, 0); usbprog_write(1, 0, 0);
usbprog_write(0, 0, 0); usbprog_write(0, 0, 0);
} }

View File

@ -931,11 +931,11 @@ static int vdebug_jtag_tms_seq(const uint8_t *tms, int num, uint8_t f_flush)
static int vdebug_jtag_path_move(struct pathmove_command *cmd, uint8_t f_flush) static int vdebug_jtag_path_move(struct pathmove_command *cmd, uint8_t f_flush)
{ {
uint8_t tms[DIV_ROUND_UP(cmd->num_states, 8)]; uint8_t tms[DIV_ROUND_UP(cmd->num_states, 8)];
LOG_DEBUG_IO("path num states %d", cmd->num_states); LOG_DEBUG_IO("path num states %u", cmd->num_states);
memset(tms, 0, DIV_ROUND_UP(cmd->num_states, 8)); memset(tms, 0, DIV_ROUND_UP(cmd->num_states, 8));
for (uint8_t i = 0; i < cmd->num_states; i++) { for (unsigned int i = 0; i < cmd->num_states; i++) {
if (tap_state_transition(tap_get_state(), true) == cmd->path[i]) if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
buf_set_u32(tms, i, 1, 1); buf_set_u32(tms, i, 1, 1);
tap_set_state(cmd->path[i]); tap_set_state(cmd->path[i]);
@ -971,9 +971,9 @@ static int vdebug_jtag_scan(struct scan_command *cmd, uint8_t f_flush)
uint8_t tms_post = tap_get_tms_path(state, cmd->end_state); uint8_t tms_post = tap_get_tms_path(state, cmd->end_state);
uint8_t num_post = tap_get_tms_path_len(state, cmd->end_state); uint8_t num_post = tap_get_tms_path_len(state, cmd->end_state);
int num_bits = jtag_scan_size(cmd); int num_bits = jtag_scan_size(cmd);
LOG_DEBUG_IO("scan len:%d fields:%d ir/!dr:%d state cur:%x end:%x", LOG_DEBUG_IO("scan len:%d fields:%u ir/!dr:%d state cur:%x end:%x",
num_bits, cmd->num_fields, cmd->ir_scan, cur, cmd->end_state); num_bits, cmd->num_fields, cmd->ir_scan, cur, cmd->end_state);
for (int i = 0; i < cmd->num_fields; i++) { for (unsigned int i = 0; i < cmd->num_fields; i++) {
uint8_t cur_num_pre = i == 0 ? num_pre : 0; uint8_t cur_num_pre = i == 0 ? num_pre : 0;
uint8_t cur_tms_pre = i == 0 ? tms_pre : 0; uint8_t cur_tms_pre = i == 0 ? tms_pre : 0;
uint8_t cur_num_post = i == cmd->num_fields - 1 ? num_post : 0; uint8_t cur_num_post = i == cmd->num_fields - 1 ? num_post : 0;
@ -992,24 +992,24 @@ static int vdebug_jtag_scan(struct scan_command *cmd, uint8_t f_flush)
return rc; return rc;
} }
static int vdebug_jtag_runtest(int cycles, tap_state_t state, uint8_t f_flush) static int vdebug_jtag_runtest(unsigned int num_cycles, tap_state_t state, uint8_t f_flush)
{ {
tap_state_t cur = tap_get_state(); tap_state_t cur = tap_get_state();
uint8_t tms_pre = tap_get_tms_path(cur, state); uint8_t tms_pre = tap_get_tms_path(cur, state);
uint8_t num_pre = tap_get_tms_path_len(cur, state); uint8_t num_pre = tap_get_tms_path_len(cur, state);
LOG_DEBUG_IO("idle len:%d state cur:%x end:%x", cycles, cur, state); LOG_DEBUG_IO("idle len:%u state cur:%x end:%x", num_cycles, cur, state);
int rc = vdebug_jtag_shift_tap(vdc.hsocket, pbuf, num_pre, tms_pre, cycles, NULL, 0, 0, NULL, f_flush); int rc = vdebug_jtag_shift_tap(vdc.hsocket, pbuf, num_pre, tms_pre, num_cycles, NULL, 0, 0, NULL, f_flush);
if (cur != state) if (cur != state)
tap_set_state(state); tap_set_state(state);
return rc; return rc;
} }
static int vdebug_jtag_stableclocks(int num, uint8_t f_flush) static int vdebug_jtag_stableclocks(unsigned int num_cycles, uint8_t f_flush)
{ {
LOG_DEBUG("stab len:%d state cur:%x", num, tap_get_state()); LOG_DEBUG("stab len:%u state cur:%x", num_cycles, tap_get_state());
return vdebug_jtag_shift_tap(vdc.hsocket, pbuf, 0, 0, num, NULL, 0, 0, NULL, f_flush); return vdebug_jtag_shift_tap(vdc.hsocket, pbuf, 0, 0, num_cycles, NULL, 0, 0, NULL, f_flush);
} }
static int vdebug_sleep(int us) static int vdebug_sleep(int us)

View File

@ -43,10 +43,10 @@ static struct pending_scan_result
/* Queue command functions */ /* Queue command functions */
static void vsllink_end_state(tap_state_t state); static void vsllink_end_state(tap_state_t state);
static void vsllink_state_move(void); static void vsllink_state_move(void);
static void vsllink_path_move(int num_states, tap_state_t *path); static void vsllink_path_move(unsigned int num_states, tap_state_t *path);
static void vsllink_tms(int num_bits, const uint8_t *bits); static void vsllink_tms(int num_bits, const uint8_t *bits);
static void vsllink_runtest(int num_cycles); static void vsllink_runtest(unsigned int num_cycles);
static void vsllink_stableclocks(int num_cycles, int tms); static void vsllink_stableclocks(unsigned int num_cycles, int tms);
static void vsllink_scan(bool ir_scan, enum scan_type type, static void vsllink_scan(bool ir_scan, enum scan_type type,
uint8_t *buffer, int scan_size, struct scan_command *command); uint8_t *buffer, int scan_size, struct scan_command *command);
static int vsllink_reset(int trst, int srst); static int vsllink_reset(int trst, int srst);
@ -98,7 +98,7 @@ static int vsllink_execute_queue(struct jtag_command *cmd_queue)
while (cmd) { while (cmd) {
switch (cmd->type) { switch (cmd->type) {
case JTAG_RUNTEST: case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %s", LOG_DEBUG_IO("runtest %u cycles, end in %s",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state)); tap_state_name(cmd->cmd.runtest->end_state));
@ -115,7 +115,7 @@ static int vsllink_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_PATHMOVE: case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %s", LOG_DEBUG_IO("pathmove: %u states, end in %s",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
@ -161,7 +161,7 @@ static int vsllink_execute_queue(struct jtag_command *cmd_queue)
break; break;
case JTAG_STABLECLOCKS: case JTAG_STABLECLOCKS:
LOG_DEBUG_IO("add %d clocks", LOG_DEBUG_IO("add %u clocks",
cmd->cmd.stableclocks->num_cycles); cmd->cmd.stableclocks->num_cycles);
switch (tap_get_state()) { switch (tap_get_state()) {
@ -371,9 +371,9 @@ static void vsllink_state_move(void)
tap_set_state(tap_get_end_state()); tap_set_state(tap_get_end_state());
} }
static void vsllink_path_move(int num_states, tap_state_t *path) static void vsllink_path_move(unsigned int num_states, tap_state_t *path)
{ {
for (int i = 0; i < num_states; i++) { for (unsigned int i = 0; i < num_states; i++) {
if (path[i] == tap_state_transition(tap_get_state(), false)) if (path[i] == tap_state_transition(tap_get_state(), false))
vsllink_tap_append_step(0, 0); vsllink_tap_append_step(0, 0);
else if (path[i] == tap_state_transition(tap_get_state(), true)) else if (path[i] == tap_state_transition(tap_get_state(), true))
@ -397,7 +397,7 @@ static void vsllink_tms(int num_bits, const uint8_t *bits)
vsllink_tap_append_step((bits[i / 8] >> (i % 8)) & 1, 0); vsllink_tap_append_step((bits[i / 8] >> (i % 8)) & 1, 0);
} }
static void vsllink_stableclocks(int num_cycles, int tms) static void vsllink_stableclocks(unsigned int num_cycles, int tms)
{ {
while (num_cycles > 0) { while (num_cycles > 0) {
vsllink_tap_append_step(tms, 0); vsllink_tap_append_step(tms, 0);
@ -405,7 +405,7 @@ static void vsllink_stableclocks(int num_cycles, int tms)
} }
} }
static void vsllink_runtest(int num_cycles) static void vsllink_runtest(unsigned int num_cycles)
{ {
tap_state_t saved_end_state = tap_get_end_state(); tap_state_t saved_end_state = tap_get_end_state();

View File

@ -1669,7 +1669,6 @@ static void xds110_execute_tlr_reset(struct jtag_command *cmd)
static void xds110_execute_pathmove(struct jtag_command *cmd) static void xds110_execute_pathmove(struct jtag_command *cmd)
{ {
uint32_t i;
uint32_t num_states; uint32_t num_states;
uint8_t *path; uint8_t *path;
@ -1685,7 +1684,7 @@ static void xds110_execute_pathmove(struct jtag_command *cmd)
} }
/* Convert requested path states into XDS API states */ /* Convert requested path states into XDS API states */
for (i = 0; i < num_states; i++) for (unsigned int i = 0; i < num_states; i++)
path[i] = (uint8_t)xds_jtag_state[cmd->cmd.pathmove->path[i]]; path[i] = (uint8_t)xds_jtag_state[cmd->cmd.pathmove->path[i]];
if (xds110.firmware >= OCD_FIRMWARE_VERSION) { if (xds110.firmware >= OCD_FIRMWARE_VERSION) {
@ -1704,7 +1703,6 @@ static void xds110_execute_pathmove(struct jtag_command *cmd)
static void xds110_queue_scan(struct jtag_command *cmd) static void xds110_queue_scan(struct jtag_command *cmd)
{ {
int i;
uint32_t offset; uint32_t offset;
uint32_t total_fields; uint32_t total_fields;
uint32_t total_bits; uint32_t total_bits;
@ -1715,7 +1713,7 @@ static void xds110_queue_scan(struct jtag_command *cmd)
/* Calculate the total number of bits to scan */ /* Calculate the total number of bits to scan */
total_bits = 0; total_bits = 0;
total_fields = 0; total_fields = 0;
for (i = 0; i < cmd->cmd.scan->num_fields; i++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) {
total_fields++; total_fields++;
total_bits += (uint32_t)cmd->cmd.scan->fields[i].num_bits; total_bits += (uint32_t)cmd->cmd.scan->fields[i].num_bits;
} }
@ -1756,7 +1754,7 @@ static void xds110_queue_scan(struct jtag_command *cmd)
buffer = &xds110.txn_requests[xds110.txn_request_size]; buffer = &xds110.txn_requests[xds110.txn_request_size];
/* Clear data out buffer to default value of all zeros */ /* Clear data out buffer to default value of all zeros */
memset((void *)buffer, 0x00, total_bytes); memset((void *)buffer, 0x00, total_bytes);
for (i = 0; i < cmd->cmd.scan->num_fields; i++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) {
if (cmd->cmd.scan->fields[i].out_value) { if (cmd->cmd.scan->fields[i].out_value) {
/* Copy over data to scan out into request buffer */ /* Copy over data to scan out into request buffer */
bit_copy(buffer, offset, cmd->cmd.scan->fields[i].out_value, 0, bit_copy(buffer, offset, cmd->cmd.scan->fields[i].out_value, 0,
@ -1775,7 +1773,7 @@ static void xds110_queue_scan(struct jtag_command *cmd)
static void xds110_queue_runtest(struct jtag_command *cmd) static void xds110_queue_runtest(struct jtag_command *cmd)
{ {
uint32_t clocks = (uint32_t)cmd->cmd.stableclocks->num_cycles; uint32_t clocks = cmd->cmd.stableclocks->num_cycles;
uint8_t end_state = (uint8_t)xds_jtag_state[cmd->cmd.runtest->end_state]; uint8_t end_state = (uint8_t)xds_jtag_state[cmd->cmd.runtest->end_state];
/* Check if new request would be too large to fit */ /* Check if new request would be too large to fit */
@ -1794,7 +1792,7 @@ static void xds110_queue_runtest(struct jtag_command *cmd)
static void xds110_queue_stableclocks(struct jtag_command *cmd) static void xds110_queue_stableclocks(struct jtag_command *cmd)
{ {
uint32_t clocks = (uint32_t)cmd->cmd.stableclocks->num_cycles; uint32_t clocks = cmd->cmd.stableclocks->num_cycles;
/* Check if new request would be too large to fit */ /* Check if new request would be too large to fit */
if ((xds110.txn_request_size + 1 + sizeof(clocks) + 1) > MAX_DATA_BLOCK) if ((xds110.txn_request_size + 1 + sizeof(clocks) + 1) > MAX_DATA_BLOCK)

View File

@ -128,7 +128,7 @@ static int xlnx_pcie_xvc_execute_stableclocks(struct jtag_command *cmd)
size_t write; size_t write;
int err; int err;
LOG_DEBUG("stableclocks %i cycles", cmd->cmd.runtest->num_cycles); LOG_DEBUG("stableclocks %u cycles", cmd->cmd.runtest->num_cycles);
while (left) { while (left) {
write = MIN(XLNX_XVC_MAX_BITS, left); write = MIN(XLNX_XVC_MAX_BITS, left);
@ -167,7 +167,7 @@ static int xlnx_pcie_xvc_execute_runtest(struct jtag_command *cmd)
{ {
int err = ERROR_OK; int err = ERROR_OK;
LOG_DEBUG("runtest %i cycles, end in %i", LOG_DEBUG("runtest %u cycles, end in %i",
cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state); cmd->cmd.runtest->end_state);
@ -200,16 +200,15 @@ static int xlnx_pcie_xvc_execute_runtest(struct jtag_command *cmd)
static int xlnx_pcie_xvc_execute_pathmove(struct jtag_command *cmd) static int xlnx_pcie_xvc_execute_pathmove(struct jtag_command *cmd)
{ {
size_t num_states = cmd->cmd.pathmove->num_states; unsigned int num_states = cmd->cmd.pathmove->num_states;
tap_state_t *path = cmd->cmd.pathmove->path; tap_state_t *path = cmd->cmd.pathmove->path;
int err = ERROR_OK; int err = ERROR_OK;
size_t i;
LOG_DEBUG("pathmove: %i states, end in %i", LOG_DEBUG("pathmove: %u states, end in %i",
cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
for (i = 0; i < num_states; i++) { for (unsigned int i = 0; i < num_states; i++) {
if (path[i] == tap_state_transition(tap_get_state(), false)) { if (path[i] == tap_state_transition(tap_get_state(), false)) {
err = xlnx_pcie_xvc_transact(1, 1, 0, NULL); err = xlnx_pcie_xvc_transact(1, 1, 0, NULL);
} else if (path[i] == tap_state_transition(tap_get_state(), true)) { } else if (path[i] == tap_state_transition(tap_get_state(), true)) {

View File

@ -436,7 +436,7 @@ void jtag_add_tlr(void);
* - ERROR_JTAG_TRANSITION_INVALID -- The path includes invalid * - ERROR_JTAG_TRANSITION_INVALID -- The path includes invalid
* state transitions. * state transitions.
*/ */
void jtag_add_pathmove(int num_states, const tap_state_t *path); void jtag_add_pathmove(unsigned int num_states, const tap_state_t *path);
/** /**
* jtag_add_statemove() moves from the current state to @a goal_state. * jtag_add_statemove() moves from the current state to @a goal_state.
@ -459,7 +459,7 @@ int jtag_add_statemove(tap_state_t goal_state);
* via TAP_IDLE. * via TAP_IDLE.
* @param endstate The final state. * @param endstate The final state.
*/ */
void jtag_add_runtest(int num_cycles, tap_state_t endstate); void jtag_add_runtest(unsigned int num_cycles, tap_state_t endstate);
/** /**
* A reset of the TAP state machine can be requested. * A reset of the TAP state machine can be requested.
@ -495,7 +495,7 @@ int jtag_add_tms_seq(unsigned nbits, const uint8_t *seq, enum tap_state t);
* first checks that the state in which the clocks are to be issued is * first checks that the state in which the clocks are to be issued is
* stable, then queues up num_cycles clocks for transmission. * stable, then queues up num_cycles clocks for transmission.
*/ */
void jtag_add_clocks(int num_cycles); void jtag_add_clocks(unsigned int num_cycles);
/** /**
* For software FIFO implementations, the queued commands can be executed * For software FIFO implementations, the queued commands can be executed

View File

@ -51,8 +51,8 @@ int interface_jtag_add_plain_dr_scan(
tap_state_t endstate); tap_state_t endstate);
int interface_jtag_add_tlr(void); int interface_jtag_add_tlr(void);
int interface_jtag_add_pathmove(int num_states, const tap_state_t *path); int interface_jtag_add_pathmove(unsigned int num_states, const tap_state_t *path);
int interface_jtag_add_runtest(int num_cycles, tap_state_t endstate); int interface_jtag_add_runtest(unsigned int num_cycles, tap_state_t endstate);
int interface_add_tms_seq(unsigned num_bits, int interface_add_tms_seq(unsigned num_bits,
const uint8_t *bits, enum tap_state state); const uint8_t *bits, enum tap_state state);
@ -67,7 +67,7 @@ int interface_add_tms_seq(unsigned num_bits,
*/ */
int interface_jtag_add_reset(int trst, int srst); int interface_jtag_add_reset(int trst, int srst);
int interface_jtag_add_sleep(uint32_t us); int interface_jtag_add_sleep(uint32_t us);
int interface_jtag_add_clocks(int num_cycles); int interface_jtag_add_clocks(unsigned int num_cycles);
int interface_jtag_execute_queue(void); int interface_jtag_execute_queue(void);
/** /**

View File

@ -58,11 +58,12 @@ static int esirisc_jtag_get_padding(void)
return padding; return padding;
} }
static int esirisc_jtag_count_bits(int num_fields, struct scan_field *fields) static int esirisc_jtag_count_bits(unsigned int num_fields,
struct scan_field *fields)
{ {
int bit_count = 0; int bit_count = 0;
for (int i = 0; i < num_fields; ++i) for (unsigned int i = 0; i < num_fields; ++i)
bit_count += fields[i].num_bits; bit_count += fields[i].num_bits;
return bit_count; return bit_count;