OpenOCD
jtag_vpi.c File Reference
Include dependency graph for jtag_vpi.c:

Go to the source code of this file.

Data Structures

struct  vpi_cmd
 

Macros

#define CMD_RESET   0
 
#define CMD_SCAN_CHAIN   2
 
#define CMD_SCAN_CHAIN_FLIP_TMS   3
 
#define CMD_STOP_SIMU   4
 
#define CMD_TMS_SEQ   1
 
#define DEFAULT_SERVER_ADDRESS   "127.0.0.1"
 
#define DEFAULT_SERVER_PORT   5555
 
#define NO_TAP_SHIFT   0
 
#define TAP_SHIFT   1
 
#define XFERT_MAX_SIZE   512
 

Functions

 COMMAND_HANDLER (jtag_vpi_set_address)
 
 COMMAND_HANDLER (jtag_vpi_set_port)
 
 COMMAND_HANDLER (jtag_vpi_stop_sim_on_exit_handler)
 
static int jtag_vpi_clock_tms (int tms)
 jtag_vpi_clock_tms - clock a TMS transition More...
 
static char * jtag_vpi_cmd_to_str (int cmd_num)
 
static int jtag_vpi_execute_queue (void)
 
static int jtag_vpi_init (void)
 
static int jtag_vpi_path_move (struct pathmove_command *cmd)
 jtag_vpi_path_move - ask a TMS sequence transition to JTAG More...
 
static int jtag_vpi_queue_tdi (uint8_t *bits, int nb_bits, int tap_shift)
 jtag_vpi_queue_tdi - short description More...
 
static int jtag_vpi_queue_tdi_xfer (uint8_t *bits, int nb_bits, int tap_shift)
 
static int jtag_vpi_quit (void)
 
static int jtag_vpi_receive_cmd (struct vpi_cmd *vpi)
 
static int jtag_vpi_reset (int trst, int srst)
 jtag_vpi_reset - ask to reset the JTAG device More...
 
static int jtag_vpi_runtest (int cycles, tap_state_t state)
 
static int jtag_vpi_scan (struct scan_command *cmd)
 jtag_vpi_scan - launches a DR-scan or IR-scan More...
 
static int jtag_vpi_send_cmd (struct vpi_cmd *vpi)
 
static int jtag_vpi_stableclocks (int cycles)
 
static int jtag_vpi_state_move (tap_state_t state)
 
static int jtag_vpi_stop_simulation (void)
 
static int jtag_vpi_tms (struct tms_command *cmd)
 jtag_vpi_tms - ask a tms command More...
 
static int jtag_vpi_tms_seq (const uint8_t *bits, int nb_bits)
 jtag_vpi_tms_seq - ask a TMS sequence transition to JTAG More...
 

Variables

struct adapter_driver jtag_vpi_adapter_driver
 
static const struct command_registration jtag_vpi_command_handlers []
 
static struct jtag_interface jtag_vpi_interface
 
static const struct command_registration jtag_vpi_subcommand_handlers []
 
static struct sockaddr_in serv_addr
 
static char * server_address
 
static int server_port = DEFAULT_SERVER_PORT
 
static int sockfd
 
static bool stop_sim_on_exit
 

Macro Definition Documentation

◆ CMD_RESET

#define CMD_RESET   0

Definition at line 35 of file jtag_vpi.c.

◆ CMD_SCAN_CHAIN

#define CMD_SCAN_CHAIN   2

Definition at line 37 of file jtag_vpi.c.

◆ CMD_SCAN_CHAIN_FLIP_TMS

#define CMD_SCAN_CHAIN_FLIP_TMS   3

Definition at line 38 of file jtag_vpi.c.

◆ CMD_STOP_SIMU

#define CMD_STOP_SIMU   4

Definition at line 39 of file jtag_vpi.c.

◆ CMD_TMS_SEQ

#define CMD_TMS_SEQ   1

Definition at line 36 of file jtag_vpi.c.

◆ DEFAULT_SERVER_ADDRESS

#define DEFAULT_SERVER_ADDRESS   "127.0.0.1"

Definition at line 30 of file jtag_vpi.c.

◆ DEFAULT_SERVER_PORT

#define DEFAULT_SERVER_PORT   5555

Definition at line 31 of file jtag_vpi.c.

◆ NO_TAP_SHIFT

#define NO_TAP_SHIFT   0

Definition at line 27 of file jtag_vpi.c.

◆ TAP_SHIFT

#define TAP_SHIFT   1

Definition at line 28 of file jtag_vpi.c.

◆ XFERT_MAX_SIZE

#define XFERT_MAX_SIZE   512

Definition at line 33 of file jtag_vpi.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

COMMAND_HANDLER ( jtag_vpi_set_address  )

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( jtag_vpi_set_port  )

◆ COMMAND_HANDLER() [3/3]

COMMAND_HANDLER ( jtag_vpi_stop_sim_on_exit_handler  )

◆ jtag_vpi_clock_tms()

static int jtag_vpi_clock_tms ( int  tms)
static

