]> git.sur5r.net Git - openocd/commitdiff
jtag: simplify jtag_add_plain_ir/dr_scan
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sat, 6 Mar 2010 10:29:59 +0000 (11:29 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 8 Mar 2010 07:12:26 +0000 (08:12 +0100)
These fn's now clearly just clock out/in bits. No mystical
fields are involved.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/jtag/core.c
src/jtag/drivers/driver.c
src/jtag/jtag.h
src/jtag/minidriver.h
src/jtag/minidummy/minidummy.c
src/jtag/zy1000/zy1000.c
src/svf/svf.c
src/target/avrt.c
src/target/dsp563xx.c
src/xsvf/xsvf.c

index bce332fc844cdb4411cd7b343081bd4acb949451..706f2f259553609beaa70a5b18d53be0c6e8c287 100644 (file)
@@ -388,15 +388,16 @@ void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap
        }
 }
 
-void jtag_add_plain_ir_scan(int in_num_fields, const struct scan_field *in_fields,
+void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
                tap_state_t state)
 {
+       assert(out_bits != NULL);
        assert(state != TAP_RESET);
 
        jtag_prelude(state);
 
        int retval = interface_jtag_add_plain_ir_scan(
-                       in_num_fields, in_fields, state);
+                       num_bits, out_bits, in_bits, state);
        jtag_set_error(retval);
 }
 
@@ -469,15 +470,16 @@ void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct s
        jtag_set_error(retval);
 }
 
-void jtag_add_plain_dr_scan(int in_num_fields, const struct scan_field *in_fields,
+void jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
                tap_state_t state)
 {
+       assert(out_bits != NULL);
        assert(state != TAP_RESET);
 
        jtag_prelude(state);
 
        int retval;
-       retval = interface_jtag_add_plain_dr_scan(in_num_fields, in_fields, state);
+       retval = interface_jtag_add_plain_dr_scan(num_bits, out_bits, in_bits, state);
        jtag_set_error(retval);
 }
 
@@ -906,7 +908,7 @@ static int jtag_examine_chain_execute(uint8_t *idcode_buffer, unsigned num_idcod
        for (unsigned i = 0; i < JTAG_MAX_CHAIN_SIZE; i++)
                buf_set_u32(idcode_buffer, i * 32, 32, END_OF_CHAIN_FLAG);
 
-       jtag_add_plain_dr_scan(1, &field, TAP_DRPAUSE);
+       jtag_add_plain_dr_scan(field.num_bits, field.out_value, field.in_value, TAP_DRPAUSE);
        jtag_add_tlr();
        return jtag_execute_queue();
 }
@@ -1207,7 +1209,7 @@ static int jtag_validate_ircapture(void)
        field.out_value = ir_test;
        field.in_value = ir_test;
 
-       jtag_add_plain_ir_scan(1, &field, TAP_IDLE);
+       jtag_add_plain_ir_scan(field.num_bits, field.out_value, field.in_value, TAP_IDLE);
 
        LOG_DEBUG("IR capture validation scan");
        retval = jtag_execute_queue();
index 57bc28d1601673956339ece10d2b69e0942bce4f..7f7f8791b2452fb3a48b70c9881589402d277815 100644 (file)
@@ -2,7 +2,7 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
- *   Copyright (C) 2007-2009 Øyvind Harboe                                 *
+ *   Copyright (C) 2007-2010 Øyvind Harboe                                 *
  *   oyvind.harboe@zylin.com                                               *
  *                                                                         *
  *   Copyright (C) 2009 SoftPLC Corporation                                *
@@ -129,35 +129,6 @@ int interface_jtag_add_ir_scan(struct jtag_tap* active, const struct scan_field
        return ERROR_OK;
 }
 
