- field++;
- }
- }
-
- /* if a TAP is bypassed, generated a dummy bit*/
- else
- {
-
- field->tap = tap;
- field->num_bits = 1;
- field->out_value = NULL;
- field->in_value = NULL;
-
- field++;
- }
- }
-
- assert(target_tap_match); /* target_tap should be enabled and not bypassed */
-}
-
-
-/**
- * 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, const scan_field_t *in_fields, tap_state_t state)
-{
- int retval;
-
- jtag_prelude(state);
-
- retval=interface_jtag_add_plain_dr_scan(in_num_fields, in_fields, cmd_queue_end_state);
- if (retval!=ERROR_OK)
- jtag_error=retval;
-}
-
-
-/**
- * see jtag_add_plain_dr_scan()
- *
- */
-int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
-{
- 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 * 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;
- 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;
-}
-
-
-void jtag_add_tlr(void)
-{
- jtag_prelude(TAP_RESET);
-
- int retval;
- retval=interface_jtag_add_tlr();
- if (retval!=ERROR_OK)
- jtag_error=retval;
-}
-
-int MINIDRIVER(interface_jtag_add_tlr)(void)
-{
- tap_state_t state = TAP_RESET;
-
- /* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
-
- jtag_queue_command(cmd);
-
- cmd->type = JTAG_STATEMOVE;
-
- cmd->cmd.statemove = cmd_queue_alloc(sizeof(statemove_command_t));
- cmd->cmd.statemove->end_state = state;
-
- return ERROR_OK;
-}
-
-void jtag_add_pathmove(int num_states, const tap_state_t *path)
-{
- tap_state_t cur_state = cmd_queue_cur_state;
- int i;
- int retval;
-
- /* the last state has to be a stable state */
- if (!tap_is_state_stable(path[num_states - 1]))
- {
- LOG_ERROR("BUG: TAP path doesn't finish in a stable state");
- exit(-1);
- }
-
- for (i=0; i<num_states; i++)
- {
- if (path[i] == TAP_RESET)
- {
- LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
- exit(-1);
- }
-
- if ( tap_state_transition(cur_state, true) != path[i]
- && tap_state_transition(cur_state, false) != path[i])
- {
- LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[i]));
- exit(-1);
- }
- cur_state = path[i];
- }
-
- jtag_prelude1();
-
- retval = interface_jtag_add_pathmove(num_states, path);
- cmd_queue_cur_state = path[num_states - 1];
- if (retval!=ERROR_OK)
- jtag_error=retval;
-}
-
-int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, const tap_state_t *path)
-{
- /* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
-
- jtag_queue_command(cmd);
-
- cmd->type = JTAG_PATHMOVE;
-
- cmd->cmd.pathmove = cmd_queue_alloc(sizeof(pathmove_command_t));
- cmd->cmd.pathmove->num_states = num_states;
- cmd->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states);
-
- for (int i = 0; i < num_states; i++)
- cmd->cmd.pathmove->path[i] = path[i];
-
- return ERROR_OK;
-}
-
-int MINIDRIVER(interface_jtag_add_runtest)(int num_cycles, tap_state_t state)
-{
- /* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
-
- jtag_queue_command(cmd);
-
- cmd->type = JTAG_RUNTEST;
-
- cmd->cmd.runtest = cmd_queue_alloc(sizeof(runtest_command_t));
- cmd->cmd.runtest->num_cycles = num_cycles;
- cmd->cmd.runtest->end_state = state;
-
- return ERROR_OK;
-}
-
-void jtag_add_runtest(int num_cycles, tap_state_t state)
-{
- int retval;
-
- jtag_prelude(state);
-
- /* executed by sw or hw fifo */
- retval=interface_jtag_add_runtest(num_cycles, cmd_queue_end_state);
- if (retval!=ERROR_OK)
- jtag_error=retval;
-}
-
-
-int MINIDRIVER(interface_jtag_add_clocks)( int num_cycles )
-{
- /* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
-
- jtag_queue_command(cmd);
-
- cmd->type = JTAG_STABLECLOCKS;
-
- cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(stableclocks_command_t));
- cmd->cmd.stableclocks->num_cycles = num_cycles;
-
- return ERROR_OK;
-}
-
-void jtag_add_clocks( int num_cycles )
-{
- int retval;
-
- if( !tap_is_state_stable(cmd_queue_cur_state) )
- {
- LOG_ERROR( "jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
- tap_state_name(cmd_queue_cur_state) );
- jtag_error = ERROR_JTAG_NOT_STABLE_STATE;
- return;
- }
-
- if( num_cycles > 0 )
- {
- jtag_prelude1();
-
- retval = interface_jtag_add_clocks(num_cycles);
- if (retval != ERROR_OK)
- jtag_error=retval;
- }
-}
-
-void jtag_add_reset(int req_tlr_or_trst, int req_srst)
-{
- int trst_with_tlr = 0;
- int retval;