43 #define UNKNOWN_COMMAND 0x00
44 #define PORT_DIRECTION 0x01
47 #define PORT_SETBIT 0x04
48 #define PORT_GETBIT 0x05
49 #define WRITE_TDI 0x06
51 #define WRITE_AND_READ 0x08
52 #define WRITE_TMS 0x09
53 #define WRITE_TMS_CHAIN 0x0A
98 cmd->cmd.reset->srst);
99 if (
cmd->cmd.reset->trst == 1)
105 cmd->cmd.runtest->num_cycles,
106 cmd->cmd.runtest->end_state);
117 cmd->cmd.pathmove->num_states,
118 cmd->cmd.pathmove->path[
cmd->cmd.pathmove->num_states - 1]);
136 LOG_ERROR(
"BUG: unknown JTAG command type encountered");
152 LOG_ERROR(
"Can't find USB JTAG Interface! Please check connection and permissions.");
156 LOG_INFO(
"USB JTAG Interface ready!");
192 int num_states =
cmd->num_states;
206 true) ==
cmd->path[state_count]) {
211 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP transition",
236 if (num_cycles > 0) {
244 for (i = 0; i < num_cycles; i++) {
323 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
340 const uint16_t vids[] = {
VID, 0 };
341 const uint16_t pids[] = {
PID, 0 };
342 struct libusb_device_handle *dev;
350 libusb_set_configuration(dev, 1);
351 libusb_claim_interface(dev, 0);
352 libusb_set_interface_alt_setting(dev, 0, 0);
370 if ((msg[0] == 2) || (msg[0] == 1) || (msg[0] == 4) || (msg[0] == 0) ||
371 (msg[0] == 6) || (msg[0] == 0x0A) || (msg[0] == 9))
373 if (res ==
ERROR_OK && transferred == msglen) {
376 if (res ==
ERROR_OK && transferred > 0)
377 return (
unsigned char)msg[1];
393 int send_bits, bufindex = 0, fillindex = 0, i, loops;
410 tmp[1] = (char)(send_bits >> 8);
411 tmp[2] = (char)(send_bits);
413 for (i = 0; i < loops; i++) {
414 tmp[3 + i] =
buffer[bufindex];
420 if (res ==
ERROR_OK && transferred == 64) {
430 for (i = 0; i < loops; i++) {
432 buffer[fillindex++] = swap;
441 int send_bits, fillindex = 0, i, loops;
458 tmp[1] = (char)(send_bits >> 8);
459 tmp[2] = (char)(send_bits);
473 for (i = 0; i < loops; i++) {
475 buffer[fillindex++] = swap;
483 int send_bits, bufindex = 0, i, loops;
499 tmp[1] = (char)(send_bits >> 8);
500 tmp[2] = (char)(send_bits);
502 for (i = 0; i < loops; i++) {
503 tmp[3 + i] =
buffer[bufindex];
528 tmp[1] = (char)value;
const char *const jtag_only[]
struct jtag_command * jtag_command_queue
The current queue of jtag_command_s structures.
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
enum scan_type jtag_scan_type(const struct scan_command *cmd)
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
scan_type
The inferred type of a scan_command_s structure, indicating whether the command has the host scan in ...
@ SCAN_IN
From device to host,.
@ SCAN_OUT
From host to device,.
@ SCAN_IO
Full-duplex scan.
static uint8_t output_value
static uint16_t direction
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
tap_state_t tap_state_transition(tap_state_t cur_state, bool tms)
Function tap_state_transition takes a current TAP state and returns the next state according to the t...
const char * tap_state_name(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
void tap_set_end_state(tap_state_t new_end_state)
This function sets the state of an "end state follower" which tracks the state that any cable driver ...
tap_state_t tap_get_end_state(void)
For more information,.
int tap_get_tms_path(tap_state_t from, tap_state_t to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
tap_state_t tap_get_state(void)
This function gets the state of the "state follower" which tracks the state of the TAPs connected to ...
#define tap_set_state(new_state)
This function sets the state of a "state follower" which tracks the state of the TAPs connected to th...
void jtag_sleep(uint32_t us)
#define ERROR_JTAG_QUEUE_FAILED
#define ERROR_JTAG_INIT_FAILED
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
int jtag_libusb_bulk_write(struct libusb_device_handle *dev, int ep, char *bytes, int size, int timeout, int *transferred)
int jtag_libusb_bulk_read(struct libusb_device_handle *dev, int ep, char *bytes, int size, int timeout, int *transferred)
int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[], struct libusb_device_handle **out, adapter_get_alternate_serial_fn adapter_get_alternate_serial)
#define LOG_DEBUG_IO(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static uint32_t bit(uint32_t value, unsigned int b)
size_t size
Size of the control block search area.
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
Represents a driver for a debugging interface.
int(* execute_queue)(void)
Execute queued commands.
struct libusb_device_handle * usb_handle
static struct jtag_interface usbprog_interface
static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value)
static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan)
static struct usbprog_jtag * usbprog_jtag_open(void)
static struct usbprog_jtag * usbprog_jtag_handle
static void usbprog_jtag_tms_collect(char tms_scan)
static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction)
static void usbprog_reset(int trst, int srst)
static void usbprog_write(int tck, int tms, int tdi)
static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
static int usbprog_init(void)
static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
static int tms_chain_index
static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen)
static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag)
static void usbprog_end_state(tap_state_t state)
static char tms_chain[64]
static int usbprog_quit(void)
static void usbprog_state_move(void)
static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value)
static int usbprog_execute_queue(void)
static void usbprog_path_move(struct pathmove_command *cmd)
static void usbprog_runtest(int num_cycles)
static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag)
struct adapter_driver usbprog_adapter_driver