jtag_vpi_clock_tms - clock a TMS transition

Parameters
tmsthe TMS to be sent

Triggers a TMS transition (ie. one JTAG TAP state move).

Definition at line 369 of file jtag_vpi.c.

References jtag_vpi_tms_seq().

Referenced by jtag_vpi_scan().

◆ jtag_vpi_cmd_to_str()

static char* jtag_vpi_cmd_to_str ( int  cmd_num)
static

Definition at line 69 of file jtag_vpi.c.

References CMD_RESET, CMD_SCAN_CHAIN, CMD_SCAN_CHAIN_FLIP_TMS, CMD_STOP_SIMU, and CMD_TMS_SEQ.

Referenced by jtag_vpi_send_cmd().

◆ jtag_vpi_execute_queue()

◆ jtag_vpi_init()

static int jtag_vpi_init ( void  )
static

◆ jtag_vpi_path_move()

static int jtag_vpi_path_move ( struct pathmove_command cmd)
static

jtag_vpi_path_move - ask a TMS sequence transition to JTAG

Parameters
cmdpath transition

Write a series of TMS transitions, where each transition consists in :

  • writing out TCK=0, TMS=<new_state>, TDI=<???>
  • writing out TCK=1, TMS=<new_state>, TDI=<???> which triggers the transition The function ensures that at the end of the sequence, the clock (TCK) is put low.

Definition at line 251 of file jtag_vpi.c.

References buf_set_u32(), cmd, DIV_ROUND_UP, jtag_vpi_tms_seq(), tap_get_state(), tap_set_state, and tap_state_transition().

Referenced by jtag_vpi_execute_queue().

◆ jtag_vpi_queue_tdi()

static int jtag_vpi_queue_tdi ( uint8_t *  bits,
int  nb_bits,
int  tap_shift 
)
static

jtag_vpi_queue_tdi - short description

Parameters
bitsbits to be queued on TDI (or NULL if 0 are to be queued)
nb_bitsnumber of bits
tap_shift

Definition at line 338 of file jtag_vpi.c.

References bits, DIV_ROUND_UP, ERROR_OK, jtag_vpi_queue_tdi_xfer(), vpi_cmd::nb_bits, NO_TAP_SHIFT, and XFERT_MAX_SIZE.

Referenced by jtag_vpi_runtest(), and jtag_vpi_scan().

◆ jtag_vpi_queue_tdi_xfer()

static int jtag_vpi_queue_tdi_xfer ( uint8_t *  bits,
int  nb_bits,
int  tap_shift 
)
static

◆ jtag_vpi_quit()

static int jtag_vpi_quit ( void  )
static

◆ jtag_vpi_receive_cmd()

static int jtag_vpi_receive_cmd ( struct vpi_cmd vpi)
static

◆ jtag_vpi_reset()

static int jtag_vpi_reset ( int  trst,
int  srst 
)
static

jtag_vpi_reset - ask to reset the JTAG device

Parameters
trst1 if TRST is to be asserted
srst1 if SRST is to be asserted

Definition at line 203 of file jtag_vpi.c.

References vpi_cmd::cmd, CMD_RESET, jtag_vpi_send_cmd(), and vpi_cmd::length.

Referenced by jtag_vpi_execute_queue().

◆ jtag_vpi_runtest()

static int jtag_vpi_runtest ( int  cycles,
tap_state_t  state 
)
static

◆ jtag_vpi_scan()

static int jtag_vpi_scan ( struct scan_command cmd)
static

jtag_vpi_scan - launches a DR-scan or IR-scan

Parameters
cmdthe command to launch

Launch a JTAG IR-scan or DR-scan

Returns ERROR_OK if OK, ERROR_xxx if a read/write error occurred.

Definition at line 385 of file jtag_vpi.c.

References cmd, ERROR_OK, jtag_build_buffer(), jtag_read_buffer(), jtag_vpi_clock_tms(), jtag_vpi_queue_tdi(), jtag_vpi_state_move(), NO_TAP_SHIFT, NULL, TAP_DRPAUSE, TAP_DRSHIFT, TAP_IRPAUSE, TAP_IRSHIFT, tap_set_state, and TAP_SHIFT.

Referenced by jtag_vpi_execute_queue().

◆ jtag_vpi_send_cmd()

◆ jtag_vpi_stableclocks()

static int jtag_vpi_stableclocks ( int  cycles)
static

Definition at line 458 of file jtag_vpi.c.

References ERROR_OK, jtag_vpi_tms_seq(), vpi_cmd::nb_bits, tap_get_state(), and TAP_RESET.

Referenced by jtag_vpi_execute_queue().

◆ jtag_vpi_state_move()

static int jtag_vpi_state_move ( tap_state_t  state)
static

◆ jtag_vpi_stop_simulation()

static int jtag_vpi_stop_simulation ( void  )
static

Definition at line 570 of file jtag_vpi.c.

References cmd, CMD_STOP_SIMU, and jtag_vpi_send_cmd().

Referenced by jtag_vpi_quit().

◆ jtag_vpi_tms()

