summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jtag/core.c14
-rw-r--r--src/jtag/drivers/driver.c59
-rw-r--r--src/jtag/jtag.h20
-rw-r--r--src/jtag/minidriver.h4
-rw-r--r--src/jtag/minidummy/minidummy.c4
-rw-r--r--src/jtag/zy1000/zy1000.c18
-rw-r--r--src/svf/svf.c5
-rw-r--r--src/target/avrt.c15
-rw-r--r--src/target/dsp563xx.c14
-rw-r--r--src/xsvf/xsvf.c9
10 files changed, 69 insertions, 93 deletions
diff --git a/src/jtag/core.c b/src/jtag/core.c
index bce332fc..706f2f25 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -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();
diff --git a/src/jtag/drivers/driver.c b/src/jtag/drivers/driver.c
index 57bc28d1..7f7f8791 100644
--- a/src/jtag/drivers/driver.c
+++ b/src/jtag/drivers/driver.c
@@ -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 *
@@ -130,35 +130,6 @@ int interface_jtag_add_ir_scan(struct jtag_tap* active, const struct scan_field
}
/**
- * 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;
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index fe57db10..ae859618 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -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.
diff --git a/src/jtag/minidriver.h b/src/jtag/minidriver.h
index 4631593f..59b2a323 100644
--- a/src/jtag/minidriver.h
+++ b/src/jtag/minidriver.h
@@ -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);
diff --git a/src/jtag/minidummy/minidummy.c b/src/jtag/minidummy/minidummy.c
index 1eef0879..46ec9c3a 100644
--- a/src/jtag/minidummy/minidummy.c
+++ b/src/jtag/minidummy/minidummy.c
@@ -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 */
diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c
index 391d8f20..65d84026 100644
--- a/src/jtag/zy1000/zy1000.c
+++ b/src/jtag/zy1000/zy1000.c
@@ -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;
}
diff --git a/src/svf/svf.c b/src/svf/svf.c
index 28595d5b..fba499c3 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -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;
}
diff --git a/src/target/avrt.c b/src/target/avrt.c
index 5d912da8..720261ee 100644
--- a/src/target/avrt.c
+++ b/src/target/avrt.c
@@ -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;
diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index a379121a..4be7f3b5 100644
--- a/src/target/dsp563xx.c
+++ b/src/target/dsp563xx.c
@@ -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));
}
diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c
index 14bed8ef..f2c1a422 100644
--- a/src/xsvf/xsvf.c
+++ b/src/xsvf/xsvf.c
@@ -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));