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 unsigned int num_states =
cmd->num_states;
206 true) ==
cmd->path[state_count]) {
211 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP transition",
234 if (num_cycles > 0) {
242 for (
unsigned int i = 0; i < num_cycles; i++) {
321 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
338 const uint16_t vids[] = {
VID, 0 };
339 const uint16_t pids[] = {
PID, 0 };
340 struct libusb_device_handle *dev;
348 libusb_set_configuration(dev, 1);
349 libusb_claim_interface(dev, 0);
350 libusb_set_interface_alt_setting(dev, 0, 0);
368 if ((msg[0] == 2) || (msg[0] == 1) || (msg[0] == 4) || (msg[0] == 0) ||
369 (msg[0] == 6) || (msg[0] == 0x0A) || (msg[0] == 9))
371 if (res ==
ERROR_OK && transferred == msglen) {
374 if (res ==
ERROR_OK && transferred > 0)
375 return (
unsigned char)msg[1];
391 int send_bits, bufindex = 0, fillindex = 0, i, loops;
408 tmp[1] = (char)(send_bits >> 8);
409 tmp[2] = (char)(send_bits);
411 for (i = 0; i < loops; i++) {
412 tmp[3 + i] =
buffer[bufindex];
418 if (res ==
ERROR_OK && transferred == 64) {
428 for (i = 0; i < loops; i++) {
430 buffer[fillindex++] = swap;
439 int send_bits, fillindex = 0, i, loops;
456 tmp[1] = (char)(send_bits >> 8);
457 tmp[2] = (char)(send_bits);
471 for (i = 0; i < loops; i++) {
473 buffer[fillindex++] = swap;
481 int send_bits, bufindex = 0, i, loops;
497 tmp[1] = (char)(send_bits >> 8);
498 tmp[2] = (char)(send_bits);
500 for (i = 0; i < loops; i++) {
501 tmp[3 + i] =
buffer[bufindex];
526 tmp[1] = (char)value;
const char *const jtag_only[]
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 structure, indicating whether the command has the host scan in fr...
@ 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_open(const uint16_t vids[], const uint16_t pids[], const char *product, struct libusb_device_handle **out, adapter_get_alternate_serial_fn adapter_get_alternate_serial)
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)
#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)(struct jtag_command *cmd_queue)
Execute commands in the supplied queue.
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 int usbprog_execute_queue(struct jtag_command *cmd_queue)
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 void usbprog_runtest(unsigned int num_cycles)
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 void usbprog_path_move(struct pathmove_command *cmd)
static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag)
struct adapter_driver usbprog_adapter_driver