static int osbdm_add_pathmove( struct queue *queue, tap_state_t *path, int num_states) { assert(num_states <= 32); struct sequence *next = queue_add_tail(queue, num_states); if (!next) { LOG_ERROR("BUG: can't allocate bit sequence"); return ERROR_FAIL; } uint32_t tms = 0; for (int i = 0; i < num_states; i++) { if (tap_state_transition(tap_get_state(), 1) == path[i]) { tms |= (1 << i); } else if (tap_state_transition(tap_get_state(), 0) == path[i]) { tms &= ~(1 << i); /* This line not so needed */ } else { LOG_ERROR("BUG: %s -> %s isn't a valid TAP state transition", tap_state_name(tap_get_state()), tap_state_name(path[i])); return ERROR_FAIL; } tap_set_state(path[i]); } buf_set_u32(next->tms, 0, num_states, tms); tap_set_end_state(tap_get_state()); return ERROR_OK; }
static void jlink_end_state(tap_state_t state) { if (tap_is_state_stable(state)) tap_set_end_state(state); else { LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } }
static void ftdi_end_state(tap_state_t state) { if (tap_is_state_stable(state)) tap_set_end_state(state); else { LOG_ERROR("BUG: %s is not a stable end state", tap_state_name(state)); exit(-1); } }
void amt_jtagaccel_end_state(int state) { if (tap_is_state_stable(state)) tap_set_end_state(state); else { LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } }
static int ftdi_execute_pathmove(struct jtag_command *cmd) { int retval = ERROR_OK; tap_state_t *path = cmd->cmd.pathmove->path; int num_states = cmd->cmd.pathmove->num_states; DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states, tap_state_name(tap_get_state()), tap_state_name(path[num_states-1])); int state_count = 0; unsigned bit_count = 0; uint8_t tms_byte = 0; DEBUG_JTAG_IO("-"); /* this loop verifies that the path is legal and logs each state in the path */ while (num_states-- && retval == ERROR_OK) { /* either TMS=0 or TMS=1 must work ... */ if (tap_state_transition(tap_get_state(), false) == path[state_count]) buf_set_u32(&tms_byte, bit_count++, 1, 0x0); else if (tap_state_transition(tap_get_state(), true) == path[state_count]) { buf_set_u32(&tms_byte, bit_count++, 1, 0x1); /* ... or else the caller goofed BADLY */ } else { LOG_ERROR("BUG: %s -> %s isn't a valid " "TAP state transition", tap_state_name(tap_get_state()), tap_state_name(path[state_count])); exit(-1); } tap_set_state(path[state_count]); state_count++; if (bit_count == 7 || num_states == 0) { retval = mpsse_clock_tms_cs_out(mpsse_ctx, &tms_byte, 0, bit_count, false, JTAG_MODE); bit_count = 0; } } tap_set_end_state(tap_get_state()); return retval; }
static void vsllink_path_move(int num_states, tap_state_t *path) { for (int i = 0; i < num_states; i++) { if (path[i] == tap_state_transition(tap_get_state(), false)) vsllink_tap_append_step(0, 0); else if (path[i] == tap_state_transition(tap_get_state(), true)) vsllink_tap_append_step(1, 0); else { LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(path[i])); exit(-1); } tap_set_state(path[i]); } tap_set_end_state(tap_get_state()); }
static void jlink_path_move(int num_states, tap_state_t *path) { int i; uint8_t tms = 0xff; for (i = 0; i < num_states; i++) { if (path[i] == tap_state_transition(tap_get_state(), false)) jlink_clock_data(NULL, 0, NULL, 0, NULL, 0, 1); else if (path[i] == tap_state_transition(tap_get_state(), true)) jlink_clock_data(NULL, 0, &tms, 0, NULL, 0, 1); else { LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition.", tap_state_name(tap_get_state()), tap_state_name(path[i])); exit(-1); } tap_set_state(path[i]); } tap_set_end_state(tap_get_state()); }
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; }
/** * Performs a cJTAG scan * @param cmd contains the JTAG scan command to perform. */ void cjtag_execute_scan(struct jtag_command *cmd) { int i; unsigned char ucTDI = 0; unsigned int ulPreamble = 0; if (cmd->cmd.scan->num_fields != 1) { LOG_ERROR("Unexpected field size of %d", cmd->cmd.scan->num_fields); return; } struct scan_field *field = cmd->cmd.scan->fields; if ((field->num_bits + MAX_PREAMBLE + MAX_POSTAMBLE) > MAX_SUPPORTED_SCAN_LENGTH) { LOG_ERROR("Scan length too long at %d", field->num_bits); return; } ulTxCount = 0; if (cmd->cmd.scan->ir_scan) { if (tap_get_state() != TAP_IRSHIFT) cjtag_move_to_state(TAP_IRSHIFT); } else { if (tap_get_state() != TAP_DRSHIFT) cjtag_move_to_state(TAP_DRSHIFT); } ulPreamble = ulTxCount; tap_set_end_state(cmd->cmd.scan->end_state); for (i = 0; i < field->num_bits - 1; i++) { if (field->out_value) bit_copy(&ucTDI, 0, field->out_value, i, 1); if (ucTDI) send_JTAG(TMS_0 | TDI_1); else send_JTAG(TMS_0 | TDI_0); } if (field->out_value) bit_copy(&ucTDI, 0, field->out_value, i, 1); if (ucTDI) send_JTAG(TMS_1 | TDI_1); else send_JTAG(TMS_1 | TDI_0); if (cmd->cmd.scan->ir_scan) tap_set_state(TAP_IREXIT1); else tap_set_state(TAP_DREXIT1); /* Move to the end state... */ cjtag_move_to_state(cmd->cmd.scan->end_state); /* Perform the scan... */ mpsse_read(local_ctx, pucRxBuffer, field->num_bits + ulTxCount); if (field->in_value) { for (i = 0; i < field->num_bits; i++) { bit_copy(field->in_value, i, (const unsigned char *)&pucRxBuffer[i + ulPreamble], 7, 1); } } }