/** * Function move_to_state * moves the TAP controller from the current state to a * \a goal_state through a path given by tap_get_tms_path(). State transition * logging is performed by delegation to clock_tms(). * * @param goal_state is the destination state for the move. */ static void move_to_state(tap_state_t goal_state) { tap_state_t start_state = tap_get_state(); /* goal_state is 1/2 of a tuple/pair of states which allow convenient lookup of the required TMS pattern to move to this state from the start state. */ /* do the 2 lookups */ int tms_bits = tap_get_tms_path(start_state, goal_state); int tms_count = tap_get_tms_path_len(start_state, goal_state); DEBUG_JTAG_IO("start=%s goal=%s", tap_state_name(start_state), tap_state_name(goal_state)); /* Track state transitions step by step */ for (int i = 0; i < tms_count; i++) tap_set_state(tap_state_transition(tap_get_state(), (tms_bits >> i) & 1)); mpsse_clock_tms_cs_out(mpsse_ctx, (uint8_t *)&tms_bits, 0, tms_count, false, JTAG_MODE); }
int jtag_add_statemove(tap_state_t goal_state) { tap_state_t cur_state = cmd_queue_cur_state; if (goal_state != cur_state) { LOG_DEBUG("cur_state=%s goal_state=%s", tap_state_name(cur_state), tap_state_name(goal_state)); } /* If goal is RESET, be paranoid and force that that transition * (e.g. five TCK cycles, TMS high). Else trust "cur_state". */ if (goal_state == TAP_RESET) jtag_add_tlr(); else if (goal_state == cur_state) /* nothing to do */; else if (tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state)) { unsigned tms_bits = tap_get_tms_path(cur_state, goal_state); unsigned tms_count = tap_get_tms_path_len(cur_state, goal_state); tap_state_t moves[8]; assert(tms_count < ARRAY_SIZE(moves)); for (unsigned i = 0; i < tms_count; i++, tms_bits >>= 1) { bool bit = tms_bits & 1; cur_state = tap_state_transition(cur_state, bit); moves[i] = cur_state; } jtag_add_pathmove(tms_count, moves); } else if (tap_state_transition(cur_state, true) == goal_state
static int ftdi_initialize(void) { int retval; if (tap_get_tms_path_len(TAP_IRPAUSE, TAP_IRPAUSE) == 7) LOG_DEBUG("ftdi interface using 7 step jtag state transitions"); else LOG_DEBUG("ftdi interface using shortest path jtag state transitions"); for (int i = 0; ftdi_vid[i] || ftdi_pid[i]; i++) { mpsse_ctx = mpsse_open(&ftdi_vid[i], &ftdi_pid[i], ftdi_device_desc, ftdi_serial, ftdi_channel); if (mpsse_ctx) break; } if (!mpsse_ctx) return ERROR_JTAG_INIT_FAILED; retval = mpsse_set_data_bits_low_byte(mpsse_ctx, output & 0xff, direction & 0xff); if (retval == ERROR_OK) retval = mpsse_set_data_bits_high_byte(mpsse_ctx, output >> 8, direction >> 8); if (retval != ERROR_OK) { LOG_ERROR("couldn't initialize FTDI with 'JTAGkey' layout"); return ERROR_JTAG_INIT_FAILED; } retval = mpsse_loopback_config(mpsse_ctx, false); if (retval != ERROR_OK) { LOG_ERROR("couldn't write to FTDI to disable loopback"); return ERROR_JTAG_INIT_FAILED; } return mpsse_flush(mpsse_ctx); }
/* Goes to the end state. */ static void jlink_state_move(void) { uint8_t tms_scan; uint8_t tms_scan_bits; tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); tms_scan_bits = tap_get_tms_path_len(tap_get_state(), tap_get_end_state()); jlink_clock_data(NULL, 0, &tms_scan, 0, NULL, 0, tms_scan_bits); tap_set_state(tap_get_end_state()); }
/* Goes to the end state. */ static void vsllink_state_move(void) { int i; uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); uint8_t tms_scan_bits = tap_get_tms_path_len(tap_get_state(), tap_get_end_state()); for (i = 0; i < tms_scan_bits; i++) vsllink_tap_append_step((tms_scan >> i) & 1, 0); tap_set_state(tap_get_end_state()); }
static void jtag_vpi_state_move(tap_state_t state) { uint8_t tms_scan; int tms_len; LOG_DEBUG("jtag_vpi_state_move: (from %s to %s)", tap_state_name(tap_get_state()), tap_state_name(state)); if (tap_get_state() == state) return; tms_scan = tap_get_tms_path(tap_get_state(), state); tms_len = tap_get_tms_path_len(tap_get_state(), state); jtag_vpi_tms_seq(&tms_scan, tms_len); tap_set_state(state); }
static int usbp5_state_move(tap_state_t state) { if (tap_get_state() == state) return ERROR_OK; uint8_t tms_scan = tap_get_tms_path(tap_get_state(), state); int tms_len = tap_get_tms_path_len(tap_get_state(), state); int retval = usbp5_tms_seq(&tms_scan, tms_len); if (retval != ERROR_OK) return retval; tap_set_state(state); return ERROR_OK; }
static int osbdm_add_statemove( struct queue *queue, tap_state_t new_state, int skip_first) { int len = 0; int tms = 0; tap_set_end_state(new_state); if (tap_get_end_state() == TAP_RESET) { /* Ignore current state */ tms = 0xff; len = 5; } else if (tap_get_state() != tap_get_end_state()) { tms = tap_get_tms_path(tap_get_state(), new_state); len = tap_get_tms_path_len(tap_get_state(), new_state); } if (len && skip_first) { len--; tms >>= 1; }