OpenOCD
jtag_vpi.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /*
4  * JTAG to VPI driver
5  *
6  * Copyright (C) 2013 Franck Jullien, <elec4fun@gmail.com>
7  *
8  * See file CREDITS for list of people who contributed to this
9  * project.
10  */
11 
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 #include <jtag/interface.h>
17 #ifdef HAVE_ARPA_INET_H
18 #include <arpa/inet.h>
19 #endif
20 
21 #ifndef _WIN32
22 #include <netinet/tcp.h>
23 #endif
24 
25 #include "helper/replacements.h"
26 
27 #define NO_TAP_SHIFT 0
28 #define TAP_SHIFT 1
29 
30 #define DEFAULT_SERVER_ADDRESS "127.0.0.1"
31 #define DEFAULT_SERVER_PORT 5555
32 
33 #define XFERT_MAX_SIZE 512
34 
35 #define CMD_RESET 0
36 #define CMD_TMS_SEQ 1
37 #define CMD_SCAN_CHAIN 2
38 #define CMD_SCAN_CHAIN_FLIP_TMS 3
39 #define CMD_STOP_SIMU 4
40 
41 /* jtag_vpi server port and address to connect to */
43 static char *server_address;
44 
45 /* Send CMD_STOP_SIMU to server when OpenOCD exits? */
46 static bool stop_sim_on_exit;
47 
48 static int sockfd;
49 static struct sockaddr_in serv_addr;
50 
51 /* One jtag_vpi "packet" as sent over a TCP channel. */
52 struct vpi_cmd {
53  union {
54  uint32_t cmd;
55  unsigned char cmd_buf[4];
56  };
57  unsigned char buffer_out[XFERT_MAX_SIZE];
58  unsigned char buffer_in[XFERT_MAX_SIZE];
59  union {
60  uint32_t length;
61  unsigned char length_buf[4];
62  };
63  union {
64  uint32_t nb_bits;
65  unsigned char nb_bits_buf[4];
66  };
67 };
68 
69 static char *jtag_vpi_cmd_to_str(int cmd_num)
70 {
71  switch (cmd_num) {
72  case CMD_RESET:
73  return "CMD_RESET";
74  case CMD_TMS_SEQ:
75  return "CMD_TMS_SEQ";
76  case CMD_SCAN_CHAIN:
77  return "CMD_SCAN_CHAIN";
79  return "CMD_SCAN_CHAIN_FLIP_TMS";
80  case CMD_STOP_SIMU:
81  return "CMD_STOP_SIMU";
82  default:
83  return "<unknown>";
84  }
85 }
86 
87 static int jtag_vpi_send_cmd(struct vpi_cmd *vpi)
88 {
89  int retval;
90 
91  /* Optional low-level JTAG debug */
93  if (vpi->nb_bits > 0) {
94  /* command with a non-empty data payload */
95  char *char_buf = buf_to_hex_str(vpi->buffer_out,
96  (vpi->nb_bits > DEBUG_JTAG_IOZ)
98  : vpi->nb_bits);
99  LOG_DEBUG_IO("sending JTAG VPI cmd: cmd=%s, "
100  "length=%" PRIu32 ", "
101  "nb_bits=%" PRIu32 ", "
102  "buf_out=0x%s%s",
103  jtag_vpi_cmd_to_str(vpi->cmd),
104  vpi->length,
105  vpi->nb_bits,
106  char_buf,
107  (vpi->nb_bits > DEBUG_JTAG_IOZ) ? "(...)" : "");
108  free(char_buf);
109  } else {
110  /* command without data payload */
111  LOG_DEBUG_IO("sending JTAG VPI cmd: cmd=%s, "
112  "length=%" PRIu32 ", "
113  "nb_bits=%" PRIu32,
114  jtag_vpi_cmd_to_str(vpi->cmd),
115  vpi->length,
116  vpi->nb_bits);
117  }
118  }
119 
120  /* Use little endian when transmitting/receiving jtag_vpi cmds.
121  The choice of little endian goes against usual networking conventions
122  but is intentional to remain compatible with most older OpenOCD builds
123  (i.e. builds on little-endian platforms). */
124  h_u32_to_le(vpi->cmd_buf, vpi->cmd);
125  h_u32_to_le(vpi->length_buf, vpi->length);
126  h_u32_to_le(vpi->nb_bits_buf, vpi->nb_bits);
127 
128 retry_write:
129  retval = write_socket(sockfd, vpi, sizeof(struct vpi_cmd));
130 
131  if (retval < 0) {
132  /* Account for the case when socket write is interrupted. */
133 #ifdef _WIN32
134  int wsa_err = WSAGetLastError();
135  if (wsa_err == WSAEINTR)
136  goto retry_write;
137 #else
138  if (errno == EINTR)
139  goto retry_write;
140 #endif
141  /* Otherwise this is an error using the socket, most likely fatal
142  for the connection. B*/
143  log_socket_error("jtag_vpi xmit");
144  /* TODO: Clean way how adapter drivers can report fatal errors
145  to upper layers of OpenOCD and let it perform an orderly shutdown? */
146  exit(-1);
147  } else if (retval < (int)sizeof(struct vpi_cmd)) {
148  /* This means we could not send all data, which is most likely fatal
149  for the jtag_vpi connection (the underlying TCP connection likely not
150  usable anymore) */
151  LOG_ERROR("jtag_vpi: Could not send all data through jtag_vpi connection.");
152  exit(-1);
153  }
154 
155  /* Otherwise the packet has been sent successfully. */
156  return ERROR_OK;
157 }
158 
159 static int jtag_vpi_receive_cmd(struct vpi_cmd *vpi)
160 {
161  unsigned int bytes_buffered = 0;
162  while (bytes_buffered < sizeof(struct vpi_cmd)) {
163  int bytes_to_receive = sizeof(struct vpi_cmd) - bytes_buffered;
164  int retval = read_socket(sockfd, ((char *)vpi) + bytes_buffered, bytes_to_receive);
165  if (retval < 0) {
166 #ifdef _WIN32
167  int wsa_err = WSAGetLastError();
168  if (wsa_err == WSAEINTR) {
169  /* socket read interrupted by WSACancelBlockingCall() */
170  continue;
171  }
172 #else
173  if (errno == EINTR) {
174  /* socket read interrupted by a signal */
175  continue;
176  }
177 #endif
178  /* Otherwise, this is an error when accessing the socket. */
179  log_socket_error("jtag_vpi recv");
180  exit(-1);
181  } else if (retval == 0) {
182  /* Connection closed by the other side */
183  LOG_ERROR("Connection prematurely closed by jtag_vpi server.");
184  exit(-1);
185  }
186  /* Otherwise, we have successfully received some data */
187  bytes_buffered += retval;
188  }
189 
190  /* Use little endian when transmitting/receiving jtag_vpi cmds. */
191  vpi->cmd = le_to_h_u32(vpi->cmd_buf);
192  vpi->length = le_to_h_u32(vpi->length_buf);
193  vpi->nb_bits = le_to_h_u32(vpi->nb_bits_buf);
194 
195  return ERROR_OK;
196 }
197 
203 static int jtag_vpi_reset(int trst, int srst)
204 {
205  struct vpi_cmd vpi;
206  memset(&vpi, 0, sizeof(struct vpi_cmd));
207 
208  vpi.cmd = CMD_RESET;
209  vpi.length = 0;
210  return jtag_vpi_send_cmd(&vpi);
211 }
212 
224 static int jtag_vpi_tms_seq(const uint8_t *bits, int nb_bits)
225 {
226  struct vpi_cmd vpi;
227  int nb_bytes;
228 
229  memset(&vpi, 0, sizeof(struct vpi_cmd));
230  nb_bytes = DIV_ROUND_UP(nb_bits, 8);
231 
232  vpi.cmd = CMD_TMS_SEQ;
233  memcpy(vpi.buffer_out, bits, nb_bytes);
234  vpi.length = nb_bytes;
235  vpi.nb_bits = nb_bits;
236 
237  return jtag_vpi_send_cmd(&vpi);
238 }
239 
252 {
253  uint8_t trans[DIV_ROUND_UP(cmd->num_states, 8)];
254 
255  memset(trans, 0, DIV_ROUND_UP(cmd->num_states, 8));
256 
257  for (unsigned int i = 0; i < cmd->num_states; i++) {
258  if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
259  buf_set_u32(trans, i, 1, 1);
260  tap_set_state(cmd->path[i]);
261  }
262 
263  return jtag_vpi_tms_seq(trans, cmd->num_states);
264 }
265 
270 static int jtag_vpi_tms(struct tms_command *cmd)
271 {
272  return jtag_vpi_tms_seq(cmd->bits, cmd->num_bits);
273 }
274 
276 {
277  if (tap_get_state() == state)
278  return ERROR_OK;
279 
280  uint8_t tms_scan = tap_get_tms_path(tap_get_state(), state);
281  int tms_len = tap_get_tms_path_len(tap_get_state(), state);
282 
283  int retval = jtag_vpi_tms_seq(&tms_scan, tms_len);
284  if (retval != ERROR_OK)
285  return retval;
286 
288 
289  return ERROR_OK;
290 }
291 
292 static int jtag_vpi_queue_tdi_xfer(uint8_t *bits, int nb_bits, int tap_shift)
293 {
294  struct vpi_cmd vpi;
295  int nb_bytes = DIV_ROUND_UP(nb_bits, 8);
296 
297  memset(&vpi, 0, sizeof(struct vpi_cmd));
298 
299  vpi.cmd = tap_shift ? CMD_SCAN_CHAIN_FLIP_TMS : CMD_SCAN_CHAIN;
300 
301  if (bits)
302  memcpy(vpi.buffer_out, bits, nb_bytes);
303  else
304  memset(vpi.buffer_out, 0xff, nb_bytes);
305 
306  vpi.length = nb_bytes;
307  vpi.nb_bits = nb_bits;
308 
309  int retval = jtag_vpi_send_cmd(&vpi);
310  if (retval != ERROR_OK)
311  return retval;
312 
313  retval = jtag_vpi_receive_cmd(&vpi);
314  if (retval != ERROR_OK)
315  return retval;
316 
317  /* Optional low-level JTAG debug */
319  char *char_buf = buf_to_hex_str(vpi.buffer_in,
321  LOG_DEBUG_IO("recvd JTAG VPI data: nb_bits=%d, buf_in=0x%s%s",
322  nb_bits, char_buf, (nb_bits > DEBUG_JTAG_IOZ) ? "(...)" : "");
323  free(char_buf);
324  }
325 
326  if (bits)
327  memcpy(bits, vpi.buffer_in, nb_bytes);
328 
329  return ERROR_OK;
330 }
331 
338 static int jtag_vpi_queue_tdi(uint8_t *bits, int nb_bits, int tap_shift)
339 {
340  int nb_xfer = DIV_ROUND_UP(nb_bits, XFERT_MAX_SIZE * 8);
341  int retval;
342 
343  while (nb_xfer) {
344  if (nb_xfer == 1) {
345  retval = jtag_vpi_queue_tdi_xfer(bits, nb_bits, tap_shift);
346  if (retval != ERROR_OK)
347  return retval;
348  } else {
350  if (retval != ERROR_OK)
351  return retval;
352  nb_bits -= XFERT_MAX_SIZE * 8;
353  if (bits)
354  bits += XFERT_MAX_SIZE;
355  }
356 
357  nb_xfer--;
358  }
359 
360  return ERROR_OK;
361 }
362 
369 static int jtag_vpi_clock_tms(int tms)
370 {
371  const uint8_t tms_0 = 0;
372  const uint8_t tms_1 = 1;
373 
374  return jtag_vpi_tms_seq(tms ? &tms_1 : &tms_0, 1);
375 }
376 
385 static int jtag_vpi_scan(struct scan_command *cmd)
386 {
387  int scan_bits;
388  uint8_t *buf = NULL;
389  int retval = ERROR_OK;
390 
391  scan_bits = jtag_build_buffer(cmd, &buf);
392 
393  if (cmd->ir_scan) {
395  if (retval != ERROR_OK)
396  return retval;
397  } else {
399  if (retval != ERROR_OK)
400  return retval;
401  }
402 
403  if (cmd->end_state == TAP_DRSHIFT) {
404  retval = jtag_vpi_queue_tdi(buf, scan_bits, NO_TAP_SHIFT);
405  if (retval != ERROR_OK)
406  return retval;
407  } else {
408  retval = jtag_vpi_queue_tdi(buf, scan_bits, TAP_SHIFT);
409  if (retval != ERROR_OK)
410  return retval;
411  }
412 
413  if (cmd->end_state != TAP_DRSHIFT) {
414  /*
415  * As our JTAG is in an unstable state (IREXIT1 or DREXIT1), move it
416  * forward to a stable IRPAUSE or DRPAUSE.
417  */
418  retval = jtag_vpi_clock_tms(0);
419  if (retval != ERROR_OK)
420  return retval;
421 
422  if (cmd->ir_scan)
424  else
426  }
427 
428  retval = jtag_read_buffer(buf, cmd);
429  if (retval != ERROR_OK)
430  return retval;
431 
432  free(buf);
433 
434  if (cmd->end_state != TAP_DRSHIFT) {
435  retval = jtag_vpi_state_move(cmd->end_state);
436  if (retval != ERROR_OK)
437  return retval;
438  }
439 
440  return ERROR_OK;
441 }
442 
443 static int jtag_vpi_runtest(unsigned int num_cycles, tap_state_t state)
444 {
445  int retval;
446 
447  retval = jtag_vpi_state_move(TAP_IDLE);
448  if (retval != ERROR_OK)
449  return retval;
450 
451  retval = jtag_vpi_queue_tdi(NULL, num_cycles, NO_TAP_SHIFT);
452  if (retval != ERROR_OK)
453  return retval;
454 
455  return jtag_vpi_state_move(state);
456 }
457 
458 static int jtag_vpi_stableclocks(unsigned int num_cycles)
459 {
460  uint8_t tms_bits[4];
461  unsigned int cycles_remain = num_cycles;
462  int nb_bits;
463  int retval;
464  const unsigned int cycles_one_batch = sizeof(tms_bits) * 8;
465 
466  /* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */
467  memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits));
468 
469  /* send the TMS bits */
470  while (cycles_remain > 0) {
471  nb_bits = (cycles_remain < cycles_one_batch) ? cycles_remain : cycles_one_batch;
472  retval = jtag_vpi_tms_seq(tms_bits, nb_bits);
473  if (retval != ERROR_OK)
474  return retval;
475  cycles_remain -= nb_bits;
476  }
477 
478  return ERROR_OK;
479 }
480 
481 static int jtag_vpi_execute_queue(struct jtag_command *cmd_queue)
482 {
483  struct jtag_command *cmd;
484  int retval = ERROR_OK;
485 
486  for (cmd = cmd_queue; retval == ERROR_OK && cmd;
487  cmd = cmd->next) {
488  switch (cmd->type) {
489  case JTAG_RESET:
490  retval = jtag_vpi_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
491  break;
492  case JTAG_RUNTEST:
493  retval = jtag_vpi_runtest(cmd->cmd.runtest->num_cycles,
494  cmd->cmd.runtest->end_state);
495  break;
496  case JTAG_STABLECLOCKS:
497  retval = jtag_vpi_stableclocks(cmd->cmd.stableclocks->num_cycles);
498  break;
499  case JTAG_TLR_RESET:
500  retval = jtag_vpi_state_move(cmd->cmd.statemove->end_state);
501  break;
502  case JTAG_PATHMOVE:
503  retval = jtag_vpi_path_move(cmd->cmd.pathmove);
504  break;
505  case JTAG_TMS:
506  retval = jtag_vpi_tms(cmd->cmd.tms);
507  break;
508  case JTAG_SLEEP:
509  jtag_sleep(cmd->cmd.sleep->us);
510  break;
511  case JTAG_SCAN:
512  retval = jtag_vpi_scan(cmd->cmd.scan);
513  break;
514  default:
515  LOG_ERROR("BUG: unknown JTAG command type 0x%X",
516  cmd->type);
517  retval = ERROR_FAIL;
518  break;
519  }
520  }
521 
522  return retval;
523 }
524 
525 static int jtag_vpi_init(void)
526 {
527  int flag = 1;
528 
529  sockfd = socket(AF_INET, SOCK_STREAM, 0);
530  if (sockfd < 0) {
531  LOG_ERROR("jtag_vpi: Could not create client socket");
532  return ERROR_FAIL;
533  }
534 
535  memset(&serv_addr, 0, sizeof(serv_addr));
536 
537  serv_addr.sin_family = AF_INET;
538  serv_addr.sin_port = htons(server_port);
539 
540  if (!server_address)
542 
543  serv_addr.sin_addr.s_addr = inet_addr(server_address);
544 
545  if (serv_addr.sin_addr.s_addr == INADDR_NONE) {
546  LOG_ERROR("jtag_vpi: inet_addr error occurred");
547  return ERROR_FAIL;
548  }
549 
550  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
551  close(sockfd);
552  LOG_ERROR("jtag_vpi: Can't connect to %s : %u", server_address, server_port);
554  }
555 
556  if (serv_addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) {
557  /* This increases performance dramatically for local
558  * connections, which is the most likely arrangement
559  * for a VPI connection. */
560  setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
561  }
562 
563  LOG_INFO("jtag_vpi: Connection to %s : %u successful", server_address, server_port);
564 
565  return ERROR_OK;
566 }
567 
568 static int jtag_vpi_stop_simulation(void)
569 {
570  struct vpi_cmd cmd;
571  memset(&cmd, 0, sizeof(struct vpi_cmd));
572  cmd.length = 0;
573  cmd.nb_bits = 0;
574  cmd.cmd = CMD_STOP_SIMU;
575  return jtag_vpi_send_cmd(&cmd);
576 }
577 
578 static int jtag_vpi_quit(void)
579 {
580  if (stop_sim_on_exit) {
582  LOG_WARNING("jtag_vpi: failed to send \"stop simulation\" command");
583  }
584  if (close_socket(sockfd) != 0) {
585  LOG_WARNING("jtag_vpi: could not close jtag_vpi client socket");
586  log_socket_error("jtag_vpi");
587  }
588  free(server_address);
589  return ERROR_OK;
590 }
591 
592 COMMAND_HANDLER(jtag_vpi_set_port)
593 {
594  if (CMD_ARGC == 0)
596 
598  LOG_INFO("jtag_vpi: server port set to %u", server_port);
599 
600  return ERROR_OK;
601 }
602 
603 COMMAND_HANDLER(jtag_vpi_set_address)
604 {
605 
606  if (CMD_ARGC == 0)
608 
609  free(server_address);
610  server_address = strdup(CMD_ARGV[0]);
611  LOG_INFO("jtag_vpi: server address set to %s", server_address);
612 
613  return ERROR_OK;
614 }
615 
616 COMMAND_HANDLER(jtag_vpi_stop_sim_on_exit_handler)
617 {
618  if (CMD_ARGC != 1)
620 
622  return ERROR_OK;
623 }
624 
625 static const struct command_registration jtag_vpi_subcommand_handlers[] = {
626  {
627  .name = "set_port",
628  .handler = &jtag_vpi_set_port,
629  .mode = COMMAND_CONFIG,
630  .help = "set the TCP port number of the jtag_vpi server (default: 5555)",
631  .usage = "tcp_port_num",
632  },
633  {
634  .name = "set_address",
635  .handler = &jtag_vpi_set_address,
636  .mode = COMMAND_CONFIG,
637  .help = "set the IP address of the jtag_vpi server (default: 127.0.0.1)",
638  .usage = "ipv4_addr",
639  },
640  {
641  .name = "stop_sim_on_exit",
642  .handler = &jtag_vpi_stop_sim_on_exit_handler,
643  .mode = COMMAND_CONFIG,
644  .help = "Configure if simulation stop command shall be sent "
645  "before OpenOCD exits (default: off)",
646  .usage = "<on|off>",
647  },
649 };
650 
651 static const struct command_registration jtag_vpi_command_handlers[] = {
652  {
653  .name = "jtag_vpi",
654  .mode = COMMAND_ANY,
655  .help = "perform jtag_vpi management",
657  .usage = "",
658  },
660 };
661 
662 static struct jtag_interface jtag_vpi_interface = {
664  .execute_queue = jtag_vpi_execute_queue,
665 };
666 
668  .name = "jtag_vpi",
669  .transports = jtag_only,
670  .commands = jtag_vpi_command_handlers,
671 
672  .init = jtag_vpi_init,
673  .quit = jtag_vpi_quit,
674 
675  .jtag_ops = &jtag_vpi_interface,
676 };
const char *const jtag_only[]
Definition: adapter.c:27
char * buf_to_hex_str(const void *_buf, unsigned int buf_len)
Definition: binarybuffer.c:178
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 COMMAND_PARSE_ON_OFF(in, out)
parses an on/off command argument
Definition: command.h:530
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define ERROR_COMMAND_CLOSE_CONNECTION
Definition: command.h:401
#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_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:442
#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
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
Definition: commands.c:230
@ 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
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
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 DEBUG_CAP_TMS_SEQ
Definition: interface.h:187
#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
#define DEBUG_JTAG_IOZ
Definition: jtag.h:20
@ TAP_RESET
Definition: jtag.h:56
@ TAP_DRPAUSE
Definition: jtag.h:44
@ TAP_IRSHIFT
Definition: jtag.h:51
@ TAP_IDLE
Definition: jtag.h:53
@ TAP_DRSHIFT
Definition: jtag.h:43
@ TAP_IRPAUSE
Definition: jtag.h:52
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
static int jtag_vpi_init(void)
Definition: jtag_vpi.c:525
#define CMD_SCAN_CHAIN_FLIP_TMS
Definition: jtag_vpi.c:38
static int jtag_vpi_tms(struct tms_command *cmd)
jtag_vpi_tms - ask a tms command
Definition: jtag_vpi.c:270
struct adapter_driver jtag_vpi_adapter_driver
Definition: jtag_vpi.c:667
static int jtag_vpi_stableclocks(unsigned int num_cycles)
Definition: jtag_vpi.c:458
static int jtag_vpi_scan(struct scan_command *cmd)
jtag_vpi_scan - launches a DR-scan or IR-scan
Definition: jtag_vpi.c:385
static int jtag_vpi_send_cmd(struct vpi_cmd *vpi)
Definition: jtag_vpi.c:87
#define TAP_SHIFT
Definition: jtag_vpi.c:28
static int jtag_vpi_queue_tdi(uint8_t *bits, int nb_bits, int tap_shift)
jtag_vpi_queue_tdi - short description
Definition: jtag_vpi.c:338
static int jtag_vpi_tms_seq(const uint8_t *bits, int nb_bits)
jtag_vpi_tms_seq - ask a TMS sequence transition to JTAG
Definition: jtag_vpi.c:224
static const struct command_registration jtag_vpi_command_handlers[]
Definition: jtag_vpi.c:651
#define CMD_SCAN_CHAIN
Definition: jtag_vpi.c:37
static struct jtag_interface jtag_vpi_interface
Definition: jtag_vpi.c:662
static int jtag_vpi_execute_queue(struct jtag_command *cmd_queue)
Definition: jtag_vpi.c:481
static int jtag_vpi_runtest(unsigned int num_cycles, tap_state_t state)
Definition: jtag_vpi.c:443
static char * jtag_vpi_cmd_to_str(int cmd_num)
Definition: jtag_vpi.c:69
static int jtag_vpi_reset(int trst, int srst)
jtag_vpi_reset - ask to reset the JTAG device
Definition: jtag_vpi.c:203
#define DEFAULT_SERVER_ADDRESS
Definition: jtag_vpi.c:30
static int jtag_vpi_receive_cmd(struct vpi_cmd *vpi)
Definition: jtag_vpi.c:159
#define CMD_TMS_SEQ
Definition: jtag_vpi.c:36
static int jtag_vpi_queue_tdi_xfer(uint8_t *bits, int nb_bits, int tap_shift)
Definition: jtag_vpi.c:292
static int jtag_vpi_quit(void)
Definition: jtag_vpi.c:578
static int jtag_vpi_clock_tms(int tms)
jtag_vpi_clock_tms - clock a TMS transition
Definition: jtag_vpi.c:369
COMMAND_HANDLER(jtag_vpi_set_port)
Definition: jtag_vpi.c:592
static int jtag_vpi_stop_simulation(void)
Definition: jtag_vpi.c:568
static int jtag_vpi_path_move(struct pathmove_command *cmd)
jtag_vpi_path_move - ask a TMS sequence transition to JTAG
Definition: jtag_vpi.c:251
#define CMD_STOP_SIMU
Definition: jtag_vpi.c:39
static struct sockaddr_in serv_addr
Definition: jtag_vpi.c:49
#define XFERT_MAX_SIZE
Definition: jtag_vpi.c:33
static int sockfd
Definition: jtag_vpi.c:48
static const struct command_registration jtag_vpi_subcommand_handlers[]
Definition: jtag_vpi.c:625
static bool stop_sim_on_exit
Definition: jtag_vpi.c:46
#define NO_TAP_SHIFT
Definition: jtag_vpi.c:27
static int jtag_vpi_state_move(tap_state_t state)
Definition: jtag_vpi.c:275
static int server_port
Definition: jtag_vpi.c:42
#define DEFAULT_SERVER_PORT
Definition: jtag_vpi.c:31
static char * server_address
Definition: jtag_vpi.c:43
#define CMD_RESET
Definition: jtag_vpi.c:35
void log_socket_error(const char *socket_desc)
Definition: log.c:484
#define LOG_DEBUG_IO(expr ...)
Definition: log.h:101
#define LOG_WARNING(expr ...)
Definition: log.h:129
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_LEVEL_IS(FOO)
Definition: log.h:99
#define LOG_INFO(expr ...)
Definition: log.h:126
#define ERROR_OK
Definition: log.h:164
@ LOG_LVL_DEBUG_IO
Definition: log.h:48
int flag
Definition: mips64.c:29
uint8_t bits[QN908X_FLASH_MAX_BLOCKS *QN908X_FLASH_PAGES_PER_BLOCK/8]
Definition: qn908x.c:0
static int read_socket(int handle, void *buffer, unsigned int count)
Definition: replacements.h:175
static int close_socket(int sock)
Definition: replacements.h:184
static int write_socket(int handle, const void *buffer, unsigned int count)
Definition: replacements.h:166
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
unsigned int supported
Bit vector listing capabilities exposed by this driver.
Definition: interface.h:186
The scan_command provide a means of encapsulating a set of scan_field structures that should be scann...
Definition: commands.h:35
Encapsulates a series of bits to be clocked out, affecting state and mode of the interface.
Definition: commands.h:101
unsigned char nb_bits_buf[4]
Definition: jtag_vpi.c:65
uint32_t cmd
Definition: jtag_vpi.c:54
unsigned char cmd_buf[4]
Definition: jtag_vpi.c:55
uint32_t length
Definition: jtag_vpi.c:60
unsigned char buffer_in[XFERT_MAX_SIZE]
Definition: jtag_vpi.c:58
unsigned char length_buf[4]
Definition: jtag_vpi.c:61
unsigned char buffer_out[XFERT_MAX_SIZE]
Definition: jtag_vpi.c:57
uint32_t nb_bits
Definition: jtag_vpi.c:64
static void h_u32_to_le(uint8_t *buf, uint32_t val)
Definition: types.h:178
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
Definition: types.h:79
static uint32_t le_to_h_u32(const uint8_t *buf)
Definition: types.h:112
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1
uint8_t state[4]
Definition: vdebug.c:21