From: Øyvind Harboe Date: Thu, 4 Mar 2010 13:38:19 +0000 (+0100) Subject: jtag: jtag_add_ir_scan() now takes a single field X-Git-Tag: v0.5.0-rc1~870 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=57d7743639d5092770d79f7c4b12ae694c482750;p=openocd jtag: jtag_add_ir_scan() now takes a single field In the code a single field was all that was ever used. Makes jtag_add_ir_scan() simpler and leaves more complicated stuff to jtag_add_plain_ir_scan(). Signed-off-by: Øyvind Harboe --- diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c index 3796a4b1..b6d24f58 100644 --- a/src/flash/nor/str9xpec.c +++ b/src/flash/nor/str9xpec.c @@ -48,7 +48,7 @@ int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; - jtag_add_ir_scan(tap, 1, &field, end_state); + jtag_add_ir_scan(tap, &field, end_state); free(field.out_value); } diff --git a/src/jtag/core.c b/src/jtag/core.c index 2e09cb6d..bce332fc 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -42,7 +42,8 @@ /// The number of JTAG queue flushes (for profiling and debugging purposes). static int jtag_flush_queue_count; -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), +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 +353,22 @@ void jtag_alloc_in_value32(struct scan_field *field) interface_jtag_alloc_in_value32(field); } -void jtag_add_ir_scan_noverify(struct jtag_tap *active, int in_count, const struct scan_field *in_fields, +void jtag_add_ir_scan_noverify(struct jtag_tap *active, const struct scan_field *in_fields, tap_state_t state) { jtag_prelude(state); - int retval = interface_jtag_add_ir_scan(active, in_count, in_fields, state); + int retval = interface_jtag_add_ir_scan(active, in_fields, state); jtag_set_error(retval); } +static void jtag_add_ir_scan_noverify_callback(struct jtag_tap *active, int dummy, const struct scan_field *in_fields, + tap_state_t state) +{ + jtag_add_ir_scan_noverify(active, in_fields, state); +} -void jtag_add_ir_scan(struct jtag_tap *active, int in_num_fields, struct scan_field *in_fields, tap_state_t state) +void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap_state_t state) { assert(state != TAP_RESET); @@ -370,18 +376,15 @@ void jtag_add_ir_scan(struct jtag_tap *active, int in_num_fields, struct scan_fi { /* 8 x 32 bit id's is enough for all invocations */ - for (int j = 0; j < in_num_fields; j++) - { - /* 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 = active->expected; - in_fields[j].check_mask = active->expected_mask; - } - jtag_add_scan_check(active, jtag_add_ir_scan_noverify, in_num_fields, in_fields, 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->check_value = active->expected; + in_fields->check_mask = active->expected_mask; + jtag_add_scan_check(active, jtag_add_ir_scan_noverify_callback, 1, in_fields, state); } else { - jtag_add_ir_scan_noverify(active, in_num_fields, in_fields, state); + jtag_add_ir_scan_noverify(active, in_fields, state); } } diff --git a/src/jtag/drivers/driver.c b/src/jtag/drivers/driver.c index 673d191e..57bc28d1 100644 --- a/src/jtag/drivers/driver.c +++ b/src/jtag/drivers/driver.c @@ -74,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(struct jtag_tap* active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state) +int interface_jtag_add_ir_scan(struct jtag_tap* active, const struct scan_field *in_fields, tap_state_t state) { size_t num_taps = jtag_tap_count_enabled(); @@ -106,8 +106,7 @@ int interface_jtag_add_ir_scan(struct jtag_tap* active, int in_num_fields, const /* if TAP is listed in input fields, copy the value */ tap->bypass = 0; - for (int j = 0; j < in_num_fields; j++) - cmd_queue_scan_field_clone(field, in_fields + j); + cmd_queue_scan_field_clone(field, in_fields); } else { /* if a TAP isn't listed in input fields, set it to BYPASS */ diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 6e21024e..fe57db10 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -350,13 +350,13 @@ int jtag_init_inner(struct command_context *cmd_ctx); * subsequent DR SCANs. * */ -void jtag_add_ir_scan(struct jtag_tap* tap, int num_fields, +void jtag_add_ir_scan(struct jtag_tap* tap, 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(struct jtag_tap* tap, int num_fields, +void jtag_add_ir_scan_noverify(struct jtag_tap* tap, const struct scan_field *fields, tap_state_t state); /** * Duplicate the scan fields passed into the function into an IR SCAN diff --git a/src/jtag/minidriver.h b/src/jtag/minidriver.h index a4172169..4631593f 100644 --- a/src/jtag/minidriver.h +++ b/src/jtag/minidriver.h @@ -50,7 +50,7 @@ #include int interface_jtag_add_ir_scan(struct jtag_tap* active, - int num_fields, const struct scan_field* 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, diff --git a/src/jtag/minidummy/minidummy.c b/src/jtag/minidummy/minidummy.c index 98b449f9..1eef0879 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(struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state) +int interface_jtag_add_ir_scan(struct jtag_tap *active, 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 da01f812..1073abc0 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -1490,6 +1490,15 @@ COMMAND_HANDLER(handle_irscan_command) } int num_fields = CMD_ARGC / 2; + if (num_fields > 1) + { + /* we really should be looking at plain_ir_scan if we want + * anything more fancy. + */ + LOG_ERROR("Specify a single value for tap"); + return ERROR_COMMAND_SYNTAX_ERROR; + } + size_t fields_len = sizeof(struct scan_field) * num_fields; fields = malloc(fields_len); memset(fields, 0, fields_len); @@ -1521,7 +1530,7 @@ COMMAND_HANDLER(handle_irscan_command) } /* did we have an endstate? */ - jtag_add_ir_scan(tap, num_fields, fields, endstate); + jtag_add_ir_scan(tap, fields, endstate); retval = jtag_execute_queue(); diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 0b112589..391d8f20 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -574,13 +574,11 @@ static __inline void scanFields(int num_fields, const struct scan_field *fields, } } -int interface_jtag_add_ir_scan(struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state) +int interface_jtag_add_ir_scan(struct jtag_tap *active, const struct scan_field *fields, tap_state_t state) { 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); @@ -590,7 +588,7 @@ int interface_jtag_add_ir_scan(struct jtag_tap *active, int num_fields, const st /* search the list */ if (tap == active) { - scanFields(num_fields, fields, TAP_IRSHIFT, pause); + scanFields(1, fields, TAP_IRSHIFT, pause); /* update device information */ buf_cpy(fields[0].out_value, tap->cur_instr, scan_size); diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 15685e61..976535b4 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -40,7 +40,7 @@ static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr) buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; - jtag_add_ir_scan(tap, 1, &field, jtag_set_end_state(TAP_IDLE)); + jtag_add_ir_scan(tap, &field, jtag_set_end_state(TAP_IDLE)); free(field.out_value); } diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index f0490596..2b7b4e42 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -49,13 +49,13 @@ static const tap_state_t arm11_move_pi_to_si_via_ci[] = /* REVISIT no error handling here! */ -static void arm11_add_ir_scan_vc(struct jtag_tap *tap, int num_fields, struct scan_field *fields, +static void arm11_add_ir_scan_vc(struct jtag_tap *tap, struct scan_field *fields, tap_state_t state) { if (cmd_queue_cur_state == TAP_IRPAUSE) jtag_add_pathmove(ARRAY_SIZE(arm11_move_pi_to_si_via_ci), arm11_move_pi_to_si_via_ci); - jtag_add_ir_scan(tap, num_fields, fields, state); + jtag_add_ir_scan(tap, fields, state); } static const tap_state_t arm11_move_pd_to_sd_via_cd[] = @@ -149,7 +149,7 @@ void arm11_add_IR(struct arm11_common * arm11, uint8_t instr, tap_state_t state) arm11_setup_field(arm11, 5, &instr, NULL, &field); - arm11_add_ir_scan_vc(arm11->arm.target->tap, 1, &field, state == ARM11_TAP_DEFAULT ? TAP_IRPAUSE : state); + arm11_add_ir_scan_vc(arm11->arm.target->tap, &field, state == ARM11_TAP_DEFAULT ? TAP_IRPAUSE : state); } /** Verify data shifted out from Scan Chain Register (SCREG). */ diff --git a/src/target/arm_jtag.c b/src/target/arm_jtag.c index 3e27b763..5ed104cf 100644 --- a/src/target/arm_jtag.c +++ b/src/target/arm_jtag.c @@ -45,13 +45,13 @@ int arm_jtag_set_instr_inner(struct arm_jtag *jtag_info, uint32_t new_instr, vo if (no_verify_capture == NULL) { - jtag_add_ir_scan(tap, 1, &field, jtag_get_end_state()); + jtag_add_ir_scan(tap, &field, jtag_get_end_state()); } else { /* FIX!!!! this is a kludge!!! arm926ejs.c should reimplement this arm_jtag_set_instr to * have special verification code. */ - jtag_add_ir_scan_noverify(tap, 1, &field, jtag_get_end_state()); + jtag_add_ir_scan_noverify(tap, &field, jtag_get_end_state()); } return ERROR_OK; diff --git a/src/target/etb.c b/src/target/etb.c index 1f73ff5e..2c4e3ebe 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -60,7 +60,7 @@ static int etb_set_instr(struct etb *etb, uint32_t new_instr) field.in_value = NULL; - jtag_add_ir_scan(tap, 1, &field, jtag_get_end_state()); + jtag_add_ir_scan(tap, &field, jtag_get_end_state()); free(field.out_value); } diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c index 79160fc4..e0550a81 100644 --- a/src/target/mips_ejtag.c +++ b/src/target/mips_ejtag.c @@ -46,7 +46,7 @@ int mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, int new_instr, void *del buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; - jtag_add_ir_scan(tap, 1, &field, jtag_get_end_state()); + jtag_add_ir_scan(tap, &field, jtag_get_end_state()); } return ERROR_OK; diff --git a/src/target/xscale.c b/src/target/xscale.c index 49738981..602034eb 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -173,7 +173,7 @@ static int xscale_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr) field.out_value = scratch; buf_set_u32(field.out_value, 0, field.num_bits, new_instr); - jtag_add_ir_scan(tap, 1, &field, jtag_get_end_state()); + jtag_add_ir_scan(tap, &field, jtag_get_end_state()); } return ERROR_OK; diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index faa55421..14bed8ef 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -704,7 +704,7 @@ COMMAND_HANDLER(handle_xsvf_command) if (tap == NULL) jtag_add_plain_ir_scan(1, &field, my_end_state); else - jtag_add_ir_scan(tap, 1, &field, my_end_state); + jtag_add_ir_scan(tap, &field, my_end_state); if (xruntest) {