-/**
- * see jtag_add_plain_ir_scan()
- *
- */
-int interface_jtag_add_plain_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
-{
-
-       struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
-       struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
-       struct scan_field * out_fields  = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field));
-
-       jtag_queue_command(cmd);
-
-       cmd->type                               = JTAG_SCAN;
-       cmd->cmd.scan                   = scan;
-
-       scan->ir_scan                   = true;
-       scan->num_fields                = in_num_fields;
-       scan->fields                    = out_fields;
-       scan->end_state                 = state;
-
-       for (int i = 0; i < in_num_fields; i++)
-               cmd_queue_scan_field_clone(out_fields + i, in_fields + i);
-
-       return ERROR_OK;
-}
-
-
-
 /**
  * see jtag_add_dr_scan()
  *
@@ -324,32 +295,40 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
        assert(target_tap_match);       /* target_tap should be enabled and not bypassed */
 }
 
-/**
- * see jtag_add_plain_dr_scan()
- *
- */
-int interface_jtag_add_plain_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
+static int jtag_add_plain_scan(int num_bits, const uint8_t *out_bits,
+               uint8_t *in_bits, tap_state_t state, bool ir_scan)
 {
        struct jtag_command * cmd               = cmd_queue_alloc(sizeof(struct jtag_command));
        struct scan_command * scan              = cmd_queue_alloc(sizeof(struct scan_command));
-       struct scan_field * out_fields  = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field));
+       struct scan_field * out_fields  = cmd_queue_alloc(sizeof(struct scan_field));
 
        jtag_queue_command(cmd);
 
        cmd->type                               = JTAG_SCAN;
        cmd->cmd.scan                   = scan;
 
-       scan->ir_scan                   = false;
-       scan->num_fields                = in_num_fields;
+       scan->ir_scan                   = ir_scan;
+       scan->num_fields                = 1;
        scan->fields                    = out_fields;
        scan->end_state                 = state;
 
-       for (int i = 0; i < in_num_fields; i++)
-               cmd_queue_scan_field_clone(out_fields + i, in_fields + i);
+       out_fields->num_bits    = num_bits;
+       out_fields->out_value   = buf_cpy(out_bits, cmd_queue_alloc(DIV_ROUND_UP(num_bits, 8)), num_bits);
+       out_fields->in_value    = in_bits;
 
        return ERROR_OK;
 }
 
+int interface_jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
+{
+       return jtag_add_plain_scan(num_bits, out_bits, in_bits, state, false);
+}
+
+int interface_jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
+{
+       return jtag_add_plain_scan(num_bits, out_bits, in_bits, state, true);
+}
+
 int interface_jtag_add_tlr(void)
 {
        tap_state_t state = TAP_RESET;
index fe57db108b2729d7f21ebb49c2cb899473e5e6ec..ae85961818557d18cd39674134255d6f96c23678 100644 (file)
@@ -359,12 +359,12 @@ void jtag_add_ir_scan(struct jtag_tap* tap,
 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
- * command.  This function assumes that the caller handles extra fields
- * for bypassed TAPs.
+ * Scan out the bits in ir scan mode.
+ *
+ * If in_bits == NULL, discard incoming bits.
  */
-void jtag_add_plain_ir_scan(int num_fields,
-               const struct scan_field* fields, tap_state_t endstate);
+void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
+               tap_state_t endstate);
 
 
 /**
@@ -390,12 +390,12 @@ void jtag_add_dr_scan(struct jtag_tap* tap, 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
- * command.  Unlike jtag_add_dr_scan(), this function assumes that the
- * caller handles extra fields for bypassed TAPs.
+ * Scan out the bits in ir scan mode.
+ *
+ * If in_bits == NULL, discard incoming bits.
  */
-void jtag_add_plain_dr_scan(int num_fields,
-               const struct scan_field* fields, tap_state_t endstate);
+void jtag_add_plain_dr_scan(int num_bits,
+               const uint8_t *out_bits, uint8_t *in_bits, tap_state_t endstate);
 
 /**
  * Defines the type of data passed to the jtag_callback_t interface.
index 4631593f418405a83351031147f570f5d1c8ee35..59b2a32369807127418c53a77580790201b50ded 100644 (file)
@@ -53,14 +53,14 @@ int interface_jtag_add_ir_scan(struct jtag_tap* active,
                const struct scan_field* fields,
                tap_state_t endstate);
 int interface_jtag_add_plain_ir_scan(
-               int num_fields, const struct scan_field* fields,
+               int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
                tap_state_t endstate);
 
 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(
-               int num_fields, const struct scan_field* fields,
+               int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
                tap_state_t endstate);
 
 int interface_jtag_add_tlr(void);
index 1eef08795c769ca0e441e49c9da08e3e6a60d14c..46ec9c3ab521cfdce7eed5579ec6ca71b3928f93 100644 (file)
@@ -54,7 +54,7 @@ int interface_jtag_add_ir_scan(struct jtag_tap *active, const struct scan_field
 
 }
 
-int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
+int interface_jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
 {
        /* synchronously do the operation here */
 
@@ -68,7 +68,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int num_fields, const st
        return ERROR_OK;
 }
 
