OpenOCD
xlnx-pcie-xvc.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 /*
4  * Copyright (c) 2019 Google, LLC.
5  * Author: Moritz Fischer <moritzf@google.com>
6  */
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <stdint.h>
13 #include <stdlib.h>
14 #include <math.h>
15 #include <unistd.h>
16 #include <linux/pci.h>
17 
18 #include <jtag/interface.h>
19 #include <jtag/swd.h>
20 #include <jtag/commands.h>
21 #include <helper/replacements.h>
22 #include <helper/bits.h>
23 
24 /* Available only from kernel v4.10 */
25 #ifndef PCI_CFG_SPACE_EXP_SIZE
26 #define PCI_CFG_SPACE_EXP_SIZE 4096
27 #endif
28 
29 #define PCIE_EXT_CAP_LST 0x100
30 
31 #define XLNX_XVC_EXT_CAP 0x00
32 #define XLNX_XVC_VSEC_HDR 0x04
33 #define XLNX_XVC_LEN_REG 0x0C
34 #define XLNX_XVC_TMS_REG 0x10
35 #define XLNX_XVC_TDX_REG 0x14
36 
37 #define XLNX_XVC_CAP_SIZE 0x20
38 #define XLNX_XVC_VSEC_ID 0x8
39 #define XLNX_XVC_MAX_BITS 0x20
40 
41 #define MASK_ACK(x) (((x) >> 9) & 0x7)
42 #define MASK_PAR(x) ((int)((x) & 0x1))
43 
44 struct xlnx_pcie_xvc {
45  int fd;
46  unsigned int offset;
47  char *device;
48 };
49 
52 
53 static int xlnx_pcie_xvc_read_reg(const int offset, uint32_t *val)
54 {
55  uint32_t res;
56  int err;
57 
58  /* Note: This should be ok endianness-wise because by going
59  * through sysfs the kernel does the conversion in the config
60  * space accessor functions
61  */
62  err = pread(xlnx_pcie_xvc->fd, &res, sizeof(res),
64  if (err != sizeof(res)) {
65  LOG_ERROR("Failed to read offset %x", offset);
67  }
68 
69  if (val)
70  *val = res;
71 
72  return ERROR_OK;
73 }
74 
75 static int xlnx_pcie_xvc_write_reg(const int offset, const uint32_t val)
76 {
77  int err;
78 
79  /* Note: This should be ok endianness-wise because by going
80  * through sysfs the kernel does the conversion in the config
81  * space accessor functions
82  */
83  err = pwrite(xlnx_pcie_xvc->fd, &val, sizeof(val),
85  if (err != sizeof(val)) {
86  LOG_ERROR("Failed to write offset: %x with value: %" PRIx32,
87  offset, val);
89  }
90 
91  return ERROR_OK;
92 }
93 
94 static int xlnx_pcie_xvc_transact(size_t num_bits, uint32_t tms, uint32_t tdi,
95  uint32_t *tdo)
96 {
97  int err;
98 
100  if (err != ERROR_OK)
101  return err;
102 
104  if (err != ERROR_OK)
105  return err;
106 
108  if (err != ERROR_OK)
109  return err;
110 
112  if (err != ERROR_OK)
113  return err;
114 
115  if (tdo)
116  LOG_DEBUG_IO("Transact num_bits: %zu, tms: %" PRIx32 ", tdi: %" PRIx32 ", tdo: %" PRIx32,
117  num_bits, tms, tdi, *tdo);
118  else
119  LOG_DEBUG_IO("Transact num_bits: %zu, tms: %" PRIx32 ", tdi: %" PRIx32 ", tdo: <null>",
120  num_bits, tms, tdi);
121  return ERROR_OK;
122 }
123 
125 {
126  int tms = tap_get_state() == TAP_RESET ? 1 : 0;
127  size_t left = cmd->cmd.stableclocks->num_cycles;
128  size_t write;
129  int err;
130 
131  LOG_DEBUG("stableclocks %u cycles", cmd->cmd.runtest->num_cycles);
132 
133  while (left) {
134  write = MIN(XLNX_XVC_MAX_BITS, left);
135  err = xlnx_pcie_xvc_transact(write, tms, 0, NULL);
136  if (err != ERROR_OK)
137  return err;
138  left -= write;
139  };
140 
141  return ERROR_OK;
142 }
143 
144 static int xlnx_pcie_xvc_execute_statemove(size_t skip)
145 {
146  uint8_t tms_scan = tap_get_tms_path(tap_get_state(),
148  int tms_count = tap_get_tms_path_len(tap_get_state(),
150  int err;
151 
152  LOG_DEBUG("statemove starting at (skip: %zu) %s end in %s", skip,
155 
156 
157  err = xlnx_pcie_xvc_transact(tms_count - skip, tms_scan >> skip, 0, NULL);
158  if (err != ERROR_OK)
159  return err;
160 
162 
163  return ERROR_OK;
164 }
165 
167 {
168  int err = ERROR_OK;
169 
170  LOG_DEBUG("runtest %u cycles, end in %i",
171  cmd->cmd.runtest->num_cycles,
172  cmd->cmd.runtest->end_state);
173 
174  tap_state_t tmp_state = tap_get_end_state();
175 
176  if (tap_get_state() != TAP_IDLE) {
179  if (err != ERROR_OK)
180  return err;
181  };
182 
183  size_t left = cmd->cmd.runtest->num_cycles;
184  size_t write;
185 
186  while (left) {
187  write = MIN(XLNX_XVC_MAX_BITS, left);
188  err = xlnx_pcie_xvc_transact(write, 0, 0, NULL);
189  if (err != ERROR_OK)
190  return err;
191  left -= write;
192  };
193 
194  tap_set_end_state(tmp_state);
195  if (tap_get_state() != tap_get_end_state())
197 
198  return err;
199 }
200 
202 {
203  unsigned int num_states = cmd->cmd.pathmove->num_states;
204  tap_state_t *path = cmd->cmd.pathmove->path;
205  int err = ERROR_OK;
206 
207  LOG_DEBUG("pathmove: %u states, end in %i",
208  cmd->cmd.pathmove->num_states,
209  cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
210 
211  for (unsigned int i = 0; i < num_states; i++) {
212  if (path[i] == tap_state_transition(tap_get_state(), false)) {
213  err = xlnx_pcie_xvc_transact(1, 1, 0, NULL);
214  } else if (path[i] == tap_state_transition(tap_get_state(), true)) {
215  err = xlnx_pcie_xvc_transact(1, 0, 0, NULL);
216  } else {
217  LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition.",
219  tap_state_name(path[i]));
221  }
222  if (err != ERROR_OK)
223  return err;
224  tap_set_state(path[i]);
225  }
226 
228 
229  return ERROR_OK;
230 }
231 
233 {
234  enum scan_type type = jtag_scan_type(cmd->cmd.scan);
235  tap_state_t saved_end_state = cmd->cmd.scan->end_state;
236  bool ir_scan = cmd->cmd.scan->ir_scan;
237  uint32_t tdi, tms, tdo;
238  uint8_t *buf, *rd_ptr;
239  int err, scan_size;
240  size_t write;
241  size_t left;
242 
243  scan_size = jtag_build_buffer(cmd->cmd.scan, &buf);
244  rd_ptr = buf;
245  LOG_DEBUG("%s scan type %d %d bits; starts in %s end in %s",
246  (cmd->cmd.scan->ir_scan) ? "IR" : "DR", type, scan_size,
248  tap_state_name(cmd->cmd.scan->end_state));
249 
250  /* If we're in TAP_DR_SHIFT state but need to do a IR_SCAN or
251  * vice-versa, do a statemove to corresponding other state, then restore
252  * end state
253  */
254  if (ir_scan && tap_get_state() != TAP_IRSHIFT) {
257  if (err != ERROR_OK)
258  goto out_err;
259  tap_set_end_state(saved_end_state);
260  } else if (!ir_scan && (tap_get_state() != TAP_DRSHIFT)) {
263  if (err != ERROR_OK)
264  goto out_err;
265  tap_set_end_state(saved_end_state);
266  }
267 
268  left = scan_size;
269  while (left) {
270  write = MIN(XLNX_XVC_MAX_BITS, left);
271  /* the last TMS should be a 1, to leave the state */
272  tms = left <= XLNX_XVC_MAX_BITS ? BIT(write - 1) : 0;
273  tdi = (type != SCAN_IN) ? buf_get_u32(rd_ptr, 0, write) : 0;
274  err = xlnx_pcie_xvc_transact(write, tms, tdi, type != SCAN_OUT ?
275  &tdo : NULL);
276  if (err != ERROR_OK)
277  goto out_err;
278  left -= write;
279  if (type != SCAN_OUT)
280  buf_set_u32(rd_ptr, 0, write, tdo);
281  rd_ptr += sizeof(uint32_t);
282  };
283 
284  err = jtag_read_buffer(buf, cmd->cmd.scan);
285  free(buf);
286 
287  if (tap_get_state() != tap_get_end_state())
289 
290  return err;
291 
292 out_err:
293  free(buf);
294  return err;
295 }
296 
298 {
299  LOG_DEBUG("reset trst: %i srst: %i", cmd->cmd.reset->trst,
300  cmd->cmd.reset->srst);
301 }
302 
304 {
305  LOG_DEBUG("sleep %" PRIu32 "", cmd->cmd.sleep->us);
306  usleep(cmd->cmd.sleep->us);
307 }
308 
310 {
311  const size_t num_bits = cmd->cmd.tms->num_bits;
312  const uint8_t *bits = cmd->cmd.tms->bits;
313  size_t left, write;
314  uint32_t tms;
315  int err;
316 
317  LOG_DEBUG("execute tms %zu", num_bits);
318 
319  left = num_bits;
320  while (left) {
321  write = MIN(XLNX_XVC_MAX_BITS, left);
322  tms = buf_get_u32(bits, 0, write);
323  err = xlnx_pcie_xvc_transact(write, tms, 0, NULL);
324  if (err != ERROR_OK)
325  return err;
326  left -= write;
327  bits += 4;
328  };
329 
330  return ERROR_OK;
331 }
332 
334 {
335  LOG_DEBUG("%s: cmd->type: %u", __func__, cmd->type);
336  switch (cmd->type) {
337  case JTAG_STABLECLOCKS:
339  case JTAG_RUNTEST:
341  case JTAG_TLR_RESET:
342  tap_set_end_state(cmd->cmd.statemove->end_state);
344  case JTAG_PATHMOVE:
346  case JTAG_SCAN:
348  case JTAG_RESET:
350  break;
351  case JTAG_SLEEP:
353  break;
354  case JTAG_TMS:
356  default:
357  LOG_ERROR("BUG: Unknown JTAG command type encountered.");
359  }
360 
361  return ERROR_OK;
362 }
363 
364 static int xlnx_pcie_xvc_execute_queue(struct jtag_command *cmd_queue)
365 {
366  struct jtag_command *cmd = cmd_queue;
367  int ret;
368 
369  while (cmd) {
371 
372  if (ret != ERROR_OK)
373  return ret;
374 
375  cmd = cmd->next;
376  }
377 
378  return ERROR_OK;
379 }
380 
381 
382 static int xlnx_pcie_xvc_init(void)
383 {
384  char filename[PATH_MAX];
385  uint32_t cap, vh;
386  int err;
387 
388  snprintf(filename, PATH_MAX, "/sys/bus/pci/devices/%s/config",
390  xlnx_pcie_xvc->fd = open(filename, O_RDWR | O_SYNC);
391  if (xlnx_pcie_xvc->fd < 0) {
392  LOG_ERROR("Failed to open device: %s", filename);
393  return ERROR_JTAG_INIT_FAILED;
394  }
395 
396  LOG_INFO("Scanning PCIe device %s's for Xilinx XVC/PCIe ...",
398  /* Parse the PCIe extended capability list and try to find
399  * vendor specific header */
401  while (xlnx_pcie_xvc->offset <= PCI_CFG_SPACE_EXP_SIZE - sizeof(cap) &&
404  if (err != ERROR_OK)
405  return err;
406  LOG_DEBUG("Checking capability at 0x%x; id=0x%04" PRIx32 " version=0x%" PRIx32 " next=0x%" PRIx32,
408  PCI_EXT_CAP_ID(cap),
409  PCI_EXT_CAP_VER(cap),
410  PCI_EXT_CAP_NEXT(cap));
411  if (PCI_EXT_CAP_ID(cap) == PCI_EXT_CAP_ID_VNDR) {
413  if (err != ERROR_OK)
414  return err;
415  LOG_DEBUG("Checking possible match at 0x%x; id: 0x%" PRIx32 "; rev: 0x%" PRIx32 "; length: 0x%" PRIx32,
417  PCI_VNDR_HEADER_ID(vh),
418  PCI_VNDR_HEADER_REV(vh),
419  PCI_VNDR_HEADER_LEN(vh));
420  if ((PCI_VNDR_HEADER_ID(vh) == XLNX_XVC_VSEC_ID) &&
421  (PCI_VNDR_HEADER_LEN(vh) == XLNX_XVC_CAP_SIZE))
422  break;
423  }
424  xlnx_pcie_xvc->offset = PCI_EXT_CAP_NEXT(cap);
425  }
428  close(xlnx_pcie_xvc->fd);
429  return ERROR_JTAG_INIT_FAILED;
430  }
431 
432  LOG_INFO("Found Xilinx XVC/PCIe capability at offset: 0x%x", xlnx_pcie_xvc->offset);
433 
434  return ERROR_OK;
435 }
436 
437 static int xlnx_pcie_xvc_quit(void)
438 {
439  int err;
440 
441  err = close(xlnx_pcie_xvc->fd);
442  if (err)
443  return err;
444 
445  return ERROR_OK;
446 }
447 
448 COMMAND_HANDLER(xlnx_pcie_xvc_handle_config_command)
449 {
450  if (CMD_ARGC < 1)
452 
453  /* we can't really free this in a safe manner, so at least
454  * limit the memory we're leaking by freeing the old one first
455  * before allocating a new one ...
456  */
457  free(xlnx_pcie_xvc->device);
458 
459  xlnx_pcie_xvc->device = strdup(CMD_ARGV[0]);
460  return ERROR_OK;
461 }
462 
464  {
465  .name = "config",
466  .handler = xlnx_pcie_xvc_handle_config_command,
467  .mode = COMMAND_CONFIG,
468  .help = "Configure XVC/PCIe JTAG adapter",
469  .usage = "device",
470  },
472 };
473 
475  {
476  .name = "xlnx_pcie_xvc",
477  .mode = COMMAND_ANY,
478  .help = "perform xlnx_pcie_xvc management",
480  .usage = "",
481  },
483 };
484 
485 static struct jtag_interface xlnx_pcie_xvc_jtag_ops = {
487 };
488 
489 static int xlnx_pcie_xvc_swd_sequence(const uint8_t *seq, size_t length)
490 {
491  size_t left, write;
492  uint32_t send;
493  int err;
494 
495  left = length;
496  while (left) {
497  write = MIN(XLNX_XVC_MAX_BITS, left);
498  send = buf_get_u32(seq, 0, write);
499  err = xlnx_pcie_xvc_transact(write, send, 0, NULL);
500  if (err != ERROR_OK)
501  return err;
502  left -= write;
503  seq += sizeof(uint32_t);
504  };
505 
506  return ERROR_OK;
507 }
508 
510 {
511  switch (seq) {
512  case LINE_RESET:
513  LOG_DEBUG("SWD line reset");
516  case JTAG_TO_SWD:
517  LOG_DEBUG("JTAG-to-SWD");
520  case SWD_TO_JTAG:
521  LOG_DEBUG("SWD-to-JTAG");
524  default:
525  LOG_ERROR("Sequence %d not supported", seq);
526  return ERROR_FAIL;
527  }
528 
529  return ERROR_OK;
530 }
531 
532 static int queued_retval;
533 
534 static void xlnx_pcie_xvc_swd_write_reg(uint8_t cmd, uint32_t value,
535  uint32_t ap_delay_clk);
536 
537 static void swd_clear_sticky_errors(void)
538 {
541 }
542 
543 static void xlnx_pcie_xvc_swd_read_reg(uint8_t cmd, uint32_t *value,
544  uint32_t ap_delay_clk)
545 {
546  uint32_t res, ack, rpar;
547  int err;
548 
549  assert(cmd & SWD_CMD_RNW);
550 
552  /* cmd + ack */
553  err = xlnx_pcie_xvc_transact(12, cmd, 0, &res);
554  if (err != ERROR_OK)
555  goto err_out;
556 
557  ack = MASK_ACK(res);
558 
559  /* read data */
560  err = xlnx_pcie_xvc_transact(32, 0, 0, &res);
561  if (err != ERROR_OK)
562  goto err_out;
563 
564  /* parity + trn */
565  err = xlnx_pcie_xvc_transact(2, 0, 0, &rpar);
566  if (err != ERROR_OK)
567  goto err_out;
568 
569  LOG_DEBUG("%s %s %s reg %X = %08"PRIx32,
570  ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ?
571  "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK",
572  cmd & SWD_CMD_APNDP ? "AP" : "DP",
573  cmd & SWD_CMD_RNW ? "read" : "write",
574  (cmd & SWD_CMD_A32) >> 1,
575  res);
576  switch (ack) {
577  case SWD_ACK_OK:
578  if (MASK_PAR(rpar) != parity_u32(res)) {
579  LOG_DEBUG_IO("Wrong parity detected");
581  return;
582  }
583  if (value)
584  *value = res;
585  if (cmd & SWD_CMD_APNDP)
586  err = xlnx_pcie_xvc_transact(ap_delay_clk, 0, 0, NULL);
587  queued_retval = err;
588  return;
589  case SWD_ACK_WAIT:
590  LOG_DEBUG_IO("SWD_ACK_WAIT");
592  return;
593  case SWD_ACK_FAULT:
594  LOG_DEBUG_IO("SWD_ACK_FAULT");
595  queued_retval = ack;
596  return;
597  default:
598  LOG_DEBUG_IO("No valid acknowledge: ack=%02"PRIx32, ack);
599  queued_retval = ack;
600  return;
601  }
602 err_out:
603  queued_retval = err;
604 }
605 
606 static void xlnx_pcie_xvc_swd_write_reg(uint8_t cmd, uint32_t value,
607  uint32_t ap_delay_clk)
608 {
609  uint32_t res, ack;
610  int err;
611 
612  assert(!(cmd & SWD_CMD_RNW));
613 
615  /* cmd + trn + ack */
616  err = xlnx_pcie_xvc_transact(13, cmd, 0, &res);
617  if (err != ERROR_OK)
618  goto err_out;
619 
620  ack = MASK_ACK(res);
621 
622  /* write data */
623  err = xlnx_pcie_xvc_transact(32, value, 0, NULL);
624  if (err != ERROR_OK)
625  goto err_out;
626 
627  /* parity + trn */
628  err = xlnx_pcie_xvc_transact(2, parity_u32(value), 0, NULL);
629  if (err != ERROR_OK)
630  goto err_out;
631 
632  LOG_DEBUG("%s %s %s reg %X = %08"PRIx32,
633  ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ?
634  "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK",
635  cmd & SWD_CMD_APNDP ? "AP" : "DP",
636  cmd & SWD_CMD_RNW ? "read" : "write",
637  (cmd & SWD_CMD_A32) >> 1,
638  value);
639 
640  switch (ack) {
641  case SWD_ACK_OK:
642  if (cmd & SWD_CMD_APNDP)
643  err = xlnx_pcie_xvc_transact(ap_delay_clk, 0, 0, NULL);
644  queued_retval = err;
645  return;
646  case SWD_ACK_WAIT:
647  LOG_DEBUG_IO("SWD_ACK_WAIT");
649  return;
650  case SWD_ACK_FAULT:
651  LOG_DEBUG_IO("SWD_ACK_FAULT");
652  queued_retval = ack;
653  return;
654  default:
655  LOG_DEBUG_IO("No valid acknowledge: ack=%02"PRIx32, ack);
656  queued_retval = ack;
657  return;
658  }
659 
660 err_out:
661  queued_retval = err;
662 }
663 
665 {
666  int err;
667 
668  /* we want at least 8 idle cycles between each transaction */
669  err = xlnx_pcie_xvc_transact(8, 0, 0, NULL);
670  if (err != ERROR_OK)
671  return err;
672 
673  err = queued_retval;
675  LOG_DEBUG("SWD queue return value: %02x", err);
676 
677  return err;
678 }
679 
680 static int xlnx_pcie_xvc_swd_init(void)
681 {
682  return ERROR_OK;
683 }
684 
685 static const struct swd_driver xlnx_pcie_xvc_swd_ops = {
687  .switch_seq = xlnx_pcie_xvc_swd_switch_seq,
688  .read_reg = xlnx_pcie_xvc_swd_read_reg,
689  .write_reg = xlnx_pcie_xvc_swd_write_reg,
691 };
692 
693 static const char * const xlnx_pcie_xvc_transports[] = { "jtag", "swd", NULL };
694 
696  .name = "xlnx_pcie_xvc",
697  .transports = xlnx_pcie_xvc_transports,
698  .commands = xlnx_pcie_xvc_command_handlers,
699 
700  .init = &xlnx_pcie_xvc_init,
701  .quit = &xlnx_pcie_xvc_quit,
702 
703  .jtag_ops = &xlnx_pcie_xvc_jtag_ops,
704  .swd_ops = &xlnx_pcie_xvc_swd_ops,
705 };
#define SWD_ACK_FAULT
Definition: arm_adi_v5.h:33
#define DP_ABORT
Definition: arm_adi_v5.h:46
#define WDERRCLR
Definition: arm_adi_v5.h:71
#define STKERRCLR
Definition: arm_adi_v5.h:70
#define ORUNERRCLR
Definition: arm_adi_v5.h:72
#define STKCMPCLR
Definition: arm_adi_v5.h:69
swd_special_seq
Definition: arm_adi_v5.h:236
@ JTAG_TO_SWD
Definition: arm_adi_v5.h:238
@ LINE_RESET
Definition: arm_adi_v5.h:237
@ SWD_TO_JTAG
Definition: arm_adi_v5.h:240
#define SWD_ACK_WAIT
Definition: arm_adi_v5.h:32
#define SWD_ACK_OK
Definition: arm_adi_v5.h:31
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
Definition: binarybuffer.h:104
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:34
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
Definition: commands.c:192
enum scan_type jtag_scan_type(const struct scan_command *cmd)
Definition: commands.c:167
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 structure, indicating whether the command has the host scan in fr...
Definition: commands.h:22
@ SCAN_IN
From device to host,.
Definition: commands.h:24
@ SCAN_OUT
From host to device,.
Definition: commands.h:26
@ JTAG_TLR_RESET
Definition: commands.h:137
@ JTAG_SCAN
Definition: commands.h:129
@ JTAG_PATHMOVE
Definition: commands.h:140
@ JTAG_STABLECLOCKS
Definition: commands.h:142
@ JTAG_RUNTEST
Definition: commands.h:138
@ JTAG_SLEEP
Definition: commands.h:141
@ JTAG_RESET
Definition: commands.h:139
@ JTAG_TMS
Definition: commands.h:143
uint8_t type
Definition: esp_usb_jtag.c:0
uint8_t length
Definition: esp_usb_jtag.c:1
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
int tap_get_tms_path_len(tap_state_t from, tap_state_t to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
Definition: interface.c:195
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
#define ERROR_JTAG_DEVICE_ERROR
Definition: jtag.h:559
@ TAP_RESET
Definition: jtag.h:56
@ TAP_IRSHIFT
Definition: jtag.h:51
@ TAP_IDLE
Definition: jtag.h:53
@ TAP_DRSHIFT
Definition: jtag.h:43
#define ERROR_JTAG_QUEUE_FAILED
Definition: jtag.h:557
#define ERROR_JTAG_INIT_FAILED
Definition: jtag.h:553
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
#define LOG_DEBUG_IO(expr ...)
Definition: log.h:101
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_INFO(expr ...)
Definition: log.h:126
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
uint8_t bits[QN908X_FLASH_MAX_BLOCKS *QN908X_FLASH_PAGES_PER_BLOCK/8]
Definition: qn908x.c:0
#define MIN(a, b)
Definition: replacements.h:22
#define BIT(nr)
Definition: stm32l4x.h:18
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
const char * name
Definition: command.h:235
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241
Represents a driver for a debugging interface.
Definition: interface.h:182
int(* execute_queue)(struct jtag_command *cmd_queue)
Execute commands in the supplied queue.
Definition: interface.h:195
int(* init)(void)
Initialize the debug link so it can perform SWD operations.
Definition: swd.h:255
unsigned int offset
Definition: xlnx-pcie-xvc.c:46
#define SWD_CMD_A32
Definition: swd.h:19
#define SWD_CMD_PARK
Definition: swd.h:22
static uint8_t swd_cmd(bool is_read, bool is_ap, uint8_t regnum)
Construct a "cmd" byte, in lSB bit order, which swd_driver.read_reg() and swd_driver....
Definition: swd.h:35
static const unsigned int swd_seq_jtag_to_swd_len
Definition: swd.h:125
static const unsigned int swd_seq_line_reset_len
Definition: swd.h:104
#define SWD_CMD_APNDP
Definition: swd.h:17
#define SWD_CMD_START
Definition: swd.h:16
#define SWD_CMD_RNW
Definition: swd.h:18
static const uint8_t swd_seq_line_reset[]
SWD Line reset.
Definition: swd.h:98
static const uint8_t swd_seq_jtag_to_swd[]
JTAG-to-SWD sequence.
Definition: swd.h:115
static const uint8_t swd_seq_swd_to_jtag[]
SWD-to-JTAG sequence.
Definition: swd.h:136
static const unsigned int swd_seq_swd_to_jtag_len
Definition: swd.h:144
static int parity_u32(uint32_t x)
Calculate the (even) parity of a 32-bit datum.
Definition: types.h:265
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1
uint8_t offset[4]
Definition: vdebug.c:9
static int queued_retval
static struct jtag_interface xlnx_pcie_xvc_jtag_ops
#define XLNX_XVC_LEN_REG
Definition: xlnx-pcie-xvc.c:33
static int xlnx_pcie_xvc_execute_scan(struct jtag_command *cmd)
static int xlnx_pcie_xvc_write_reg(const int offset, const uint32_t val)
Definition: xlnx-pcie-xvc.c:75
static void xlnx_pcie_xvc_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
static const char *const xlnx_pcie_xvc_transports[]
static int xlnx_pcie_xvc_transact(size_t num_bits, uint32_t tms, uint32_t tdi, uint32_t *tdo)
Definition: xlnx-pcie-xvc.c:94
COMMAND_HANDLER(xlnx_pcie_xvc_handle_config_command)
#define PCIE_EXT_CAP_LST
Definition: xlnx-pcie-xvc.c:29
struct adapter_driver xlnx_pcie_xvc_adapter_driver
static int xlnx_pcie_xvc_execute_pathmove(struct jtag_command *cmd)
#define XLNX_XVC_TMS_REG
Definition: xlnx-pcie-xvc.c:34
#define XLNX_XVC_CAP_SIZE
Definition: xlnx-pcie-xvc.c:37
static int xlnx_pcie_xvc_quit(void)
static int xlnx_pcie_xvc_swd_init(void)
#define XLNX_XVC_VSEC_HDR
Definition: xlnx-pcie-xvc.c:32
static int xlnx_pcie_xvc_execute_statemove(size_t skip)
static void swd_clear_sticky_errors(void)
static const struct command_registration xlnx_pcie_xvc_command_handlers[]
static int xlnx_pcie_xvc_execute_command(struct jtag_command *cmd)
static const struct swd_driver xlnx_pcie_xvc_swd_ops
static int xlnx_pcie_xvc_swd_sequence(const uint8_t *seq, size_t length)
static int xlnx_pcie_xvc_read_reg(const int offset, uint32_t *val)
Definition: xlnx-pcie-xvc.c:53
static int xlnx_pcie_xvc_swd_switch_seq(enum swd_special_seq seq)
#define XLNX_XVC_EXT_CAP
Definition: xlnx-pcie-xvc.c:31
#define XLNX_XVC_VSEC_ID
Definition: xlnx-pcie-xvc.c:38
static int xlnx_pcie_xvc_init(void)
static int xlnx_pcie_xvc_execute_stableclocks(struct jtag_command *cmd)
static void xlnx_pcie_xvc_execute_reset(struct jtag_command *cmd)
static int xlnx_pcie_xvc_execute_queue(struct jtag_command *cmd_queue)
static int xlnx_pcie_xvc_execute_tms(struct jtag_command *cmd)
#define XLNX_XVC_TDX_REG
Definition: xlnx-pcie-xvc.c:35
static void xlnx_pcie_xvc_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
#define MASK_ACK(x)
Definition: xlnx-pcie-xvc.c:41
#define XLNX_XVC_MAX_BITS
Definition: xlnx-pcie-xvc.c:39
static struct xlnx_pcie_xvc xlnx_pcie_xvc_state
Definition: xlnx-pcie-xvc.c:50
static void xlnx_pcie_xvc_execute_sleep(struct jtag_command *cmd)
static int xlnx_pcie_xvc_swd_run_queue(void)
#define MASK_PAR(x)
Definition: xlnx-pcie-xvc.c:42
#define PCI_CFG_SPACE_EXP_SIZE
Definition: xlnx-pcie-xvc.c:26
static const struct command_registration xlnx_pcie_xvc_subcommand_handlers[]
static int xlnx_pcie_xvc_execute_runtest(struct jtag_command *cmd)