diff options
author | Øyvind Harboe <oyvind.harboe@zylin.com> | 2010-03-01 20:00:59 +0100 |
---|---|---|
committer | Øyvind Harboe <oyvind.harboe@zylin.com> | 2010-03-08 08:12:25 +0100 |
commit | e018c7c1d29e8dabb9b4a90bb9eb3574eb1668bb (patch) | |
tree | e89d52d68c83186556ef6ae3ad6c82032fe26642 | |
parent | f7d1be714b91fcc12e56c8fa78c702e75a733019 (diff) |
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: Øyvind Harboe <oyvind.harboe@zylin.com>
-rw-r--r-- | src/flash/nor/str9xpec.c | 45 | ||||
-rw-r--r-- | src/jtag/core.c | 32 | ||||
-rw-r--r-- | src/jtag/drivers/driver.c | 34 | ||||
-rw-r--r-- | src/jtag/jtag.h | 11 | ||||
-rw-r--r-- | src/jtag/minidriver.h | 4 | ||||
-rw-r--r-- | src/jtag/minidummy/minidummy.c | 4 | ||||
-rw-r--r-- | src/jtag/tcl.c | 8 | ||||
-rw-r--r-- | src/jtag/zy1000/zy1000.c | 72 | ||||
-rw-r--r-- | src/pld/virtex2.c | 12 | ||||
-rw-r--r-- | src/svf/svf.c | 4 | ||||
-rw-r--r-- | src/target/arm11.c | 8 | ||||
-rw-r--r-- | src/target/arm11_dbgtap.c | 36 | ||||
-rw-r--r-- | src/target/arm11_dbgtap.h | 2 | ||||
-rw-r--r-- | src/target/arm720t.c | 6 | ||||
-rw-r--r-- | src/target/arm7tdmi.c | 14 | ||||
-rw-r--r-- | src/target/arm920t.c | 20 | ||||
-rw-r--r-- | src/target/arm926ejs.c | 17 | ||||
-rw-r--r-- | src/target/arm966e.c | 12 | ||||
-rw-r--r-- | src/target/arm9tdmi.c | 24 | ||||
-rw-r--r-- | src/target/arm_adi_v5.c | 7 | ||||
-rw-r--r-- | src/target/arm_jtag.c | 5 | ||||
-rw-r--r-- | src/target/avrt.c | 2 | ||||
-rw-r--r-- | src/target/dsp563xx.c | 2 | ||||
-rw-r--r-- | src/target/embeddedice.c | 26 | ||||
-rw-r--r-- | src/target/etb.c | 23 | ||||
-rw-r--r-- | src/target/etm.c | 12 | ||||
-rw-r--r-- | src/target/feroceon.c | 5 | ||||
-rw-r--r-- | src/target/mips_ejtag.c | 16 | ||||
-rw-r--r-- | src/target/xscale.c | 42 | ||||
-rw-r--r-- | src/xsvf/xsvf.c | 9 |
30 files changed, 155 insertions, 359 deletions
diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c index 243336a3..3796a4b1 100644 --- a/src/flash/nor/str9xpec.c +++ b/src/flash/nor/str9xpec.c @@ -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 = §or; 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)); diff --git a/src/jtag/core.c b/src/jtag/core.c index d43bd1ce..2e09cb6d 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -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; diff --git a/src/jtag/drivers/driver.c b/src/jtag/drivers/driver.c index ca59239e..673d191e 100644 --- a/src/jtag/drivers/driver.c +++ b/src/jtag/drivers/driver.c @@ -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; diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 7e5dc102..6e21024e 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -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 diff --git a/src/jtag/minidriver.h b/src/jtag/minidriver.h index 810bb0e5..a4172169 100644 --- a/src/jtag/minidriver.h +++ b/src/jtag/minidriver.h @@ -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( diff --git a/src/jtag/minidummy/minidummy.c b/src/jtag/minidummy/minidummy.c index 01cdd2ed..98b449f9 100644 --- a/src/jtag/minidummy/minidummy.c +++ b/src/jtag/minidummy/minidummy.c @@ -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 */ diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index ffb5d276..da01f812 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -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(); diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index c5bc0ffd..0b112589 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -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; - } - } - - scanFields(i - j, fields + j, TAP_DRSHIFT, pause); + assert(!tap->bypass); - j = i; - } - } - - if (!found) + scanFields(num_fields, fields, TAP_DRSHIFT, pause); + } else { /* Shift out a 0 for disabled tap's */ + assert(tap->bypass); shiftValueInner(TAP_DRSHIFT, pause?TAP_DRPAUSE:TAP_DRSHIFT, 1, 0); } - else - { - } } gotoEndState(state); return ERROR_OK; @@ -683,7 +653,6 @@ int interface_jtag_add_plain_dr_scan(int num_fields, const struct scan_field *fi return ERROR_OK; } - int interface_jtag_add_tlr() { setCurrentState(TAP_RESET); @@ -691,8 +660,6 @@ int interface_jtag_add_tlr() } - - int interface_jtag_add_reset(int req_trst, int req_srst) { zy1000_reset(req_trst, req_srst); @@ -737,7 +704,6 @@ static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, state); #endif - return ERROR_OK; } diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index bbf6b667..15685e61 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -35,13 +35,12 @@ static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr) { 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, jtag_set_end_state(TAP_IDLE)); + jtag_add_ir_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE)); free(field.out_value); } @@ -59,7 +58,6 @@ static int virtex2_send_32(struct pld_device *pld_device, values = malloc(num_words * 4); - scan_field.tap = virtex2_info->tap; scan_field.num_bits = num_words * 32; scan_field.out_value = values; scan_field.in_value = NULL; @@ -69,7 +67,7 @@ static int virtex2_send_32(struct pld_device *pld_device, virtex2_set_instr(virtex2_info->tap, 0x5); /* CFG_IN */ - jtag_add_dr_scan(1, &scan_field, jtag_set_end_state(TAP_DRPAUSE)); + jtag_add_dr_scan(virtex2_info->tap, 1, &scan_field, jtag_set_end_state(TAP_DRPAUSE)); free(values); @@ -88,7 +86,6 @@ static int virtex2_receive_32(struct pld_device *pld_device, struct virtex2_pld_device *virtex2_info = pld_device->driver_priv; struct scan_field scan_field; - scan_field.tap = virtex2_info->tap; scan_field.num_bits = 32; scan_field.out_value = NULL; scan_field.in_value = NULL; @@ -99,7 +96,7 @@ static int virtex2_receive_32(struct pld_device *pld_device, { scan_field.in_value = (uint8_t *)words; - jtag_add_dr_scan(1, &scan_field, jtag_set_end_state(TAP_DRPAUSE)); + jtag_add_dr_scan(virtex2_info->tap, 1, &scan_field, jtag_set_end_state(TAP_DRPAUSE)); jtag_add_callback(virtexflip32, (jtag_callback_data_t)words); @@ -139,7 +136,6 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename) unsigned int i; struct scan_field field; - field.tap = virtex2_info->tap; field.in_value = NULL; if ((retval = xilinx_read_bit_file(&bit_file, filename)) != ERROR_OK) @@ -159,7 +155,7 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename) field.num_bits = bit_file.length * 8; field.out_value = bit_file.data; - jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_DRPAUSE)); + jtag_add_dr_scan(virtex2_info->tap, 1, &field, jtag_set_end_state(TAP_DRPAUSE)); jtag_execute_queue(); jtag_add_tlr(); diff --git a/src/svf/svf.c b/src/svf/svf.c index f46d6983..28595d5b 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -216,8 +216,6 @@ static char *svf_command_buffer = NULL; static int svf_command_buffer_size = 0; static int svf_line_number = 1; -static struct jtag_tap *tap = NULL; - #define SVF_MAX_BUFFER_SIZE_TO_COMMIT (4 * 1024) static uint8_t *svf_tdi_buffer = NULL, *svf_tdo_buffer = NULL, *svf_mask_buffer = NULL; static int svf_buffer_index = 0, svf_buffer_size = 0; @@ -1082,7 +1080,6 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str) { svf_add_check_para(0, svf_buffer_index, i); } - field.tap = tap; field.num_bits = i; field.out_value = &svf_tdi_buffer[svf_buffer_index]; field.in_value = &svf_tdi_buffer[svf_buffer_index]; @@ -1178,7 +1175,6 @@ static int svf_run_command(struct command_context *cmd_ctx |