-int interface_jtag_add_plain_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
+int interface_jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
 {
        /* synchronously do the operation here */
 
index 391d8f2076201d9383aee80dec7a3a1f3c2c7249..65d84026079504d56d8016d67925f3f1b3104098 100644 (file)
@@ -611,9 +611,14 @@ int interface_jtag_add_ir_scan(struct jtag_tap *active, const struct scan_field
 
 
 
-int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
+int interface_jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
 {
-       scanFields(num_fields, fields, TAP_IRSHIFT, 1);
+       struct scan_field field;
+       field.num_bits  = num_bits;
+       field.out_value = out_bits;
+       field.in_value  = in_bits;
+
+       scanFields(1, &field, TAP_IRSHIFT, 1);
        gotoEndState(state);
 
        return ERROR_OK;
@@ -644,9 +649,14 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int num_fields, const st
        return ERROR_OK;
 }
 
-int interface_jtag_add_plain_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
+int interface_jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
 {
-       scanFields(num_fields, fields, TAP_DRSHIFT, 1);
+       struct scan_field field;
+       field.num_bits  = num_bits;
+       field.out_value = out_bits;
+       field.in_value  = in_bits;
+
+       scanFields(1, &field, TAP_DRSHIFT, 1);
        gotoEndState(state);
        return ERROR_OK;
 }
index 28595d5bd07ba4aace58500bbd4adc8845474bea..fba499c3d989cb991602575fabd15a7e8b666e26 100644 (file)
@@ -1084,7 +1084,7 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str)
                        field.out_value = &svf_tdi_buffer[svf_buffer_index];
                        field.in_value = &svf_tdi_buffer[svf_buffer_index];
                        /* NOTE:  doesn't use SVF-specified state paths */
-                       jtag_add_plain_dr_scan(1, &field, svf_para.dr_end_state);
+                       jtag_add_plain_dr_scan(field.num_bits, field.out_value, field.in_value, svf_para.dr_end_state);
 
                        svf_buffer_index += (i + 7) >> 3;
                }
@@ -1179,7 +1179,8 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str)
                        field.out_value = &svf_tdi_buffer[svf_buffer_index];
                        field.in_value = &svf_tdi_buffer[svf_buffer_index];
                        /* NOTE:  doesn't use SVF-specified state paths */
-                       jtag_add_plain_ir_scan(1, &field, svf_para.ir_end_state);
+                       jtag_add_plain_ir_scan(field.num_bits, field.out_value, field.in_value,
+                                       svf_para.ir_end_state);
 
                        svf_buffer_index += (i + 7) >> 3;
                }
