}
}
-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);
}
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);
}
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();
}
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();
* 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 *
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()
*
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;
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);
/**
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.
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);
}
-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 */
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 */
-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;
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;
}
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;
}
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;
}
}
{
- 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;
}
{
- 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;
}
{
- 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));
}
}
{
- 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));
}
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));
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);
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));