-/**
- * see jtag_add_dr_scan()
- *
- */
-int MINIDRIVER(interface_jtag_add_dr_scan)(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
-{
- int j;
- int field_count = 0;
-
- /* count devices in bypass */
-
- size_t bypass_devices = 0;
-
- for (jtag_tap_t * tap = jtag_NextEnabledTap(NULL); tap != NULL; tap = jtag_NextEnabledTap(tap))
- {
- if (tap->bypass)
- bypass_devices++;
- }
-
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
-
- jtag_queue_command(cmd);
-
- cmd->type = JTAG_SCAN;
- cmd->cmd.scan = scan;
-
- scan->ir_scan = false;
- scan->num_fields = in_num_fields + bypass_devices;
- scan->fields = out_fields;
- scan->end_state = state;
-
- for (jtag_tap_t * tap = jtag_NextEnabledTap(NULL); tap != NULL; tap = jtag_NextEnabledTap(tap))
- {
- int found = 0;
- scan->fields[field_count].tap = tap;
-
- for (j = 0; j < in_num_fields; j++)
- {
- if (tap == in_fields[j].tap)
- {
- found = 1;
- 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;
- field_count++;
- }
- }
- if (!found)
- {
-#ifdef _DEBUG_JTAG_IO_
- /* if a device isn't listed, the BYPASS register should be selected */
- if (! tap->bypass)
- {
- LOG_ERROR("BUG: no scan data for a device not in BYPASS");
- exit(-1);
- }
-#endif
- /* program the scan field to 1 bit length, and ignore it's value */
- scan->fields[field_count].num_bits = 1;
- scan->fields[field_count].out_value = NULL;
- scan->fields[field_count].in_value = NULL;
- field_count++;
- }
- else
- {
-#ifdef _DEBUG_JTAG_IO_
- /* if a device is listed, the BYPASS register must not be selected */
- if (tap->bypass)
- {
- LOG_ERROR("BUG: scan data for a device in BYPASS");
- exit(-1);
- }
-#endif
- }
- }
-
- /* field_count represents the true number of fields setup*/
- scan->num_fields = field_count;
- 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,
- const u32 *value,
- tap_state_t end_state)
-{
- int field_count = 0;
-
- /* count devices in bypass */
-
- size_t bypass_devices = 0;
-
- for (jtag_tap_t * tap = jtag_NextEnabledTap(NULL); tap != NULL; tap = jtag_NextEnabledTap(tap))
- {
- if (tap->bypass)
- bypass_devices++;
- }
-
-
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
-
- jtag_queue_command(cmd);
-
- cmd->type = JTAG_SCAN;
- cmd->cmd.scan = scan;
-
- scan->ir_scan = false;
- scan->num_fields = in_num_fields + bypass_devices;
- scan->fields = out_fields;
- scan->end_state = end_state;
-
- for (jtag_tap_t * tap = jtag_NextEnabledTap(NULL); tap != NULL; tap = jtag_NextEnabledTap(tap))
- {
- scan->fields[field_count].tap = tap;
-
- if (tap == target_tap)
- {
-#ifdef _DEBUG_JTAG_IO_
- /* if a device is listed, the BYPASS register must not be selected */
- if (tap->bypass)
- {
- LOG_ERROR("BUG: scan data for a device in BYPASS");
- exit(-1);
- }
-#endif
- for (int j = 0; j < in_num_fields; j++)
- {
- u8 out_value[4];
- size_t scan_size = num_bits[j];
- buf_set_u32(out_value, 0, scan_size, value[j]);
- 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
- {
-#ifdef _DEBUG_JTAG_IO_
- /* if a device isn't listed, the BYPASS register should be selected */
- if (! tap->bypass)
- {
- LOG_ERROR("BUG: no scan data for a device not in BYPASS");
- exit(-1);
- }
-#endif
- /* program the scan field to 1 bit length, and ignore it's value */
- scan->fields[field_count].num_bits = 1;
- scan->fields[field_count].out_value = NULL;
- scan->fields[field_count].in_value = NULL;
- field_count++;
- }
- }
-}
-