jtag: Use 'unsigned int' for 'scan_field.num_bits'
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: Idcbbbbbea2705512201eb326c3e6cef110dbc674 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8413 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
9ef59daef0
commit
7d56407ba7
|
@ -210,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[%u].out_value[%i]: 0x%s", i,
|
||||
LOG_DEBUG("fields[%u].out_value[%u]: 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[%u].out_value[%i]: NULL",
|
||||
LOG_DEBUG_IO("fields[%u].out_value[%u]: NULL",
|
||||
i, cmd->fields[i].num_bits);
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
|
|||
* are specified we don't have to examine this field
|
||||
*/
|
||||
if (cmd->fields[i].in_value) {
|
||||
int num_bits = cmd->fields[i].num_bits;
|
||||
const unsigned int num_bits = cmd->fields[i].num_bits;
|
||||
uint8_t *captured = buf_set_buf(buffer, bit_count,
|
||||
malloc(DIV_ROUND_UP(num_bits, 8)), 0, num_bits);
|
||||
|
||||
|
@ -252,7 +252,7 @@ int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
|
|||
? DEBUG_JTAG_IOZ
|
||||
: num_bits);
|
||||
|
||||
LOG_DEBUG("fields[%u].in_value[%i]: 0x%s",
|
||||
LOG_DEBUG("fields[%u].in_value[%u]: 0x%s",
|
||||
i, num_bits, char_buf);
|
||||
free(char_buf);
|
||||
}
|
||||
|
|
|
@ -964,12 +964,12 @@ int default_interface_jtag_execute_queue(void)
|
|||
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);
|
||||
LOG_DEBUG_IO(" %db out: %s", field->num_bits, str);
|
||||
LOG_DEBUG_IO(" %ub out: %s", field->num_bits, str);
|
||||
free(str);
|
||||
}
|
||||
if (field->in_value) {
|
||||
char *str = buf_to_hex_str(field->in_value, field->num_bits);
|
||||
LOG_DEBUG_IO(" %db in: %s", field->num_bits, str);
|
||||
LOG_DEBUG_IO(" %ub in: %s", field->num_bits, str);
|
||||
free(str);
|
||||
}
|
||||
}
|
||||
|
@ -1337,7 +1337,7 @@ static int jtag_validate_ircapture(void)
|
|||
int retval;
|
||||
|
||||
/* when autoprobing, accommodate huge IR lengths */
|
||||
int total_ir_length = 0;
|
||||
unsigned int total_ir_length = 0;
|
||||
for (tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
|
||||
if (tap->ir_length == 0)
|
||||
total_ir_length += JTAG_IRLEN_MAX;
|
||||
|
|
|
@ -19,7 +19,7 @@ struct bitq_interface *bitq_interface; /* low level bit queue interface */
|
|||
struct bitq_state {
|
||||
struct jtag_command *cmd; /* command currently processed */
|
||||
unsigned int field_idx; /* index of field currently being processed */
|
||||
int bit_pos; /* position of bit currently being processed */
|
||||
unsigned int bit_pos; /* position of bit currently being processed */
|
||||
int status; /* processing status */
|
||||
};
|
||||
static struct bitq_state bitq_in_state;
|
||||
|
@ -142,11 +142,10 @@ static void bitq_runtest(unsigned int num_cycles)
|
|||
|
||||
static void bitq_scan_field(struct scan_field *field, int do_pause)
|
||||
{
|
||||
int bit_cnt;
|
||||
int tdo_req;
|
||||
|
||||
const uint8_t *out_ptr;
|
||||
uint8_t out_mask;
|
||||
uint8_t out_mask;
|
||||
|
||||
if (field->in_value)
|
||||
tdo_req = 1;
|
||||
|
@ -155,7 +154,7 @@ static void bitq_scan_field(struct scan_field *field, int do_pause)
|
|||
|
||||
if (!field->out_value) {
|
||||
/* just send zeros and request data from TDO */
|
||||
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
|
||||
for (unsigned int i = 0; i < (field->num_bits - 1); i++)
|
||||
bitq_io(0, 0, tdo_req);
|
||||
|
||||
bitq_io(do_pause, 0, tdo_req);
|
||||
|
@ -163,7 +162,7 @@ static void bitq_scan_field(struct scan_field *field, int do_pause)
|
|||
/* send data, and optionally request TDO */
|
||||
out_mask = 0x01;
|
||||
out_ptr = field->out_value;
|
||||
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--) {
|
||||
for (unsigned int i = 0; i < (field->num_bits - 1); i++) {
|
||||
bitq_io(0, ((*out_ptr) & out_mask) != 0, tdo_req);
|
||||
if (out_mask == 0x80) {
|
||||
out_mask = 0x01;
|
||||
|
|
|
@ -1772,11 +1772,11 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
|||
cmsis_dap_end_state(cmd->cmd.scan->end_state);
|
||||
|
||||
struct scan_field *field = cmd->cmd.scan->fields;
|
||||
unsigned scan_size = 0;
|
||||
unsigned int scan_size = 0;
|
||||
|
||||
for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
|
||||
scan_size += field->num_bits;
|
||||
LOG_DEBUG_IO("%s%s field %u/%u %d bits",
|
||||
LOG_DEBUG_IO("%s%s field %u/%u %u bits",
|
||||
field->in_value ? "in" : "",
|
||||
field->out_value ? "out" : "",
|
||||
i,
|
||||
|
|
|
@ -451,7 +451,7 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
|
|||
|
||||
for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
|
||||
scan_size += field->num_bits;
|
||||
LOG_DEBUG_IO("%s%s field %u/%u %d bits",
|
||||
LOG_DEBUG_IO("%s%s field %u/%u %u bits",
|
||||
field->in_value ? "in" : "",
|
||||
field->out_value ? "out" : "",
|
||||
i,
|
||||
|
|
|
@ -183,7 +183,7 @@ static void jlink_execute_scan(struct jtag_command *cmd)
|
|||
|
||||
for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
|
||||
scan_size += field->num_bits;
|
||||
LOG_DEBUG_IO("%s%s field %u/%u %d bits",
|
||||
LOG_DEBUG_IO("%s%s field %u/%u %u bits",
|
||||
field->in_value ? "in" : "",
|
||||
field->out_value ? "out" : "",
|
||||
i,
|
||||
|
|
|
@ -86,7 +86,7 @@ extern tap_state_t cmd_queue_cur_state;
|
|||
*/
|
||||
struct scan_field {
|
||||
/** The number of bits this field specifies */
|
||||
int num_bits;
|
||||
unsigned int num_bits;
|
||||
/** A pointer to value to be scanned into the device */
|
||||
const uint8_t *out_value;
|
||||
/** A pointer to a 32-bit memory location for data scanned out */
|
||||
|
|
|
@ -211,12 +211,12 @@ void dump_field(int idle, const struct scan_field *field)
|
|||
|
||||
log_printf_lf(LOG_LVL_DEBUG,
|
||||
__FILE__, __LINE__, __PRETTY_FUNCTION__,
|
||||
"%db %s %08x @%02x -> %s %08x @%02x; %di",
|
||||
"%ub %s %08x @%02x -> %s %08x @%02x; %di",
|
||||
field->num_bits, op_string[out_op], out_data, out_address,
|
||||
status_string[in_op], in_data, in_address, idle);
|
||||
} else {
|
||||
log_printf_lf(LOG_LVL_DEBUG,
|
||||
__FILE__, __LINE__, __PRETTY_FUNCTION__, "%db %s %08x @%02x -> ?; %di",
|
||||
__FILE__, __LINE__, __PRETTY_FUNCTION__, "%ub %s %08x @%02x -> ?; %di",
|
||||
field->num_bits, op_string[out_op], out_data, out_address, idle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,7 +412,7 @@ static void dump_field(const struct scan_field *field)
|
|||
|
||||
log_printf_lf(LOG_LVL_DEBUG,
|
||||
__FILE__, __LINE__, "scan",
|
||||
"%db %s %c%c:%08x @%02x -> %s %c%c:%08x @%02x",
|
||||
"%ub %s %c%c:%08x @%02x -> %s %c%c:%08x @%02x",
|
||||
field->num_bits,
|
||||
op_string[out_op], out_interrupt, out_haltnot, out_data,
|
||||
out_address,
|
||||
|
|
|
@ -389,7 +389,7 @@ static void dump_field(int idle, const struct scan_field *field)
|
|||
|
||||
log_printf_lf(LOG_LVL_DEBUG,
|
||||
__FILE__, __LINE__, "scan",
|
||||
"%db %s %08x @%02x -> %s %08x @%02x; %di",
|
||||
"%ub %s %08x @%02x -> %s %08x @%02x; %di",
|
||||
field->num_bits, op_string[out_op], out_data, out_address,
|
||||
status_string[in_op], in_data, in_address, idle);
|
||||
|
||||
|
|
Loading…
Reference in New Issue