OpenOCD
usbprog.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2007 by Benedikt Sauter *
5  * sauter@ixbat.de *
6  ***************************************************************************/
7 
8 /*
9  * This file is based on Dominic Rath's amt_jtagaccel.c.
10  *
11  * usbprog is a free programming adapter. You can easily install
12  * different firmware versions from an "online pool" over USB.
13  * The adapter can be used for programming and debugging AVR and ARM
14  * processors, as USB to RS232 converter, as JTAG interface or as
15  * simple I/O interface (5 lines).
16  *
17  * http://www.embedded-projects.net/usbprog
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <jtag/interface.h>
25 #include <jtag/commands.h>
26 #include "libusb_helper.h"
27 
28 #define VID 0x1781
29 #define PID 0x0c63
30 
31 /* Pins at usbprog */
32 #define TDO_BIT 0
33 #define TDI_BIT 3
34 #define TCK_BIT 2
35 #define TMS_BIT 1
36 
38 static void usbprog_state_move(void);
39 static void usbprog_path_move(struct pathmove_command *cmd);
40 static void usbprog_runtest(int num_cycles);
41 static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size);
42 
43 #define UNKNOWN_COMMAND 0x00
44 #define PORT_DIRECTION 0x01
45 #define PORT_SET 0x02
46 #define PORT_GET 0x03
47 #define PORT_SETBIT 0x04
48 #define PORT_GETBIT 0x05
49 #define WRITE_TDI 0x06
50 #define READ_TDO 0x07
51 #define WRITE_AND_READ 0x08
52 #define WRITE_TMS 0x09
53 #define WRITE_TMS_CHAIN 0x0A
54 
55 struct usbprog_jtag {
56  struct libusb_device_handle *usb_handle;
57 };
58 
60 
61 static struct usbprog_jtag *usbprog_jtag_open(void);
62 /* static void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag); */
63 static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag);
64 static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen);
65 
66 static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char *buffer, int size);
67 static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char *buffer, int size);
68 static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char *buffer, int size);
69 static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan);
70 
71 static char tms_chain[64];
72 static int tms_chain_index;
73 
74 static void usbprog_jtag_tms_collect(char tms_scan);
76 
77 static void usbprog_write(int tck, int tms, int tdi);
78 static void usbprog_reset(int trst, int srst);
79 
80 static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction);
81 static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value);
82 /* static unsigned char usbprog_jtag_get_port(struct usbprog_jtag *usbprog_jtag); */
83 static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value);
84 /* static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit); */
85 
86 static int usbprog_execute_queue(void)
87 {
88  struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
89  int scan_size;
90  enum scan_type type;
91  uint8_t *buffer;
92 
93  while (cmd) {
94  switch (cmd->type) {
95  case JTAG_RESET:
96  LOG_DEBUG_IO("reset trst: %i srst %i",
97  cmd->cmd.reset->trst,
98  cmd->cmd.reset->srst);
99  if (cmd->cmd.reset->trst == 1)
101  usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
102  break;
103  case JTAG_RUNTEST:
104  LOG_DEBUG_IO("runtest %i cycles, end in %i",
105  cmd->cmd.runtest->num_cycles,
106  cmd->cmd.runtest->end_state);
107  usbprog_end_state(cmd->cmd.runtest->end_state);
108  usbprog_runtest(cmd->cmd.runtest->num_cycles);
109  break;
110  case JTAG_TLR_RESET:
111  LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
112  usbprog_end_state(cmd->cmd.statemove->end_state);
114  break;
115  case JTAG_PATHMOVE:
116  LOG_DEBUG_IO("pathmove: %i states, end in %i",
117  cmd->cmd.pathmove->num_states,
118  cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
119  usbprog_path_move(cmd->cmd.pathmove);
120  break;
121  case JTAG_SCAN:
122  LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
123  usbprog_end_state(cmd->cmd.scan->end_state);
124  scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
125  type = jtag_scan_type(cmd->cmd.scan);
126  usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
127  if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
129  free(buffer);
130  break;
131  case JTAG_SLEEP:
132  LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
133  jtag_sleep(cmd->cmd.sleep->us);
134  break;
135  default:
136  LOG_ERROR("BUG: unknown JTAG command type encountered");
137  exit(-1);
138  }
139 
140  cmd = cmd->next;
141  }
142 
143  return ERROR_OK;
144 }
145 
146 static int usbprog_init(void)
147 {
149 
150  tms_chain_index = 0;
151  if (usbprog_jtag_handle == 0) {
152  LOG_ERROR("Can't find USB JTAG Interface! Please check connection and permissions.");
153  return ERROR_JTAG_INIT_FAILED;
154  }
155 
156  LOG_INFO("USB JTAG Interface ready!");
157 
159  usbprog_reset(0, 0);
160  usbprog_write(0, 0, 0);
161 
162  return ERROR_OK;
163 }
164 
165 static int usbprog_quit(void)
166 {
167  return ERROR_OK;
168 }
169 
170 /*************** jtag execute commands **********************/
172 {
175  else {
176  LOG_ERROR("BUG: %i is not a valid end state", state);
177  exit(-1);
178  }
179 }
180 
181 static void usbprog_state_move(void)
182 {
183  uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
184 
186 
188 }
189 
191 {
192  int num_states = cmd->num_states;
193  int state_count;
194 
195  /* There may be queued transitions, and before following a specified
196  path, we must flush those queued transitions */
198 
199  state_count = 0;
200  while (num_states) {
201  if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) {
202  /* LOG_INFO("1"); */
203  usbprog_write(0, 0, 0);
204  usbprog_write(1, 0, 0);
205  } else if (tap_state_transition(tap_get_state(),
206  true) == cmd->path[state_count]) {
207  /* LOG_INFO("2"); */
208  usbprog_write(0, 1, 0);
209  usbprog_write(1, 1, 0);
210  } else {
211  LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
213  tap_state_name(cmd->path[state_count]));
214  exit(-1);
215  }
216 
217  tap_set_state(cmd->path[state_count]);
218  state_count++;
219  num_states--;
220  }
221 
223 }
224 
225 static void usbprog_runtest(int num_cycles)
226 {
227  int i;
228 
229  /* only do a state_move when we're not already in IDLE */
230  if (tap_get_state() != TAP_IDLE) {
233  }
234 
235  /* execute num_cycles */
236  if (num_cycles > 0) {
238  usbprog_write(0, 0, 0);
239  } else {
241  /* LOG_INFO("NUM CYCLES %i",num_cycles); */
242  }
243 
244  for (i = 0; i < num_cycles; i++) {
245  usbprog_write(1, 0, 0);
246  usbprog_write(0, 0, 0);
247  }
248 
249  LOG_DEBUG_IO("runtest: cur_state %s end_state %s", tap_state_name(
251 
252  /* finish in end_state */
253  /*
254  usbprog_end_state(saved_end_state);
255  if (tap_get_state() != tap_get_end_state())
256  usbprog_state_move();
257  */
258 }
259 
260 static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
261 {
262  tap_state_t saved_end_state = tap_get_end_state();
263 
264  if (ir_scan)
266  else
268 
269  /* Only move if we're not already there */
270  if (tap_get_state() != tap_get_end_state())
272 
273  usbprog_end_state(saved_end_state);
274 
276 
277  void (*f)(struct usbprog_jtag *usbprog_jtag, char *buffer_local, int size);
278  switch (type) {
279  case SCAN_OUT:
281  break;
282  case SCAN_IN:
284  break;
285  case SCAN_IO:
287  break;
288  default:
289  LOG_ERROR("unknown scan type: %i", type);
290  exit(-1);
291  }
292  f(usbprog_jtag_handle, (char *)buffer, scan_size);
293 
294  /* The adapter does the transition to PAUSE internally */
295  if (ir_scan)
297  else
299 
300  if (tap_get_state() != tap_get_end_state())
302 }
303 
304 /*************** jtag wrapper functions *********************/
305 
306 static void usbprog_write(int tck, int tms, int tdi)
307 {
308  unsigned char output_value = 0x00;
309 
310  if (tms)
311  output_value |= (1 << TMS_BIT);
312  if (tdi)
313  output_value |= (1 << TDI_BIT);
314  if (tck)
315  output_value |= (1 << TCK_BIT);
316 
318 }
319 
320 /* (1) assert or (0) deassert reset lines */
321 static void usbprog_reset(int trst, int srst)
322 {
323  LOG_DEBUG("trst: %i, srst: %i", trst, srst);
324 
325  if (trst)
327  else
329 
330  if (srst)
332  else
334 }
335 
336 /*************** jtag lowlevel functions ********************/
337 
339 {
340  const uint16_t vids[] = { VID, 0 };
341  const uint16_t pids[] = { PID, 0 };
342  struct libusb_device_handle *dev;
343 
344  if (jtag_libusb_open(vids, pids, &dev, NULL) != ERROR_OK)
345  return NULL;
346 
347  struct usbprog_jtag *tmp = malloc(sizeof(struct usbprog_jtag));
348  tmp->usb_handle = dev;
349 
350  libusb_set_configuration(dev, 1);
351  libusb_claim_interface(dev, 0);
352  libusb_set_interface_alt_setting(dev, 0, 0);
353 
354  return tmp;
355 }
356 
357 #if 0
358 static void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag)
359 {
360  libusb_close(usbprog_jtag->usb_handle);
361  free(usbprog_jtag);
362 }
363 #endif
364 
365 static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen)
366 {
367  int transferred;
368 
369  int res = jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, msg, msglen, 100, &transferred);
370  if ((msg[0] == 2) || (msg[0] == 1) || (msg[0] == 4) || (msg[0] == 0) ||
371  (msg[0] == 6) || (msg[0] == 0x0A) || (msg[0] == 9))
372  return 1;
373  if (res == ERROR_OK && transferred == msglen) {
374  /* LOG_INFO("HALLLLOOO %i",(int)msg[0]); */
375  res = jtag_libusb_bulk_read(usbprog_jtag->usb_handle, 0x82, msg, 2, 100, &transferred);
376  if (res == ERROR_OK && transferred > 0)
377  return (unsigned char)msg[1];
378  else
379  return -1;
380  } else
381  return -1;
382  return 0;
383 }
384 
386 {
388 }
389 
391 {
392  char tmp[64]; /* fastest packet size for usb controller */
393  int send_bits, bufindex = 0, fillindex = 0, i, loops;
394 
395  char swap;
396  /* 61 byte can be transferred (488 bit) */
397 
398  while (size > 0) {
399  if (size > 488) {
400  send_bits = 488;
401  size = size - 488;
402  loops = 61;
403  } else {
404  send_bits = size;
405  loops = size / 8;
406  loops++;
407  size = 0;
408  }
409  tmp[0] = WRITE_AND_READ;
410  tmp[1] = (char)(send_bits >> 8); /* high */
411  tmp[2] = (char)(send_bits); /* low */
412 
413  for (i = 0; i < loops; i++) {
414  tmp[3 + i] = buffer[bufindex];
415  bufindex++;
416  }
417 
418  int transferred;
419  int res = jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000, &transferred);
420  if (res == ERROR_OK && transferred == 64) {
421  /* LOG_INFO("HALLLLOOO2 %i",(int)tmp[0]); */
422  usleep(1);
423  int timeout = 0;
424  while (jtag_libusb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 1000, &transferred) != ERROR_OK) {
425  timeout++;
426  if (timeout > 10)
427  break;
428  }
429 
430  for (i = 0; i < loops; i++) {
431  swap = tmp[3 + i];
432  buffer[fillindex++] = swap;
433  }
434  }
435  }
436 }
437 
439 {
440  char tmp[64]; /* fastest packet size for usb controller */
441  int send_bits, fillindex = 0, i, loops;
442 
443  char swap;
444  /* 61 byte can be transferred (488 bit) */
445 
446  while (size > 0) {
447  if (size > 488) {
448  send_bits = 488;
449  size = size - 488;
450  loops = 61;
451  } else {
452  send_bits = size;
453  loops = size / 8;
454  loops++;
455  size = 0;
456  }
457  tmp[0] = WRITE_AND_READ;
458  tmp[1] = (char)(send_bits >> 8); /* high */
459  tmp[2] = (char)(send_bits); /* low */
460 
461  int transferred;
462  jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 3, 1000, &transferred);
463 
464  /* LOG_INFO("HALLLLOOO3 %i",(int)tmp[0]); */
465  int timeout = 0;
466  usleep(1);
467  while (jtag_libusb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 10, &transferred) != ERROR_OK) {
468  timeout++;
469  if (timeout > 10)
470  break;
471  }
472 
473  for (i = 0; i < loops; i++) {
474  swap = tmp[3 + i];
475  buffer[fillindex++] = swap;
476  }
477  }
478 }
479 
481 {
482  char tmp[64]; /* fastest packet size for usb controller */
483  int send_bits, bufindex = 0, i, loops;
484 
485  /* 61 byte can be transferred (488 bit) */
486  while (size > 0) {
487  if (size > 488) {
488  send_bits = 488;
489  size = size - 488;
490  loops = 61;
491  } else {
492  send_bits = size;
493  loops = size/8;
494  /* if (loops == 0) */
495  loops++;
496  size = 0;
497  }
498  tmp[0] = WRITE_TDI;
499  tmp[1] = (char)(send_bits >> 8); /* high */
500  tmp[2] = (char)(send_bits); /* low */
501 
502  for (i = 0; i < loops; i++) {
503  tmp[3 + i] = buffer[bufindex];
504  bufindex++;
505  }
506  int transferred;
507  jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000, &transferred);
508  }
509 }
510 
511 static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan)
512 {
513  usbprog_jtag_tms_collect(tms_scan);
514 }
515 
517 {
518  char tmp[2];
519  tmp[0] = PORT_DIRECTION;
520  tmp[1] = (char)direction;
522 }
523 
524 static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value)
525 {
526  char tmp[2];
527  tmp[0] = PORT_SET;
528  tmp[1] = (char)value;
530 }
531 
532 #if 0
533 static unsigned char usbprog_jtag_get_port(struct usbprog_jtag *usbprog_jtag)
534 {
535  char tmp[2];
536  tmp[0] = PORT_GET;
537  tmp[1] = 0x00;
538  return usbprog_jtag_message(usbprog_jtag, tmp, 2);
539 }
540 #endif
541 
542 static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value)
543 {
544  char tmp[3];
545  tmp[0] = PORT_SETBIT;
546  tmp[1] = (char)bit;
547  if (value == 1)
548  tmp[2] = 0x01;
549  else
550  tmp[2] = 0x00;
552 }
553 
554 #if 0
555 static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit)
556 {
557  char tmp[2];
558  tmp[0] = PORT_GETBIT;
559  tmp[1] = (char)bit;
560 
561  if (usbprog_jtag_message(usbprog_jtag, tmp, 2) > 0)
562  return 1;
563  else
564  return 0;
565 }
566 #endif
567 
568 static void usbprog_jtag_tms_collect(char tms_scan)
569 {
570  tms_chain[tms_chain_index] = tms_scan;
571  tms_chain_index++;
572 }
573 
575 {
576  /* LOG_INFO("TMS SEND"); */
577  if (tms_chain_index > 0) {
578  char tmp[tms_chain_index + 2];
579  tmp[0] = WRITE_TMS_CHAIN;
580  tmp[1] = (char)(tms_chain_index);
581  for (int i = 0; i < tms_chain_index + 1; i++)
582  tmp[2 + i] = tms_chain[i];
583  int transferred;
584  jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, tms_chain_index + 2, 1000, &transferred);
585  tms_chain_index = 0;
586  }
587 }
588 
589 static struct jtag_interface usbprog_interface = {
591 };
592 
594  .name = "usbprog",
595  .transports = jtag_only,
596 
597  .init = usbprog_init,
598  .quit = usbprog_quit,
599 
600  .jtag_ops = &usbprog_interface,
601 };
const char *const jtag_only[]
Definition: adapter.c:31
struct jtag_command * jtag_command_queue
The current queue of jtag_command_s structures.
Definition: commands.c:36
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
Definition: commands.c:189
enum scan_type jtag_scan_type(const struct scan_command *cmd)
Definition: commands.c:162
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
Definition: commands.c:230
scan_type
The inferred type of a scan_command_s structure, indicating whether the command has the host scan in ...
Definition: commands.h:22
@ SCAN_IN
From device to host,.
Definition: commands.h:24
@ SCAN_OUT
From host to device,.
Definition: commands.h:26
@ SCAN_IO
Full-duplex scan.
Definition: commands.h:28
@ JTAG_TLR_RESET
Definition: commands.h:137
@ JTAG_SCAN
Definition: commands.h:129
@ JTAG_PATHMOVE
Definition: commands.h:140
@ JTAG_RUNTEST
Definition: commands.h:138
@ JTAG_SLEEP
Definition: commands.h:141
@ JTAG_RESET
Definition: commands.h:139
static uint8_t output_value
Definition: ep93xx.c:25
uint8_t type
Definition: esp_usb_jtag.c:0
static uint16_t direction
Definition: ftdi.c:119
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
Definition: interface.c:200
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...
Definition: interface.c:223
const char * tap_state_name(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
Definition: interface.c:344
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 ...
Definition: interface.c:48
tap_state_t tap_get_end_state(void)
For more information,.
Definition: interface.c:56
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 ...
Definition: interface.c:190
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 ...
Definition: interface.c:37
#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...
Definition: interface.h:49
void jtag_sleep(uint32_t us)
Definition: jtag/core.c:1062
@ TAP_RESET
Definition: jtag.h:55
@ TAP_DRPAUSE
Definition: jtag.h:43
@ TAP_IRSHIFT
Definition: jtag.h:50
@ TAP_IDLE
Definition: jtag.h:52
@ TAP_DRSHIFT
Definition: jtag.h:42
@ TAP_IRPAUSE
Definition: jtag.h:51
#define ERROR_JTAG_QUEUE_FAILED
Definition: jtag.h:553
#define ERROR_JTAG_INIT_FAILED
Definition: jtag.h:549
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 ...)
Definition: log.h:101
#define LOG_ERROR(expr ...)
Definition: log.h:123
#define LOG_INFO(expr ...)
Definition: log.h:117
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:155
static uint32_t bit(uint32_t value, unsigned int b)
Definition: opcodes.h:15
size_t size
Size of the control block search area.
Definition: rtt/rtt.c:30
Represents a driver for a debugging interface.
Definition: interface.h:207
const char *const name
The name of the interface driver.
Definition: interface.h:209
Represents a driver for a debugging interface.
Definition: interface.h:184
int(* execute_queue)(void)
Execute queued commands.
Definition: interface.h:195
Definition: psoc6.c:84
struct libusb_device_handle * usb_handle
Definition: usbprog.c:56
#define NULL
Definition: usb.h:16
static struct jtag_interface usbprog_interface
Definition: usbprog.c:589
#define WRITE_TMS_CHAIN
Definition: usbprog.c:53
#define PID
Definition: usbprog.c:29
static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
Definition: usbprog.c:260
static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value)
Definition: usbprog.c:542
static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan)
Definition: usbprog.c:511
static struct usbprog_jtag * usbprog_jtag_open(void)
Definition: usbprog.c:338
static struct usbprog_jtag * usbprog_jtag_handle
Definition: usbprog.c:59
static void usbprog_jtag_tms_collect(char tms_scan)
Definition: usbprog.c:568
static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction)
Definition: usbprog.c:516
#define PORT_SETBIT
Definition: usbprog.c:47
static void usbprog_reset(int trst, int srst)
Definition: usbprog.c:321
static void usbprog_write(int tck, int tms, int tdi)
Definition: usbprog.c:306
static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
Definition: usbprog.c:438
static int usbprog_init(void)
Definition: usbprog.c:146
static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
Definition: usbprog.c:390
#define PORT_DIRECTION
Definition: usbprog.c:44
static int tms_chain_index
Definition: usbprog.c:72
#define TDI_BIT
Definition: usbprog.c:33
static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen)
Definition: usbprog.c:365
#define PORT_GET
Definition: usbprog.c:46
static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag)
Definition: usbprog.c:574
#define PORT_GETBIT
Definition: usbprog.c:48
static void usbprog_end_state(tap_state_t state)
Definition: usbprog.c:171
static char tms_chain[64]
Definition: usbprog.c:71
static int usbprog_quit(void)
Definition: usbprog.c:165
static void usbprog_state_move(void)
Definition: usbprog.c:181
#define WRITE_TDI
Definition: usbprog.c:49
#define PORT_SET
Definition: usbprog.c:45
static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
Definition: usbprog.c:480
static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value)
Definition: usbprog.c:524
static int usbprog_execute_queue(void)
Definition: usbprog.c:86
#define TMS_BIT
Definition: usbprog.c:35
#define WRITE_AND_READ
Definition: usbprog.c:51
static void usbprog_path_move(struct pathmove_command *cmd)
Definition: usbprog.c:190
#define TCK_BIT
Definition: usbprog.c:34
static void usbprog_runtest(int num_cycles)
Definition: usbprog.c:225
static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag)
Definition: usbprog.c:385
#define VID
Definition: usbprog.c:28
struct adapter_driver usbprog_adapter_driver
Definition: usbprog.c:593
uint8_t cmd
Definition: vdebug.c:1
uint8_t state[4]
Definition: vdebug.c:21