mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
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:
committed by
Antonio Borneo
parent
42450345dd
commit
0847a4d7fb
@@ -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)
|
||||
{
|
||||
int i;
|
||||
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)
|
||||
type |= SCAN_IN;
|
||||
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 bit_count = 0;
|
||||
int i;
|
||||
|
||||
/* 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;
|
||||
|
||||
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 bit_count = 0;
|
||||
int i;
|
||||
|
||||
bit_count = jtag_scan_size(cmd);
|
||||
*buffer = calloc(1, DIV_ROUND_UP(bit_count, 8));
|
||||
|
||||
bit_count = 0;
|
||||
|
||||
LOG_DEBUG_IO("%s num_fields: %i",
|
||||
LOG_DEBUG_IO("%s num_fields: %u",
|
||||
cmd->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
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 (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) {
|
||||
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
|
||||
: 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);
|
||||
free(char_buf);
|
||||
}
|
||||
buf_set_buf(cmd->fields[i].out_value, 0, *buffer,
|
||||
bit_count, cmd->fields[i].num_bits);
|
||||
} 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);
|
||||
}
|
||||
|
||||
@@ -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 i;
|
||||
int bit_count = 0;
|
||||
int retval;
|
||||
|
||||
/* we return ERROR_OK, unless a check fails, or a handler reports a problem */
|
||||
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
|
||||
* 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
|
||||
: 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);
|
||||
free(char_buf);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ struct scan_command {
|
||||
/** instruction/not data scan */
|
||||
bool ir_scan;
|
||||
/** number of fields in *fields array */
|
||||
int num_fields;
|
||||
unsigned int num_fields;
|
||||
/** pointer to an array of data scan fields */
|
||||
struct scan_field *fields;
|
||||
/** state in which JTAG commands should finish */
|
||||
@@ -50,14 +50,14 @@ struct statemove_command {
|
||||
|
||||
struct pathmove_command {
|
||||
/** number of states in *path */
|
||||
int num_states;
|
||||
unsigned int num_states;
|
||||
/** states that have to be passed */
|
||||
tap_state_t *path;
|
||||
};
|
||||
|
||||
struct runtest_command {
|
||||
/** number of cycles to spend in Run-Test/Idle state */
|
||||
int num_cycles;
|
||||
unsigned int num_cycles;
|
||||
/** state in which JTAG commands should finish */
|
||||
tap_state_t end_state;
|
||||
};
|
||||
@@ -65,7 +65,7 @@ struct runtest_command {
|
||||
|
||||
struct stableclocks_command {
|
||||
/** 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 {
|
||||
/** 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]. */
|
||||
const uint8_t *bits;
|
||||
};
|
||||
|
||||
@@ -514,7 +514,7 @@ int jtag_add_tms_seq(unsigned nbits, const uint8_t *seq, enum tap_state state)
|
||||
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;
|
||||
|
||||
@@ -525,7 +525,7 @@ void jtag_add_pathmove(int num_states, const tap_state_t *path)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_states; i++) {
|
||||
for (unsigned int i = 0; i < num_states; i++) {
|
||||
if (path[i] == TAP_RESET) {
|
||||
LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
|
||||
jtag_set_error(ERROR_JTAG_STATE_INVALID);
|
||||
@@ -589,14 +589,14 @@ int jtag_add_statemove(tap_state_t goal_state)
|
||||
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_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)) {
|
||||
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",
|
||||
cmd->cmd.scan->ir_scan ? "IR" : "DR",
|
||||
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;
|
||||
if (field->out_value) {
|
||||
char *str = buf_to_hex_str(field->out_value, field->num_bits);
|
||||
|
||||
@@ -203,7 +203,7 @@ static void amt_jtagaccel_state_move(void)
|
||||
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;
|
||||
uint8_t aw_scan_tms_5;
|
||||
|
||||
@@ -1836,15 +1836,17 @@ static int angie_reset(int trst, int srst)
|
||||
*/
|
||||
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;
|
||||
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;
|
||||
state_count = 0;
|
||||
|
||||
while (num_states > 0) {
|
||||
unsigned int batch_size;
|
||||
|
||||
tms_sequence = 0;
|
||||
|
||||
/* Determine batch size */
|
||||
@@ -1853,7 +1855,7 @@ static int angie_queue_pathmove(struct angie *device, struct jtag_command *cmd)
|
||||
else
|
||||
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]) {
|
||||
/* Append '0' transition: clear bit 'i' in tms_sequence */
|
||||
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)
|
||||
{
|
||||
int ret;
|
||||
unsigned int num_cycles;
|
||||
|
||||
if (!tap_is_state_stable(tap_get_state())) {
|
||||
LOG_ERROR("JTAG_STABLECLOCKS: state not stable");
|
||||
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) */
|
||||
if (tap_get_state() == TAP_RESET)
|
||||
|
||||
@@ -44,8 +44,8 @@ static uint8_t usb_out_buffer[ARMJTAGEW_OUT_BUFFER_SIZE];
|
||||
/* Queue command functions */
|
||||
static void armjtagew_end_state(tap_state_t state);
|
||||
static void armjtagew_state_move(void);
|
||||
static void armjtagew_path_move(int num_states, tap_state_t *path);
|
||||
static void armjtagew_runtest(int num_cycles);
|
||||
static void armjtagew_path_move(unsigned int num_states, tap_state_t *path);
|
||||
static void armjtagew_runtest(unsigned int num_cycles);
|
||||
static void armjtagew_scan(bool ir_scan,
|
||||
enum scan_type type,
|
||||
uint8_t *buffer,
|
||||
@@ -95,7 +95,7 @@ static int armjtagew_execute_queue(struct jtag_command *cmd_queue)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
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->end_state);
|
||||
|
||||
@@ -111,7 +111,7 @@ static int armjtagew_execute_queue(struct jtag_command *cmd_queue)
|
||||
break;
|
||||
|
||||
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->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
|
||||
@@ -279,11 +279,9 @@ static void armjtagew_state_move(void)
|
||||
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 (i = 0; i < num_states; i++) {
|
||||
for (unsigned int i = 0; i < num_states; i++) {
|
||||
/*
|
||||
* 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
|
||||
@@ -305,10 +303,8 @@ static void armjtagew_path_move(int num_states, tap_state_t *path)
|
||||
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();
|
||||
|
||||
/* 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 */
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
for (unsigned int i = 0; i < num_cycles; i++)
|
||||
armjtagew_tap_append_step(0, 0);
|
||||
|
||||
/* finish in end_state */
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
* this function checks the current stable state to decide on the value of TMS
|
||||
* 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);
|
||||
|
||||
@@ -95,7 +95,7 @@ static int bitbang_execute_tms(struct jtag_command *cmd)
|
||||
unsigned num_bits = cmd->cmd.tms->num_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;
|
||||
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)
|
||||
{
|
||||
int num_states = cmd->num_states;
|
||||
unsigned int num_states = cmd->num_states;
|
||||
int state_count;
|
||||
int tms = 0;
|
||||
|
||||
@@ -147,10 +147,8 @@ static int bitbang_path_move(struct pathmove_command *cmd)
|
||||
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();
|
||||
|
||||
/* 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 */
|
||||
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)
|
||||
return ERROR_FAIL;
|
||||
if (bitbang_interface->write(1, 0, 0) != ERROR_OK)
|
||||
@@ -179,13 +177,12 @@ static int bitbang_runtest(int num_cycles)
|
||||
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 i;
|
||||
|
||||
/* 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)
|
||||
return ERROR_FAIL;
|
||||
if (bitbang_interface->write(0, tms, 0) != ERROR_OK)
|
||||
@@ -319,7 +316,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
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,
|
||||
tap_state_name(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;
|
||||
break;
|
||||
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,
|
||||
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
|
||||
if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK)
|
||||
|
||||
@@ -18,7 +18,7 @@ struct bitq_interface *bitq_interface; /* low level bit queue interface */
|
||||
/* state of input queue */
|
||||
struct bitq_state {
|
||||
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 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)
|
||||
{
|
||||
int i;
|
||||
|
||||
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])
|
||||
bitq_io(0, 0, 0);
|
||||
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());
|
||||
}
|
||||
|
||||
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 */
|
||||
if (tap_get_state() != TAP_IDLE)
|
||||
bitq_state_move(TAP_IDLE);
|
||||
|
||||
/* execute num_cycles */
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
for (unsigned int i = 0; i < num_cycles; i++)
|
||||
bitq_io(0, 0, 0);
|
||||
|
||||
/* 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)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (cmd->ir_scan)
|
||||
bitq_state_move(TAP_IRSHIFT);
|
||||
else
|
||||
bitq_state_move(TAP_DRSHIFT);
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < cmd->num_fields - 1; i++)
|
||||
bitq_scan_field(&cmd->fields[i], 0);
|
||||
|
||||
@@ -226,7 +221,7 @@ int bitq_execute_queue(struct jtag_command *cmd_queue)
|
||||
break;
|
||||
|
||||
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_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
@@ -238,7 +233,7 @@ int bitq_execute_queue(struct jtag_command *cmd_queue)
|
||||
break;
|
||||
|
||||
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]);
|
||||
bitq_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
|
||||
@@ -27,11 +27,11 @@ static int buspirate_reset(int trst, int srst);
|
||||
|
||||
static void buspirate_end_state(tap_state_t state);
|
||||
static void buspirate_state_move(void);
|
||||
static void buspirate_path_move(int num_states, tap_state_t *path);
|
||||
static void buspirate_runtest(int num_cycles);
|
||||
static void buspirate_path_move(unsigned int num_states, tap_state_t *path);
|
||||
static void buspirate_runtest(unsigned int num_cycles);
|
||||
static void buspirate_scan(bool ir_scan, enum scan_type type,
|
||||
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_PORT_MODE 0x01
|
||||
@@ -162,7 +162,7 @@ static int buspirate_execute_queue(struct jtag_command *cmd_queue)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
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,
|
||||
tap_state_name(cmd->cmd.runtest
|
||||
->end_state));
|
||||
@@ -180,7 +180,7 @@ static int buspirate_execute_queue(struct jtag_command *cmd_queue)
|
||||
buspirate_state_move();
|
||||
break;
|
||||
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,
|
||||
tap_state_name(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);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
default:
|
||||
@@ -580,11 +580,9 @@ static void buspirate_state_move(void)
|
||||
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 (i = 0; i < num_states; i++) {
|
||||
for (unsigned int i = 0; i < num_states; i++) {
|
||||
if (tap_state_transition(tap_get_state(), false) == path[i]) {
|
||||
buspirate_tap_append(0, 0);
|
||||
} 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());
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
/* 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();
|
||||
}
|
||||
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
for (unsigned int i = 0; i < num_cycles; i++)
|
||||
buspirate_tap_append(0, 0);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1752,7 +1752,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
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");
|
||||
return;
|
||||
}
|
||||
@@ -1774,9 +1774,9 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
struct scan_field *field = cmd->cmd.scan->fields;
|
||||
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;
|
||||
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->out_value ? "out" : "",
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
/* TODO: Perform optimizations? */
|
||||
/* 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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -1901,7 +1901,7 @@ static void cmsis_dap_runtest(int num_cycles)
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state
|
||||
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 */
|
||||
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->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];
|
||||
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
||||
int interface_jtag_add_clocks(int num_cycles)
|
||||
int interface_jtag_add_clocks(unsigned int num_cycles)
|
||||
{
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
@@ -657,7 +657,7 @@ static int syncbb_execute_tms(struct jtag_command *cmd)
|
||||
unsigned num_bits = cmd->cmd.tms->num_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;
|
||||
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)
|
||||
{
|
||||
int num_states = cmd->num_states;
|
||||
unsigned int num_states = cmd->num_states;
|
||||
int state_count;
|
||||
int tms = 0;
|
||||
|
||||
@@ -702,9 +702,8 @@ static void syncbb_path_move(struct pathmove_command *cmd)
|
||||
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();
|
||||
|
||||
@@ -715,7 +714,7 @@ static void syncbb_runtest(int 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(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
|
||||
* 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 i;
|
||||
|
||||
/* 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(0, tms, 0);
|
||||
}
|
||||
@@ -832,7 +830,7 @@ static int syncbb_execute_queue(struct jtag_command *cmd_queue)
|
||||
break;
|
||||
|
||||
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));
|
||||
|
||||
syncbb_end_state(cmd->cmd.runtest->end_state);
|
||||
@@ -854,7 +852,7 @@ static int syncbb_execute_queue(struct jtag_command *cmd_queue)
|
||||
break;
|
||||
|
||||
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]));
|
||||
|
||||
syncbb_path_move(cmd->cmd.pathmove);
|
||||
|
||||
@@ -311,10 +311,9 @@ static void ftdi_end_state(tap_state_t state)
|
||||
|
||||
static void ftdi_execute_runtest(struct jtag_command *cmd)
|
||||
{
|
||||
int i;
|
||||
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,
|
||||
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);
|
||||
|
||||
/* TODO: Reuse ftdi_execute_stableclocks */
|
||||
i = cmd->cmd.runtest->num_cycles;
|
||||
unsigned int i = cmd->cmd.runtest->num_cycles;
|
||||
while (i > 0) {
|
||||
/* there are no state transitions in this code, so omit state tracking */
|
||||
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())
|
||||
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,
|
||||
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)
|
||||
{
|
||||
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! */
|
||||
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)
|
||||
{
|
||||
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(path[num_states-1]));
|
||||
|
||||
@@ -432,7 +431,7 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
|
||||
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");
|
||||
return;
|
||||
}
|
||||
@@ -450,9 +449,9 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
|
||||
struct scan_field *field = cmd->cmd.scan->fields;
|
||||
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;
|
||||
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->out_value ? "out" : "",
|
||||
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
|
||||
* 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. */
|
||||
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;
|
||||
}
|
||||
|
||||
LOG_DEBUG_IO("clocks %i while in %s",
|
||||
LOG_DEBUG_IO("clocks %u while in %s",
|
||||
cmd->cmd.stableclocks->num_cycles,
|
||||
tap_state_name(tap_get_state()));
|
||||
}
|
||||
|
||||
@@ -185,10 +185,9 @@ static void gw16012_path_move(struct pathmove_command *cmd)
|
||||
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();
|
||||
int i;
|
||||
|
||||
/* only do a state_move when we're not already in IDLE */
|
||||
if (tap_get_state() != TAP_IDLE) {
|
||||
@@ -196,7 +195,7 @@ static void gw16012_runtest(int num_cycles)
|
||||
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_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);
|
||||
break;
|
||||
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);
|
||||
gw16012_end_state(cmd->cmd.runtest->end_state);
|
||||
gw16012_runtest(cmd->cmd.runtest->num_cycles);
|
||||
|
||||
@@ -80,9 +80,9 @@ static struct device_config tmp_config;
|
||||
/* Queue command functions */
|
||||
static void jlink_end_state(tap_state_t state);
|
||||
static void jlink_state_move(void);
|
||||
static void jlink_path_move(int num_states, tap_state_t *path);
|
||||
static void jlink_stableclocks(int num_cycles);
|
||||
static void jlink_runtest(int num_cycles);
|
||||
static void jlink_path_move(unsigned int num_states, tap_state_t *path);
|
||||
static void jlink_stableclocks(unsigned int num_cycles);
|
||||
static void jlink_runtest(unsigned int num_cycles);
|
||||
static void jlink_reset(int trst, int srst);
|
||||
static int jlink_reset_safe(int trst, int srst);
|
||||
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)
|
||||
{
|
||||
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->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");
|
||||
}
|
||||
|
||||
if (cmd->cmd.scan->num_fields == 0) {
|
||||
if (!cmd->cmd.scan->num_fields) {
|
||||
LOG_DEBUG("empty scan, doing nothing");
|
||||
return;
|
||||
}
|
||||
@@ -181,9 +181,9 @@ static void jlink_execute_scan(struct jtag_command *cmd)
|
||||
struct scan_field *field = cmd->cmd.scan->fields;
|
||||
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;
|
||||
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->out_value ? "out" : "",
|
||||
i,
|
||||
@@ -885,12 +885,11 @@ static void jlink_state_move(void)
|
||||
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;
|
||||
|
||||
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))
|
||||
jlink_clock_data(NULL, 0, NULL, 0, NULL, 0, 1);
|
||||
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());
|
||||
}
|
||||
|
||||
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;
|
||||
/* 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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int jtag_dpi_runtest(int cycles)
|
||||
static int jtag_dpi_runtest(unsigned int num_cycles)
|
||||
{
|
||||
char buf[20];
|
||||
uint8_t *data_buf = last_ir_buf, *read_scan;
|
||||
@@ -189,7 +189,7 @@ static int jtag_dpi_runtest(int cycles)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "ib %d\n", num_bits);
|
||||
while (cycles > 0) {
|
||||
while (num_cycles > 0) {
|
||||
ret = write_sock(buf, strlen(buf));
|
||||
if (ret != ERROR_OK) {
|
||||
LOG_ERROR("write_sock() fail, file %s, line %d",
|
||||
@@ -209,7 +209,7 @@ static int jtag_dpi_runtest(int cycles)
|
||||
goto out;
|
||||
}
|
||||
|
||||
cycles -= num_bits + 6;
|
||||
num_cycles -= num_bits + 6;
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -217,9 +217,9 @@ out:
|
||||
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)
|
||||
|
||||
@@ -254,7 +254,7 @@ static int jtag_vpi_path_move(struct pathmove_command *cmd)
|
||||
|
||||
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])
|
||||
buf_set_u32(trans, i, 1, 1);
|
||||
tap_set_state(cmd->path[i]);
|
||||
@@ -440,7 +440,7 @@ static int jtag_vpi_scan(struct scan_command *cmd)
|
||||
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;
|
||||
|
||||
@@ -448,23 +448,21 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
|
||||
if (retval != ERROR_OK)
|
||||
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)
|
||||
return retval;
|
||||
|
||||
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];
|
||||
int cycles_remain = cycles;
|
||||
unsigned int cycles_remain = num_cycles;
|
||||
int nb_bits;
|
||||
int retval;
|
||||
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 */
|
||||
memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits));
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ static int opendous_quit(void);
|
||||
/* Queue command functions */
|
||||
static void opendous_end_state(tap_state_t state);
|
||||
static void opendous_state_move(void);
|
||||
static void opendous_path_move(int num_states, tap_state_t *path);
|
||||
static void opendous_runtest(int num_cycles);
|
||||
static void opendous_path_move(unsigned int num_states, tap_state_t *path);
|
||||
static void opendous_runtest(unsigned int num_cycles);
|
||||
static void opendous_scan(int ir_scan, enum scan_type type, uint8_t *buffer,
|
||||
int scan_size, struct scan_command *command);
|
||||
static void opendous_reset(int trst, int srst);
|
||||
@@ -248,7 +248,7 @@ static int opendous_execute_queue(struct jtag_command *cmd_queue)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
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);
|
||||
|
||||
if (cmd->cmd.runtest->end_state != -1)
|
||||
@@ -265,7 +265,7 @@ static int opendous_execute_queue(struct jtag_command *cmd_queue)
|
||||
break;
|
||||
|
||||
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->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
|
||||
@@ -419,11 +419,9 @@ void opendous_state_move(void)
|
||||
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 (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))
|
||||
opendous_tap_append_step(0, 0);
|
||||
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());
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
/* 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 */
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
for (unsigned int i = 0; i < num_cycles; i++)
|
||||
opendous_tap_append_step(0, 0);
|
||||
|
||||
/* finish in end_state */
|
||||
|
||||
@@ -760,15 +760,17 @@ static void openjtag_execute_runtest(struct jtag_command *cmd)
|
||||
if (openjtag_variant != OPENJTAG_VARIANT_CY7C65215 ||
|
||||
cmd->cmd.runtest->num_cycles) {
|
||||
uint8_t command;
|
||||
int cycles = cmd->cmd.runtest->num_cycles;
|
||||
unsigned int num_cycles = cmd->cmd.runtest->num_cycles;
|
||||
|
||||
do {
|
||||
const unsigned int num_cycles_cmd = MIN(num_cycles, 16);
|
||||
|
||||
command = 7;
|
||||
command |= (((cycles > 16 ? 16 : cycles) - 1) & 0x0F) << 4;
|
||||
command |= ((num_cycles_cmd - 1) & 0x0F) << 4;
|
||||
|
||||
openjtag_add_byte(command);
|
||||
cycles -= 16;
|
||||
} while (cycles > 0);
|
||||
num_cycles -= num_cycles_cmd;
|
||||
} while (num_cycles > 0);
|
||||
}
|
||||
|
||||
tap_set_end_state(end_state);
|
||||
|
||||
@@ -381,7 +381,7 @@ static int osbdm_quit(void)
|
||||
static int osbdm_add_pathmove(
|
||||
struct queue *queue,
|
||||
tap_state_t *path,
|
||||
int num_states)
|
||||
unsigned int num_states)
|
||||
{
|
||||
assert(num_states <= 32);
|
||||
|
||||
@@ -392,7 +392,7 @@ static int osbdm_add_pathmove(
|
||||
}
|
||||
|
||||
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]) {
|
||||
tms |= (1 << 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(
|
||||
struct queue *queue,
|
||||
int count)
|
||||
unsigned int count)
|
||||
{
|
||||
if (!tap_is_state_stable(tap_get_state())) {
|
||||
LOG_ERROR("BUG: current state (%s) is not stable",
|
||||
@@ -489,7 +489,7 @@ static int osbdm_add_tms(
|
||||
static int osbdm_add_scan(
|
||||
struct queue *queue,
|
||||
struct scan_field *fields,
|
||||
int num_fields,
|
||||
unsigned int num_fields,
|
||||
tap_state_t end_state,
|
||||
bool ir_scan)
|
||||
{
|
||||
@@ -508,7 +508,7 @@ static int osbdm_add_scan(
|
||||
|
||||
/* Add scan */
|
||||
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);
|
||||
if (!next) {
|
||||
LOG_ERROR("Can't allocate bit sequence");
|
||||
@@ -536,7 +536,7 @@ static int osbdm_add_scan(
|
||||
|
||||
static int osbdm_add_runtest(
|
||||
struct queue *queue,
|
||||
int num_cycles,
|
||||
unsigned int num_cycles,
|
||||
tap_state_t end_state)
|
||||
{
|
||||
if (osbdm_add_statemove(queue, TAP_IDLE, 0) != ERROR_OK)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user