예제 #1
0
파일: ftdi.c 프로젝트: rjarzmik/openocd
/**
 * 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);
}
예제 #2
0
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
예제 #3
0
파일: xsvf.c 프로젝트: unnamet/estick-jtag
/* xsvf has it's own definition of a statemove. This needs
 * to be handled according to the xsvf spec, which has nothing
 * to do with the JTAG spec or OpenOCD as such.
 *
 * Implemented via jtag_add_pathmove().
 */
static void xsvf_add_statemove(tap_state_t state)
{
	tap_state_t moves[7]; 	/* max # of transitions */
	tap_state_t curstate = cmd_queue_cur_state;
	int i;

	u8 move = tap_get_tms_path(cmd_queue_cur_state, state);

	if (state != TAP_RESET  &&  state==cmd_queue_cur_state)
		return;

	if(state==TAP_RESET)
	{
		jtag_add_tlr();
		return;
	}

	for (i=0; i<7; i++)
	{
		int j = (move >> i) & 1;
		if (j)
		{
			curstate = tap_state_transition(curstate, true);
		}
		else
		{
			curstate = tap_state_transition(curstate, false);
		}
		moves[i] = curstate;
	}

	jtag_add_pathmove(7, moves);
}
예제 #4
0
파일: jlink.c 프로젝트: saeugetier/openocd
/* 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());
}
예제 #5
0
파일: vsllink.c 프로젝트: Bot007/openOCD
/* 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());
}
예제 #6
0
파일: jtag_vpi.c 프로젝트: Bot007/openOCD
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);
}
예제 #7
0
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;
}
예제 #8
0
파일: osbdm.c 프로젝트: FelixVi/openocd
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;
	}