}
+/**
+ * Generate an IR SCAN with a list of scan fields with one entry for each enabled TAP.
+ *
+ * If the input field list contains an instruction value for a TAP then that is used
+ * otherwise the TAP is set to bypass.
+ *
+ * TAPs for which no fields are passed are marked as bypassed for subsequent DR SCANs.
+ *
+ */
void jtag_add_ir_scan(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
if (jtag_verify&&jtag_verify_capture_ir)
}
/**
- * Generate a list of scan fields with one entry for each TAP.
- *
- * If the input field list contains an instruction value for a TAP then that is used
- * otherwise the TAP is set to bypass.
+ * see jtag_add_ir_scan()
*
*/
int MINIDRIVER(interface_jtag_add_ir_scan)(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
return ERROR_OK;
}
+/**
+ * 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
+ *
+ */
void jtag_add_plain_ir_scan(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
int retval;
jtag_error=retval;
}
+
+/**
+ * see jtag_add_plain_ir_scan()
+ *
+ */
int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
return ERROR_OK;
}
-void jtag_add_dr_scan(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
-{
- int retval;
-
- jtag_prelude(state);
-
- retval=interface_jtag_add_dr_scan(in_num_fields, in_fields, cmd_queue_end_state);
- if (retval!=ERROR_OK)
- jtag_error=retval;
-}
int jtag_check_value_inner(u8 *captured, u8 *in_check_value, u8 *in_check_mask, int num_bits);
}
}
+
+/**
+ * Generate a DR SCAN using the fields passed to the function
+ *
+ * For not bypassed TAPs the function checks in_fields and uses fields specified there.
+ * For bypassed TAPs the function generates a dummy 1bit field.
+ *
+ * The bypass status of TAPs is set by jtag_add_ir_scan().
+ *
+ */
+void jtag_add_dr_scan(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
+{
+ int retval;
+
+ jtag_prelude(state);
+
+ retval=interface_jtag_add_dr_scan(in_num_fields, in_fields, cmd_queue_end_state);
+ if (retval!=ERROR_OK)
+ jtag_error=retval;
+}
+
+
+/**
+ * see jtag_add_dr_scan()
+ *
+ */
int MINIDRIVER(interface_jtag_add_dr_scan)(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
int j;
int nth_tap;
int bypass_devices = 0;
int field_count = 0;
- int scan_size;
jtag_tap_t *tap;
if (tap == in_fields[j].tap)
{
found = 1;
- scan_size = in_fields[j].num_bits;
+ size_t scan_size = in_fields[j].num_bits;
scan->fields[field_count].num_bits = scan_size;
scan->fields[field_count].out_value = buf_cpy(in_fields[j].out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
scan->fields[field_count].in_value = in_fields[j].in_value;
return ERROR_OK;
}
+
+
+/**
+ * Generate a DR SCAN using the array of output values passed to the function
+ *
+ * This function assumes that the parameter target_tap specifies the one TAP
+ * that is not bypassed. All other TAPs must be bypassed and the function will
+ * generate a dummy 1bit field for them.
+ *
+ * For the target_tap a sequence of output-only fields will be generated where
+ * each field has the size num_bits and the field's values are taken from
+ * the array value.
+ *
+ * The bypass status of TAPs is set by jtag_add_ir_scan().
+ *
+ */
void MINIDRIVER(interface_jtag_add_dr_out)(jtag_tap_t *target_tap,
int in_num_fields,
const int *num_bits,
{
int nth_tap;
int field_count = 0;
- int scan_size;
int bypass_devices = 0;
jtag_tap_t *tap;
}
}
- /* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
jtag_queue_command(cmd);
- cmd->type = JTAG_SCAN;
+ cmd->type = JTAG_SCAN;
+ cmd->cmd.scan = scan;
- /* allocate memory for dr scan command */
- cmd->cmd.scan = cmd_queue_alloc(sizeof(scan_command_t));
- cmd->cmd.scan->ir_scan = false;
- cmd->cmd.scan->num_fields = in_num_fields + bypass_devices;
- cmd->cmd.scan->fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
- cmd->cmd.scan->end_state = end_state;
+ scan->ir_scan = false;
+ scan->num_fields = in_num_fields + bypass_devices;
+ scan->fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
+ scan->end_state = end_state;
tap = NULL;
nth_tap = -1;
break;
}
nth_tap++;
- cmd->cmd.scan->fields[field_count].tap = tap;
+ scan->fields[field_count].tap = tap;
if (tap == target_tap)
{
- int j;
#ifdef _DEBUG_JTAG_IO_
/* if a device is listed, the BYPASS register must not be selected */
if (tap->bypass)
exit(-1);
}
#endif
- for (j = 0; j < in_num_fields; j++)
+ for (int j = 0; j < in_num_fields; j++)
{
u8 out_value[4];
- scan_size = num_bits[j];
+ size_t scan_size = num_bits[j];
buf_set_u32(out_value, 0, scan_size, value[j]);
- cmd->cmd.scan->fields[field_count].num_bits = scan_size;
- cmd->cmd.scan->fields[field_count].out_value = buf_cpy(out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
- cmd->cmd.scan->fields[field_count].in_value = NULL;
+ scan->fields[field_count].num_bits = scan_size;
+ scan->fields[field_count].out_value = buf_cpy(out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
+ scan->fields[field_count].in_value = NULL;
field_count++;
}
} else
}
#endif
/* program the scan field to 1 bit length, and ignore it's value */
- cmd->cmd.scan->fields[field_count].num_bits = 1;
- cmd->cmd.scan->fields[field_count].out_value = NULL;
- cmd->cmd.scan->fields[field_count].in_value = NULL;
+ scan->fields[field_count].num_bits = 1;
+ scan->fields[field_count].out_value = NULL;
+ scan->fields[field_count].in_value = NULL;
field_count++;
}
}
}
+
+/**
+ * Duplicate the scan fields passed into the function into a DR SCAN command
+ *
+ * This function assumes that the caller handles extra fields for bypassed TAPs
+ *
+ */
void jtag_add_plain_dr_scan(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
int retval;
jtag_error=retval;
}
+
+/**
+ * see jtag_add_plain_dr_scan()
+ *
+ */
int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
- /* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
jtag_queue_command(cmd);
- cmd->type = JTAG_SCAN;
+ cmd->type = JTAG_SCAN;
+ cmd->cmd.scan = scan;
- /* allocate memory for scan command */
- cmd->cmd.scan = cmd_queue_alloc(sizeof(scan_command_t));
- cmd->cmd.scan->ir_scan = false;
- cmd->cmd.scan->num_fields = in_num_fields;
- cmd->cmd.scan->fields = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t));
- cmd->cmd.scan->end_state = state;
+ scan->ir_scan = false;
+ scan->num_fields = in_num_fields;
+ scan->fields = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t));
+ scan->end_state = state;
for (int i = 0; i < in_num_fields; i++)
{
int num_bits = in_fields[i].num_bits;
int num_bytes = CEIL(in_fields[i].num_bits, 8);
- cmd->cmd.scan->fields[i].tap = in_fields[i].tap;
- cmd->cmd.scan->fields[i].num_bits = num_bits;
- cmd->cmd.scan->fields[i].out_value = buf_cpy(in_fields[i].out_value, cmd_queue_alloc(num_bytes), num_bits);
- cmd->cmd.scan->fields[i].in_value = in_fields[i].in_value;
+ scan->fields[i].tap = in_fields[i].tap;
+ scan->fields[i].num_bits = num_bits;
+ scan->fields[i].out_value = buf_cpy(in_fields[i].out_value, cmd_queue_alloc(num_bytes), num_bits);
+ scan->fields[i].in_value = in_fields[i].in_value;
}
return ERROR_OK;
}
+
void jtag_add_tlr(void)
{
jtag_prelude(TAP_RESET);
/* to state: */
/* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */ /* from state: */
- { B8(1111111,7), B8(0000000,7), B8(00101,5), B8(01010,5), B8(001101,6), B8(010110,6) }, /* RESET */
+ { B8(1111111,7), B8(0000000,7), B8(0010111,7), B8(0001010,7), B8(0011011,7), B8(0010110,7) }, /* RESET */
{ B8(1111111,7), B8(0000000,7), B8(001,3), B8(0101,4), B8(0011,4), B8(01011,5) }, /* IDLE */
- { B8(1111111,7), B8(011,3), B8(00111,5), B8(01,2), B8(001111,6), B8(0101111,7) }, /* DRSHIFT */
- { B8(1111111,7), B8(011,3), B8(01,2), B8(0,1), B8(001111,6), B8(0101111,7) }, /* DRPAUSE */
+ { B8(1111111,7), B8(011,3), B8(00111,5), B8(01,2), B8(001111,6), B8(0101111,7) }, /* DRSHIFT */
+ { B8(1111111,7), B8(011,3), B8(01,2), B8(0,1), B8(001111,6), B8(0101111,7) }, /* DRPAUSE */
{ B8(1111111,7), B8(011,3), B8(00111,5), B8(010111,6), B8(001111,6), B8(01,2) }, /* IRSHIFT */
{ B8(1111111,7), B8(011,3), B8(00111,5), B8(010111,6), B8(01,2), B8(0,1) } /* IRPAUSE */