index 5d912da8058bf4d74a056645831927bc9e86f9f8..720261eea48cccbf560d770df05d4827a92c4875 100644 (file)
@@ -190,12 +190,8 @@ int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_l
        }
 
        {
-               struct scan_field field[1];
-
-               field[0].num_bits = tap->ir_length;
-               field[0].out_value = ir_out;
-               field[0].in_value = ir_in;
-               jtag_add_plain_ir_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE));
+               jtag_add_plain_ir_scan(tap->ir_length, ir_out, ir_in,
+                               jtag_set_end_state(TAP_IDLE));
        }
 
        return ERROR_OK;
@@ -210,12 +206,7 @@ int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out, int dr_l
        }
 
        {
-               struct scan_field field[1];
-
-               field[0].num_bits = dr_len;
-               field[0].out_value = dr_out;
-               field[0].in_value = dr_in;
-               jtag_add_plain_dr_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE));
+               jtag_add_plain_dr_scan(dr_len, dr_out, dr_in, jtag_set_end_state(TAP_IDLE));
        }
 
        return ERROR_OK;
index a379121a9f351849ab399f1cdbe37ada6adae4ce..4be7f3b5ed9c4f2f275c29d92629e23d48a9585b 100644 (file)
@@ -863,12 +863,7 @@ int dsp563xx_write_ir(struct jtag_tap *tap, uint8_t * ir_in, uint8_t * ir_out,
        }
 
        {
-               struct scan_field field[1];
-
-               field[0].num_bits = tap->ir_length;
-               field[0].out_value = ir_out;
-               field[0].in_value = ir_in;
-               jtag_add_plain_ir_scan(ARRAY_SIZE(field), field,
+               jtag_add_plain_ir_scan(tap->ir_length, ir_out, ir_in,
                                       jtag_set_end_state(TAP_IDLE));
        }
 
@@ -885,12 +880,7 @@ int dsp563xx_write_dr(struct jtag_tap *tap, uint8_t * dr_in, uint8_t * dr_out,
        }
 
        {
-               struct scan_field field[1];
-
-               field[0].num_bits = dr_len;
-               field[0].out_value = dr_out;
-               field[0].in_value = dr_in;
-               jtag_add_plain_dr_scan(ARRAY_SIZE(field), field,
+               jtag_add_plain_dr_scan(dr_len, dr_out, dr_in,
                                       jtag_set_end_state(TAP_IDLE));
        }
 
index 14bed8efb44996f4aaa7fdd2921d08cfd7a6ed69..f2c1a4220a2a0eec8aa2110a7d0f5a50e09fbdef 100644 (file)
@@ -481,7 +481,8 @@ COMMAND_HANDLER(handle_xsvf_command)
                                        field.in_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1);
 
                                        if (tap == NULL)
-                                               jtag_add_plain_dr_scan(1, &field, jtag_set_end_state(TAP_DRPAUSE));
+                                               jtag_add_plain_dr_scan(field.num_bits, field.out_value, field.in_value,
+                                                               jtag_set_end_state(TAP_DRPAUSE));
                                        else
                                                jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_DRPAUSE));
 
@@ -702,7 +703,8 @@ COMMAND_HANDLER(handle_xsvf_command)
 
 
                                        if (tap == NULL)
-                                               jtag_add_plain_ir_scan(1, &field, my_end_state);
+                                               jtag_add_plain_ir_scan(field.num_bits,
+                                                               field.out_value, field.in_value, my_end_state);
                                        else
                                                jtag_add_ir_scan(tap, &field, my_end_state);
 
@@ -936,7 +938,8 @@ COMMAND_HANDLER(handle_xsvf_command)
                                                LOG_USER("LSDR retry %d", attempt);
 
                                        if (tap == NULL)
-                                               jtag_add_plain_dr_scan(1, &field, jtag_set_end_state(TAP_DRPAUSE));
+                                               jtag_add_plain_dr_scan(field.num_bits, field.out_value, field.in_value,
+                                                               jtag_set_end_state(TAP_DRPAUSE));
                                        else
                                                jtag_add_dr_scan(tap, 1, &field, jtag_set_end_state(TAP_DRPAUSE));