static int jtag_vpi_tms ( struct tms_command cmd)
static

jtag_vpi_tms - ask a tms command

Parameters
cmdtms command

Definition at line 270 of file jtag_vpi.c.

References cmd, and jtag_vpi_tms_seq().

Referenced by jtag_vpi_execute_queue().

◆ jtag_vpi_tms_seq()

static int jtag_vpi_tms_seq ( const uint8_t *  bits,
int  nb_bits 
)
static

jtag_vpi_tms_seq - ask a TMS sequence transition to JTAG

Parameters
bitsTMS bits to be written (bit0, bit1 .. bitN)
nb_bitsnumber of TMS bits (between 1 and 8)

Write a series of TMS transitions, where each transition consists in :

  • writing out TCK=0, TMS=<new_state>, TDI=<???>
  • writing out TCK=1, TMS=<new_state>, TDI=<???> which triggers the transition The function ensures that at the end of the sequence, the clock (TCK) is put low.

Definition at line 224 of file jtag_vpi.c.

References bits, vpi_cmd::buffer_out, vpi_cmd::cmd, CMD_TMS_SEQ, DIV_ROUND_UP, jtag_vpi_send_cmd(), vpi_cmd::length, and vpi_cmd::nb_bits.

Referenced by jtag_vpi_clock_tms(), jtag_vpi_path_move(), jtag_vpi_stableclocks(), jtag_vpi_state_move(), and jtag_vpi_tms().

Variable Documentation

◆ jtag_vpi_adapter_driver

struct adapter_driver jtag_vpi_adapter_driver
Initial value:
= {
.name = "jtag_vpi",
.transports = jtag_only,
.init = jtag_vpi_init,
.quit = jtag_vpi_quit,
.jtag_ops = &jtag_vpi_interface,
}
const char *const jtag_only[]
Definition: adapter.c:31
static int jtag_vpi_init(void)
Definition: jtag_vpi.c:527
static const struct command_registration jtag_vpi_command_handlers[]
Definition: jtag_vpi.c:659
static struct jtag_interface jtag_vpi_interface
Definition: jtag_vpi.c:670
static int jtag_vpi_quit(void)
Definition: jtag_vpi.c:580

Definition at line 622 of file jtag_vpi.c.

◆ jtag_vpi_command_handlers

const struct command_registration jtag_vpi_command_handlers[]
static
Initial value:
= {
{
.name = "jtag_vpi",
.mode = COMMAND_ANY,
.help = "perform jtag_vpi management",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration jtag_vpi_subcommand_handlers[]
Definition: jtag_vpi.c:633
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:235

Definition at line 622 of file jtag_vpi.c.

◆ jtag_vpi_interface

struct jtag_interface jtag_vpi_interface
static
Initial value:
= {
.supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = jtag_vpi_execute_queue,
}
#define DEBUG_CAP_TMS_SEQ
Definition: interface.h:189
static int jtag_vpi_execute_queue(void)
Definition: jtag_vpi.c:483

Definition at line 622 of file jtag_vpi.c.

◆ jtag_vpi_subcommand_handlers

const struct command_registration jtag_vpi_subcommand_handlers[]
static
Initial value:
= {
{
.name = "set_port",
.handler = &jtag_vpi_set_port,
.mode = COMMAND_CONFIG,
.help = "set the TCP port number of the jtag_vpi server (default: 5555)",
.usage = "tcp_port_num",
},
{
.name = "set_address",
.handler = &jtag_vpi_set_address,
.mode = COMMAND_CONFIG,
.help = "set the IP address of the jtag_vpi server (default: 127.0.0.1)",
.usage = "ipv4_addr",
},
{
.name = "stop_sim_on_exit",
.handler = &jtag_vpi_stop_sim_on_exit_handler,
.mode = COMMAND_CONFIG,
.help = "Configure if simulation stop command shall be sent "
"before OpenOCD exits (default: off)",
.usage = "<on|off>",
},
}
@ COMMAND_CONFIG
Definition: command.h:41

Definition at line 622 of file jtag_vpi.c.

◆ serv_addr

struct sockaddr_in serv_addr
static

Definition at line 48 of file jtag_vpi.c.

Referenced by jtag_vpi_init().

◆ server_address

char* server_address
static

Definition at line 43 of file jtag_vpi.c.

Referenced by COMMAND_HANDLER(), jtag_vpi_init(), and jtag_vpi_quit().

◆ server_port

int server_port = DEFAULT_SERVER_PORT
static

Definition at line 42 of file jtag_vpi.c.

Referenced by COMMAND_HANDLER(), and jtag_vpi_init().

◆ sockfd

int sockfd
static

Definition at line 48 of file jtag_vpi.c.

Referenced by jtag_vpi_init(), jtag_vpi_quit(), jtag_vpi_receive_cmd(), and jtag_vpi_send_cmd().

◆ stop_sim_on_exit

bool stop_sim_on_exit
static

Definition at line 46 of file jtag_vpi.c.

Referenced by COMMAND_HANDLER(), and jtag_vpi_quit().