Commit e018c7c1 authored by Øyvind Harboe's avatar Øyvind Harboe
Browse files

jtag: retire tap field



jtag_add_dr/ir_scan() now takes the tap as the first
argument, rather than for each of the fields passed
in.

The code never exercised the path where there was
more than one tap being scanned, who knows if it even
worked.

This simplifies the implementation and reduces clutter
in the calling code.

use jtag_add_ir/dr_plain_scan() for more fancy situations.
Signed-off-by: default avatarØyvind Harboe <oyvind.harboe@zylin.com>
parent f7d1be71
......@@ -43,13 +43,12 @@ int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end
{
struct scan_field field;
field.tap = tap;
field.num_bits = tap->ir_length;
field.out_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1);
buf_set_u32(field.out_value, 0, field.num_bits, new_instr);
field.in_value = NULL;
jtag_add_ir_scan(1, &field, end_state);
jtag_add_ir_scan(tap, 1, &field, end_state);
free(field.out_value);
}
......@@ -65,13 +64,12 @@ static uint8_t str9xpec_isc_status(struct jtag_tap *tap)
if (str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE) != ERROR_OK)
return ISC_STATUS_ERROR;
field.tap = tap;
field.num_bits = 8;
field.out_value = NULL;
field.in_value = &status;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
jtag_execute_queue();
LOG_DEBUG("status: 0x%2.2x", status);
......@@ -153,13 +151,12 @@ static int str9xpec_read_config(struct flash_bank *bank)
/* execute ISC_CONFIGURATION command */
str9xpec_set_instr(tap, ISC_CONFIGURATION, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 64;
field.out_value = NULL;
field.in_value = str9xpec_info->options;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
jtag_execute_queue();
status = str9xpec_isc_status(tap);
......@@ -301,21 +298,19 @@ static int str9xpec_blank_check(struct flash_bank *bank, int first, int last)
/* execute ISC_BLANK_CHECK command */
str9xpec_set_instr(tap, ISC_BLANK_CHECK, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 64;
field.out_value = buffer;
field.in_value = NULL;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_sleep(40000);
/* read blank check result */
field.tap = tap;
field.num_bits = 64;
field.out_value = NULL;
field.in_value = buffer;
jtag_add_dr_scan(1, &field, TAP_IRPAUSE);
jtag_add_dr_scan(tap, 1, &field, TAP_IRPAUSE);
jtag_execute_queue();
status = str9xpec_isc_status(tap);
......@@ -407,12 +402,11 @@ static int str9xpec_erase_area(struct flash_bank *bank, int first, int last)
/* execute ISC_ERASE command */
str9xpec_set_instr(tap, ISC_ERASE, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 64;
field.out_value = buffer;
field.in_value = NULL;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
jtag_execute_queue();
jtag_add_sleep(10);
......@@ -468,12 +462,11 @@ static int str9xpec_lock_device(struct flash_bank *bank)
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);
do {
field.tap = tap;
field.num_bits = 8;
field.out_value = NULL;
field.in_value = &status;
jtag_add_dr_scan(1, &field, jtag_get_end_state());
jtag_add_dr_scan(tap, 1, &field, jtag_get_end_state());
jtag_execute_queue();
} while (!(status & ISC_STATUS_BUSY));
......@@ -549,12 +542,11 @@ static int str9xpec_set_address(struct flash_bank *bank, uint8_t sector)
/* set flash controller address */
str9xpec_set_instr(tap, ISC_ADDRESS_SHIFT, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 8;
field.out_value = &sector;
field.in_value = NULL;
jtag_add_dr_scan(1, &field, jtag_get_end_state());
jtag_add_dr_scan(tap, 1, &field, jtag_get_end_state());
return ERROR_OK;
}
......@@ -633,12 +625,11 @@ static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off
{
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 64;
field.out_value = (buffer + bytes_written);
field.in_value = NULL;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
/* small delay before polling */
jtag_add_sleep(50);
......@@ -646,12 +637,11 @@ static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);
do {
field.tap = tap;
field.num_bits = 8;
field.out_value = NULL;
field.in_value = scanbuf;
jtag_add_dr_scan(1, &field, jtag_get_end_state());
jtag_add_dr_scan(tap, 1, &field, jtag_get_end_state());
jtag_execute_queue();
status = buf_get_u32(scanbuf, 0, 8);
......@@ -683,12 +673,11 @@ static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 64;
field.out_value = last_dword;
field.in_value = NULL;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
/* small delay before polling */
jtag_add_sleep(50);
......@@ -696,12 +685,11 @@ static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);
do {
field.tap = tap;
field.num_bits = 8;
field.out_value = NULL;
field.in_value = scanbuf;
jtag_add_dr_scan(1, &field, jtag_get_end_state());
jtag_add_dr_scan(tap, 1, &field, jtag_get_end_state());
jtag_execute_queue();
status = buf_get_u32(scanbuf, 0, 8);
......@@ -750,12 +738,11 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
str9xpec_set_instr(tap, ISC_IDCODE, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 32;
field.out_value = NULL;
field.in_value = buffer;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
jtag_execute_queue();
idcode = buf_get_u32(buffer, 0, 32);
......@@ -867,12 +854,11 @@ static int str9xpec_write_options(struct flash_bank *bank)
/* execute ISC_PROGRAM command */
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);
field.tap = tap;
field.num_bits = 64;
field.out_value = str9xpec_info->options;
field.in_value = NULL;
jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_IDLE));
jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE));
/* small delay before polling */
jtag_add_sleep(50);
......@@ -880,12 +866,11 @@ static int str9xpec_write_options(struct flash_bank *bank)
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);
do {
field.tap = tap;
field.num_bits = 8;
field.out_value = NULL;
field.in_value = &status;
jtag_add_dr_scan(1, &field, jtag_get_end_state());
jtag_add_dr_scan(tap, 1, &field, jtag_get_end_state());
jtag_execute_queue();
} while (!(status & ISC_STATUS_BUSY));
......
......@@ -42,7 +42,7 @@
/// The number of JTAG queue flushes (for profiling and debugging purposes).
static int jtag_flush_queue_count;
static void jtag_add_scan_check(void (*jtag_add_scan)(int in_num_fields, const struct scan_field *in_fields, tap_state_t state),
static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state),
int in_num_fields, struct scan_field *in_fields, tap_state_t state);
/**
......@@ -352,17 +352,17 @@ void jtag_alloc_in_value32(struct scan_field *field)
interface_jtag_alloc_in_value32(field);
}
void jtag_add_ir_scan_noverify(int in_count, const struct scan_field *in_fields,
void jtag_add_ir_scan_noverify(struct jtag_tap *active, int in_count, const struct scan_field *in_fields,
tap_state_t state)
{
jtag_prelude(state);
int retval = interface_jtag_add_ir_scan(in_count, in_fields, state);
int retval = interface_jtag_add_ir_scan(active, in_count, in_fields, state);
jtag_set_error(retval);
}
void jtag_add_ir_scan(int in_num_fields, struct scan_field *in_fields, tap_state_t state)
void jtag_add_ir_scan(struct jtag_tap *active, int in_num_fields, struct scan_field *in_fields, tap_state_t state)
{
assert(state != TAP_RESET);
......@@ -375,13 +375,13 @@ void jtag_add_ir_scan(int in_num_fields, struct scan_field *in_fields, tap_state
/* if we are to run a verification of the ir scan, we need to get the input back.
* We may have to allocate space if the caller didn't ask for the input back.
*/
in_fields[j].check_value = in_fields[j].tap->expected;
in_fields[j].check_mask = in_fields[j].tap->expected_mask;
in_fields[j].check_value = active->expected;
in_fields[j].check_mask = active->expected_mask;
}
jtag_add_scan_check(jtag_add_ir_scan_noverify, in_num_fields, in_fields, state);
jtag_add_scan_check(active, jtag_add_ir_scan_noverify, in_num_fields, in_fields, state);
} else
{
jtag_add_ir_scan_noverify(in_num_fields, in_fields, state);
jtag_add_ir_scan_noverify(active, in_num_fields, in_fields, state);
}
}
......@@ -405,7 +405,7 @@ static int jtag_check_value_mask_callback(jtag_callback_data_t data0, jtag_callb
return jtag_check_value_inner((uint8_t *)data0, (uint8_t *)data1, (uint8_t *)data2, (int)data3);
}
static void jtag_add_scan_check(void (*jtag_add_scan)(int in_num_fields, const struct scan_field *in_fields, tap_state_t state),
static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state),
int in_num_fields, struct scan_field *in_fields, tap_state_t state)
{
for (int i = 0; i < in_num_fields; i++)
......@@ -419,7 +419,7 @@ static void jtag_add_scan_check(void (*jtag_add_scan)(int in_num_fields, const s
field->modified = 1;
}
jtag_add_scan(in_num_fields, in_fields, state);
jtag_add_scan(active, in_num_fields, in_fields, state);
for (int i = 0; i < in_num_fields; i++)
{
......@@ -442,19 +442,19 @@ static void jtag_add_scan_check(void (*jtag_add_scan)(int in_num_fields, const s
}
}
void jtag_add_dr_scan_check(int in_num_fields, struct scan_field *in_fields, tap_state_t state)
void jtag_add_dr_scan_check(struct jtag_tap *active, int in_num_fields, struct scan_field *in_fields, tap_state_t state)
{
if (jtag_verify)
{
jtag_add_scan_check(jtag_add_dr_scan, in_num_fields, in_fields, state);
jtag_add_scan_check(active, jtag_add_dr_scan, in_num_fields, in_fields, state);
} else
{
jtag_add_dr_scan(in_num_fields, in_fields, state);
jtag_add_dr_scan(active, in_num_fields, in_fields, state);
}
}
void jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fields,
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields,
tap_state_t state)
{
assert(state != TAP_RESET);
......@@ -462,7 +462,7 @@ void jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fields,
jtag_prelude(state);
int retval;
retval = interface_jtag_add_dr_scan(in_num_fields, in_fields, state);
retval = interface_jtag_add_dr_scan(active, in_num_fields, in_fields, state);
jtag_set_error(retval);
}
......@@ -894,7 +894,6 @@ void jtag_sleep(uint32_t us)
static int jtag_examine_chain_execute(uint8_t *idcode_buffer, unsigned num_idcode)
{
struct scan_field field = {
.tap = NULL,
.num_bits = num_idcode * 32,
.out_value = idcode_buffer,
.in_value = idcode_buffer,
......@@ -1201,7 +1200,6 @@ static int jtag_validate_ircapture(void)
/* after this scan, all TAPs will capture BYPASS instructions */
buf_set_ones(ir_test, total_ir_length);
field.tap = NULL;
field.num_bits = total_ir_length;
field.out_value = ir_test;
field.in_value = ir_test;
......
......@@ -64,7 +64,6 @@ static void jtag_callback_queue_reset(void)
*/
static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct scan_field * src)
{
dst->tap = src->tap;
dst->num_bits = src->num_bits;
dst->out_value = buf_cpy(src->out_value, cmd_queue_alloc(DIV_ROUND_UP(src->num_bits, 8)), src->num_bits);
dst->in_value = src->in_value;
......@@ -75,7 +74,7 @@ static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct sca
* see jtag_add_ir_scan()
*
*/
int interface_jtag_add_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
int interface_jtag_add_ir_scan(struct jtag_tap* active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
{
size_t num_taps = jtag_tap_count_enabled();
......@@ -102,33 +101,19 @@ int interface_jtag_add_ir_scan(int in_num_fields, const struct scan_field *in_fi
{
/* search the input field list for fields for the current TAP */
bool found = false;
for (int j = 0; j < in_num_fields; j++)
if (tap == active)
{
if (tap != in_fields[j].tap)
continue;
/* if TAP is listed in input fields, copy the value */
found = true;
tap->bypass = 0;
assert(in_fields[j].num_bits == tap->ir_length); /* input fields must have the same length as the TAP's IR */
cmd_queue_scan_field_clone(field, in_fields + j);
break;
}
if (!found)
for (int j = 0; j < in_num_fields; j++)
cmd_queue_scan_field_clone(field, in_fields + j);
} else
{
/* if a TAP isn't listed in input fields, set it to BYPASS */
tap->bypass = 1;
field->tap = tap;
field->num_bits = tap->ir_length;
field->out_value = buf_set_ones(cmd_queue_alloc(DIV_ROUND_UP(tap->ir_length, 8)), tap->ir_length);
field->in_value = NULL; /* do not collect input for tap's in bypass */
......@@ -178,7 +163,7 @@ int interface_jtag_add_plain_ir_scan(int in_num_fields, const struct scan_field
* see jtag_add_dr_scan()
*
*/
int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
int interface_jtag_add_dr_scan(struct jtag_tap* active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
{
/* count devices in bypass */
......@@ -215,6 +200,7 @@ int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fi
if (!tap->bypass)
{
assert(active == tap);
#ifndef NDEBUG
/* remember initial position for assert() */
struct scan_field *start_field = field;
......@@ -222,9 +208,6 @@ int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fi
for (int j = 0; j < in_num_fields; j++)
{
if (tap != in_fields[j].tap)
continue;
cmd_queue_scan_field_clone(field, in_fields + j);
field++;
......@@ -236,7 +219,6 @@ int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fi
/* if a TAP is bypassed, generated a dummy bit*/
else
{
field->tap = tap;
field->num_bits = 1;
field->out_value = NULL;
field->in_value = NULL;
......@@ -320,7 +302,6 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
size_t scan_size = num_bits[j];
buf_set_u32(out_value, 0, scan_size, value[j]);
field->tap = tap;
field->num_bits = scan_size;
field->out_value = buf_cpy(out_value, cmd_queue_alloc(DIV_ROUND_UP(scan_size, 8)), scan_size);
field->in_value = NULL;
......@@ -333,7 +314,6 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
else
{
field->tap = tap;
field->num_bits = 1;
field->out_value = NULL;
field->in_value = NULL;
......
......@@ -109,9 +109,6 @@ extern tap_state_t cmd_queue_cur_state;
* The allocated, modified, and intmp fields are internal work space.
*/
struct scan_field {
/// A pointer to the tap structure to which this field refers.
struct jtag_tap* tap;
/// The number of bits this field specifies (up to 32)
int num_bits;
/// A pointer to value to be scanned into the device
......@@ -353,13 +350,13 @@ int jtag_init_inner(struct command_context *cmd_ctx);
* subsequent DR SCANs.
*
*/
void jtag_add_ir_scan(int num_fields,
void jtag_add_ir_scan(struct jtag_tap* tap, int num_fields,
struct scan_field* fields, tap_state_t endstate);
/**
* The same as jtag_add_ir_scan except no verification is performed out
* the output values.
*/
void jtag_add_ir_scan_noverify(int num_fields,
void jtag_add_ir_scan_noverify(struct jtag_tap* tap, int num_fields,
const struct scan_field *fields, tap_state_t state);
/**
* Duplicate the scan fields passed into the function into an IR SCAN
......@@ -387,10 +384,10 @@ void jtag_alloc_in_value32(struct scan_field *field);
* specified there. For bypassed TAPs, the function generates a dummy
* 1-bit field. The bypass status of TAPs is set by jtag_add_ir_scan().
*/
void jtag_add_dr_scan(int num_fields,
void jtag_add_dr_scan(struct jtag_tap* tap, int num_fields,
const struct scan_field* fields, tap_state_t endstate);
/// A version of jtag_add_dr_scan() that uses the check_value/mask fields
void jtag_add_dr_scan_check(int num_fields,
void jtag_add_dr_scan_check(struct jtag_tap* tap, int num_fields,
struct scan_field* fields, tap_state_t endstate);
/**
* Duplicate the scan fields passed into the function into a DR SCAN
......
......@@ -49,14 +49,14 @@
// and it may provide additional declarations that must be defined.
#include <jtag/minidriver_imp.h>
int interface_jtag_add_ir_scan(
int interface_jtag_add_ir_scan(struct jtag_tap* active,
int num_fields, const struct scan_field* fields,
tap_state_t endstate);
int interface_jtag_add_plain_ir_scan(
int num_fields, const struct scan_field* fields,
tap_state_t endstate);
int interface_jtag_add_dr_scan(
int interface_jtag_add_dr_scan(struct jtag_tap* active,
int num_fields, const struct scan_field* fields,
tap_state_t endstate);
int interface_jtag_add_plain_dr_scan(
......
......@@ -46,7 +46,7 @@ int interface_jtag_execute_queue(void)
return ERROR_OK;
}
int interface_jtag_add_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
int interface_jtag_add_ir_scan(struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state)
{
/* synchronously do the operation here */
......@@ -61,7 +61,7 @@ int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fi
return ERROR_OK;
}
int interface_jtag_add_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
int interface_jtag_add_dr_scan(struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state)
{
/* synchronously do the operation here */
......
......@@ -175,7 +175,6 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
Jim_GetLong(interp, args[i], &bits);
str = Jim_GetString(args[i + 1], &len);
fields[field_count].tap = tap;
fields[field_count].num_bits = bits;
fields[field_count].out_value = malloc(DIV_ROUND_UP(bits, 8));
str_to_buf(str, len, fields[field_count].out_value, bits, 0);
......@@ -183,7 +182,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
field_count++;
}
jtag_add_dr_scan(num_fields, fields, endstate);
jtag_add_dr_scan(tap, num_fields, fields, endstate);
retval = jtag_execute_queue();
if (retval != ERROR_OK)
......@@ -1462,7 +1461,7 @@ COMMAND_HANDLER(handle_irscan_command)
{
int i;
struct scan_field *fields;
struct jtag_tap *tap;
struct jtag_tap *tap = NULL;
tap_state_t endstate;
if ((CMD_ARGC < 2) || (CMD_ARGC % 2))
......@@ -1510,7 +1509,6 @@ COMMAND_HANDLER(handle_irscan_command)
return ERROR_FAIL;
}
int field_size = tap->ir_length;
fields[i].tap = tap;
fields[i].num_bits = field_size;
fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8));
......@@ -1523,7 +1521,7 @@ COMMAND_HANDLER(handle_irscan_command)
}
/* did we have an endstate? */
jtag_add_ir_scan(num_fields, fields, endstate);
jtag_add_ir_scan(tap, num_fields, fields, endstate);
retval = jtag_execute_queue();
......
......@@ -574,38 +574,28 @@ static __inline void scanFields(int num_fields, const struct scan_field *fields,
}
}
int interface_jtag_add_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
int interface_jtag_add_ir_scan(struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state)
{
int j;
int scan_size = 0;
struct jtag_tap *tap, *nextTap;
assert(num_fields == 1);
for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap = nextTap)
{
nextTap = jtag_tap_next_enabled(tap);
int pause = (nextTap==NULL);
int found = 0;
bool pause = (nextTap==NULL);
scan_size = tap->ir_length;
/* search the list */
for (j = 0; j < num_fields; j++)
if (tap == active)
{
if (tap == fields[j].tap)
{
found = 1;
scanFields(1, fields + j, TAP_IRSHIFT, pause);
/* update device information */
buf_cpy(fields[j].out_value, tap->cur_instr, scan_size);
scanFields(num_fields, fields, TAP_IRSHIFT, pause);
/* update device information */
buf_cpy(fields[0].out_value, tap->cur_instr, scan_size);
tap->bypass = 0;
break;
}
}
if (!found)
tap->bypass = 0;
} else
{
/* if a device isn't listed, set it to BYPASS */
assert(scan_size <= 32);
......@@ -631,46 +621,26 @@ int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fi
return ERROR_OK;
}
int interface_jtag_add_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
int interface_jtag_add_dr_scan(struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state)
{
int j;
struct jtag_tap *tap, *nextTap;
for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap = nextTap)
{
nextTap = jtag_tap_next_enabled(tap);
int found = 0;
int pause = (nextTap==NULL);
bool pause = (nextTap==NULL);
for (j = 0; j < num_fields; j++)
/* Find a range of fields to write to this tap */
if (tap == active)
{
/* Find a range of fields to write to this tap */
if (tap == fields[j].tap)
{
found = 1;
int i;
for (i = j + 1; i < num_fields; i++)
{
if (tap != fields[j].tap)
{
break;