jtag: jtag_add_ir_scan() now takes a single field
authorØyvind Harboe <oyvind.harboe@zylin.com>
Thu, 4 Mar 2010 13:38:19 +0000 (14:38 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 8 Mar 2010 07:12:25 +0000 (08:12 +0100)
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 <oyvind.harboe@zylin.com>
15 files changed:
src/flash/nor/str9xpec.c
src/jtag/core.c
src/jtag/drivers/driver.c
src/jtag/jtag.h
src/jtag/minidriver.h
src/jtag/minidummy/minidummy.c
src/jtag/tcl.c
src/jtag/zy1000/zy1000.c
src/pld/virtex2.c
src/target/arm11_dbgtap.c
src/target/arm_jtag.c
src/target/etb.c
src/target/mips_ejtag.c
src/target/xscale.c
src/xsvf/xsvf.c

index 3796a4b..b6d24f5 100644 (file)
@@ -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);
        }
index 2e09cb6..bce332f 100644 (file)
@@ -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);
        }
 }
 
index 673d191..57bc28d 100644 (file)
@@ -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 */
index 6e21024..fe57db1 100644 (file)
@@ -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
index a417216..4631593 100644 (file)
@@ -50,7 +50,7 @@
 #include <jtag/minidriver_imp.h>
 
 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,
index 98b449f..1eef087 100644 (file)
@@ -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 */
 
index da01f81..1073abc 100644 (file)
@@ -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();
 
index 0b11258..391d8f2 100644 (file)
@@ -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);
 
index 15685e6..976535b 100644 (file)
@@ -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);
        }
index f049059..2b7b4e4 100644 (file)
@@ -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). */
index 3e27b76..5ed104c 100644 (file)
@@ -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;
index 1f73ff5..2c4e3eb 100644 (file)
@@ -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);
        }
index 79160fc..e0550a8 100644 (file)
@@ -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;
index 4973898..602034e 100644 (file)
@@ -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;
index faa5542..14bed8e 100644 (file)
@@ -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)
                                        {