jtag: simplify jtag_add_plain_ir/dr_scan

These fn's now clearly just clock out/in bits. No mystical
fields are involved.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
This commit is contained in:
Øyvind Harboe 2010-03-06 11:29:59 +01:00
parent 57d7743639
commit 50dc56a488
10 changed files with 69 additions and 93 deletions

View 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();

View 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;

View 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.

View 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);

View 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 */

View 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;
}

View 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;
}

View 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;

View 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));
}

View 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));