OpenOCD
interface.h File Reference
Include dependency graph for interface.h:

Go to the source code of this file.

Data Structures

struct  adapter_driver
 Represents a driver for a debugging interface. More...
 
struct  jtag_interface
 Represents a driver for a debugging interface. More...
 

Macros

#define DEBUG_CAP_TMS_SEQ   (1 << 0)
 
#define tap_set_state(new_state)
 This function sets the state of a "state follower" which tracks the state of the TAPs connected to the cable. More...
 

Functions

int adapter_assert_reset (void)
 
int adapter_config_trace (bool enabled, enum tpiu_pin_protocol pin_protocol, uint32_t port_size, unsigned int *trace_freq, unsigned int traceclkin_freq, uint16_t *prescaler)
 
int adapter_deassert_reset (void)
 
int adapter_poll_trace (uint8_t *buf, size_t *size)
 
int adapter_resets (int assert_trst, int assert_srst)
 
static tap_state_t jtag_debug_state_machine (const void *tms_buf, const void *tdi_buf, unsigned int tap_len, tap_state_t start_tap_state)
 Prints verbose TAP state transitions for the given TMS/TDI buffers. More...
 
tap_state_t jtag_debug_state_machine_ (const void *tms_buf, const void *tdi_buf, unsigned int tap_len, tap_state_t start_tap_state)
 
tap_state_t tap_get_end_state (void)
 For more information,. More...
 
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 the cable. More...
 
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 seven TAP clock cycles in order to get from state "from" to state "to". More...
 
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 transition as given by the function tap_get_tms_path(). More...
 
bool tap_is_state_stable (tap_state_t astate)
 Function tap_is_state_stable returns true if the astate is stable. More...
 
int tap_move_ndx (tap_state_t astate)
 Function tap_move_ndx when given a stable state, returns an index from 0-5. More...
 
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 thinks will be the end (resultant) state of the current TAP SIR or SDR operation. More...
 
void tap_set_state_impl (tap_state_t new_state)
 implementation of wrapper function tap_set_state() More...
 
tap_state_t tap_state_transition (tap_state_t current_state, bool tms)
 Function tap_state_transition takes a current TAP state and returns the next state according to the tms value. More...
 
void tap_use_new_tms_table (bool use_new)
 Allow switching between old and new TMS tables. More...
 
bool tap_uses_new_tms_table (void)
 

Variables

struct adapter_driver am335xgpio_adapter_driver
 
struct adapter_driver amt_jtagaccel_adapter_driver
 
struct adapter_driver angie_adapter_driver
 
struct adapter_driver armjtagew_adapter_driver
 
struct adapter_driver at91rm9200_adapter_driver
 
struct adapter_driver bcm2835gpio_adapter_driver
 
struct adapter_driver buspirate_adapter_driver
 
struct adapter_driver cmsis_dap_adapter_driver
 
struct adapter_driver dmem_dap_adapter_driver
 
struct adapter_driver dummy_adapter_driver
 
struct adapter_driver ep93xx_adapter_driver
 
struct adapter_driver esp_usb_adapter_driver
 
struct adapter_driver ft232r_adapter_driver
 
struct adapter_driver ftdi_adapter_driver
 
struct adapter_driver gw16012_adapter_driver
 
struct adapter_driver hl_adapter_driver
 
struct adapter_driver imx_gpio_adapter_driver
 
struct adapter_driver jlink_adapter_driver
 
struct adapter_driver jtag_dpi_adapter_driver
 
const char *const jtag_only []
 
struct adapter_driver jtag_vpi_adapter_driver
 
struct adapter_driver kitprog_adapter_driver
 
struct adapter_driver linuxgpiod_adapter_driver
 
struct adapter_driver opendous_adapter_driver
 
struct adapter_driver openjtag_adapter_driver
 
struct adapter_driver osbdm_adapter_driver
 
struct adapter_driver parport_adapter_driver
 
struct adapter_driver presto_adapter_driver
 
struct adapter_driver remote_bitbang_adapter_driver
 
struct adapter_driver rlink_adapter_driver
 
struct adapter_driver rshim_dap_adapter_driver
 
struct adapter_driver stlink_dap_adapter_driver
 
struct adapter_driver sysfsgpio_adapter_driver
 
struct adapter_driver ulink_adapter_driver
 
struct adapter_driver usb_blaster_adapter_driver
 
struct adapter_driver usbprog_adapter_driver
 
struct adapter_driver vdebug_adapter_driver
 
struct adapter_driver vsllink_adapter_driver
 
struct adapter_driver xds110_adapter_driver
 
struct adapter_driver xlnx_pcie_xvc_adapter_driver
 

Macro Definition Documentation

◆ DEBUG_CAP_TMS_SEQ

#define DEBUG_CAP_TMS_SEQ   (1 << 0)

Definition at line 187 of file interface.h.

◆ tap_set_state

#define tap_set_state (   new_state)
Value:
do { \
LOG_DEBUG_IO("tap_set_state(%s)", tap_state_name(new_state)); \
tap_set_state_impl(new_state); \
} while (0)
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

This function sets the state of a "state follower" which tracks the state of the TAPs connected to the cable.

The state follower is hopefully always in the same state as the actual TAPs in the jtag chain, and will be so if there are no bugs in the tracking logic within that cable driver.

All the cable drivers call this function to indicate the state they think the TAPs attached to their cables are in. Because this function can also log transitions, it will be helpful to call this function with every transition that the TAPs being manipulated are expected to traverse, not just end points of a multi-step state path.

Parameters
new_stateThe state we think the TAPs are currently in (or are about to enter).

Definition at line 49 of file interface.h.

Function Documentation

◆ adapter_assert_reset()

◆ adapter_config_trace()

int adapter_config_trace ( bool  enabled,
enum tpiu_pin_protocol  pin_protocol,
uint32_t  port_size,
unsigned int *  trace_freq,
unsigned int  traceclkin_freq,
uint16_t *  prescaler 
)

Definition at line 1916 of file jtag/core.c.

References adapter_driver::config_trace, ERROR_FAIL, ERROR_OK, and LOG_ERROR.

Referenced by arm_tpiu_swo_cleanup_all(), and COMMAND_HANDLER().

◆ adapter_deassert_reset()

◆ adapter_poll_trace()

int adapter_poll_trace ( uint8_t *  buf,
size_t *  size 
)

Definition at line 1931 of file jtag/core.c.

References ERROR_FAIL, adapter_driver::poll_trace, and size.

Referenced by arm_tpiu_swo_poll_trace().

◆ adapter_resets()

◆ jtag_debug_state_machine()

static tap_state_t jtag_debug_state_machine ( const void *  tms_buf,
const void *  tdi_buf,
unsigned int  tap_len,
tap_state_t  start_tap_state 
)
inlinestatic

Prints verbose TAP state transitions for the given TMS/TDI buffers.

Parameters
tms_bufmust points to a buffer containing the TMS bitstream.
tdi_bufmust points to a buffer containing the TDI bitstream.
tap_lenmust specify the length of the TMS/TDI bitstreams.
start_tap_statemust specify the current TAP state.
Returns
the final TAP state; pass as start_tap_state in following call.

Definition at line 161 of file interface.h.

References jtag_debug_state_machine_(), LOG_LEVEL_IS, and LOG_LVL_DEBUG_IO.

Referenced by buspirate_tap_execute(), and jlink_flush().

◆ jtag_debug_state_machine_()

tap_state_t jtag_debug_state_machine_ ( const void *  tms_buf,
const void *  tdi_buf,
unsigned int  tap_len,
tap_state_t  start_tap_state 
)

◆ tap_get_end_state()

◆ tap_get_state()

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 the cable.

See also
tap_set_state
Returns
tap_state_t The state the TAPs are in now.

Definition at line 37 of file interface.c.

References state_follower.

Referenced by amt_jtagaccel_runtest(), amt_jtagaccel_scan(), amt_jtagaccel_state_move(), angie_queue_pathmove(), angie_queue_runtest(), angie_queue_scan(), angie_queue_stableclocks(), angie_queue_statemove(), armjtagew_path_move(), armjtagew_runtest(), armjtagew_scan(), armjtagew_state_move(), bitbang_path_move(), bitbang_runtest(), bitbang_scan(), bitbang_stableclocks(), bitbang_state_move(), bitq_execute_queue(), bitq_path_move(), bitq_runtest(), bitq_scan_field(), bitq_state_move(), buspirate_path_move(), buspirate_runtest(), buspirate_scan(), buspirate_stableclocks(), buspirate_state_move(), cmsis_dap_execute_scan(), cmsis_dap_pathmove(), cmsis_dap_runtest(), cmsis_dap_stableclocks(), cmsis_dap_state_move(), ftdi_execute_pathmove(), ftdi_execute_runtest(), ftdi_execute_scan(), ftdi_execute_sleep(), ftdi_execute_stableclocks(), ftdi_execute_statemove(), gw16012_path_move(), gw16012_runtest(), gw16012_scan(), gw16012_state_move(), jlink_execute_scan(), jlink_path_move(), jlink_runtest(), jlink_stableclocks(), jlink_state_move(), jtag_vpi_path_move(), jtag_vpi_stableclocks(), jtag_vpi_state_move(), move_to_state(), opendous_path_move(), opendous_runtest(), opendous_scan(), opendous_state_move(), openjtag_execute_runtest(), openjtag_execute_scan(), osbdm_add_pathmove(), osbdm_add_scan(), osbdm_add_stableclocks(), osbdm_add_statemove(), rlink_path_move(), rlink_runtest(), rlink_scan(), rlink_state_move(), syncbb_path_move(), syncbb_runtest(), syncbb_scan(), syncbb_stableclocks(), syncbb_state_move(), ublast_path_move(), ublast_state_move(), ulink_queue_pathmove(), ulink_queue_runtest(), ulink_queue_scan(), ulink_queue_stableclocks(), ulink_queue_statemove(), usbprog_path_move(), usbprog_runtest(), usbprog_scan(), usbprog_state_move(), vdebug_jtag_path_move(), vdebug_jtag_runtest(), vdebug_jtag_scan(), vdebug_jtag_stableclocks(), vdebug_jtag_tlr(), vsllink_execute_queue(), vsllink_path_move(), vsllink_runtest(), vsllink_scan(), vsllink_state_move(), xlnx_pcie_xvc_execute_pathmove(), xlnx_pcie_xvc_execute_runtest(), xlnx_pcie_xvc_execute_scan(), xlnx_pcie_xvc_execute_stableclocks(), and xlnx_pcie_xvc_execute_statemove().

◆ tap_get_tms_path()

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 seven TAP clock cycles in order to get from state "from" to state "to".

The length of the sequence must be determined with a parallel call to tap_get_tms_path_len().

Parameters
fromThe starting state.
toThe desired final state.
Returns
int The required TMS bit sequence, with the first bit in the sequence at bit 0.

Definition at line 190 of file interface.c.

References tap_move_ndx(), and tms_seqs.

Referenced by angie_queue_scan(), angie_queue_statemove(), armjtagew_state_move(), bitbang_state_move(), bitq_state_move(), buspirate_state_move(), cmsis_dap_state_move(), gw16012_state_move(), jlink_state_move(), jtag_add_statemove(), jtag_vpi_state_move(), move_to_state(), opendous_state_move(), osbdm_add_statemove(), rlink_state_move(), syncbb_state_move(), ublast_state_move(), ulink_queue_scan(), ulink_queue_statemove(), usbprog_state_move(), vdebug_jtag_runtest(), vdebug_jtag_scan(), vdebug_jtag_tlr(), vsllink_state_move(), and xlnx_pcie_xvc_execute_statemove().

◆ tap_get_tms_path_len()

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 transition as given by the function tap_get_tms_path().

For at least one interface (JLink) it's not OK to simply "pad" TMS sequences to fit a whole byte. (I suspect this is a general TAP problem within OOCD.) Padding TMS causes all manner of instability that's not easily discovered. Using this routine we can apply EXACTLY the state transitions required to make something work - no more - no less.

Parameters
fromis the starting state
tois the resultant or final state
Returns
int - the total number of bits in a transition.

Definition at line 195 of file interface.c.

References tap_move_ndx(), and tms_seqs.

Referenced by angie_queue_scan(), angie_queue_statemove(), armjtagew_state_move(), bitbang_state_move(), bitq_state_move(), buspirate_state_move(), cmsis_dap_state_move(), ftdi_initialize(), gw16012_state_move(), jlink_state_move(), jtag_add_statemove(), jtag_vpi_state_move(), move_to_state(), opendous_state_move(), osbdm_add_statemove(), rlink_state_move(), syncbb_state_move(), ublast_state_move(), ulink_queue_scan(), ulink_queue_statemove(), vdebug_jtag_runtest(), vdebug_jtag_scan(), vdebug_jtag_tlr(), vsllink_state_move(), and xlnx_pcie_xvc_execute_statemove().

◆ tap_is_state_stable()

◆ tap_move_ndx()

int tap_move_ndx ( tap_state_t  astate)

Function tap_move_ndx when given a stable state, returns an index from 0-5.

The index corresponds to a sequence of stable states which are given in this order:

{ TAP_RESET, TAP_IDLE, TAP_DRSHIFT, TAP_DRPAUSE, TAP_IRSHIFT, TAP_IRPAUSE }

This sequence corresponds to look up tables which are used in some of the cable drivers.

Parameters
astateis the stable state to find in the sequence. If a non stable state is passed, this may cause the program to output an error message and terminate.
Returns
int - the array (or sequence) index as described above

Definition at line 61 of file interface.c.

Referenced by amt_jtagaccel_scan(), amt_jtagaccel_state_move(), tap_get_tms_path(), and tap_get_tms_path_len().

◆ tap_set_end_state()

◆ tap_set_state_impl()

void tap_set_state_impl ( tap_state_t  new_state)

implementation of wrapper function tap_set_state()

Definition at line 31 of file interface.c.

References state_follower.

◆ tap_state_transition()

◆ tap_use_new_tms_table()

void tap_use_new_tms_table ( bool  use_new)

Allow switching between old and new TMS tables.

See also
tap_get_tms_path

Definition at line 447 of file interface.c.

References old_tms_seqs, short_tms_seqs, and tms_seqs.

Referenced by COMMAND_HANDLER().

◆ tap_uses_new_tms_table()

bool tap_uses_new_tms_table ( void  )
Returns
True if new TMS table is active; false otherwise.

Definition at line 451 of file interface.c.

References short_tms_seqs, and tms_seqs.

Referenced by COMMAND_HANDLER().

Variable Documentation

◆ am335xgpio_adapter_driver

struct adapter_driver am335xgpio_adapter_driver
extern

Definition at line 464 of file am335xgpio.c.

◆ amt_jtagaccel_adapter_driver

struct adapter_driver amt_jtagaccel_adapter_driver
extern

Definition at line 535 of file amt_jtagaccel.c.

◆ angie_adapter_driver

struct adapter_driver angie_adapter_driver
extern

Definition at line 2376 of file angie.c.

◆ armjtagew_adapter_driver

struct adapter_driver armjtagew_adapter_driver
extern

Definition at line 462 of file arm-jtag-ew.c.

◆ at91rm9200_adapter_driver

struct adapter_driver at91rm9200_adapter_driver
extern

Definition at line 154 of file at91rm9200.c.

◆ bcm2835gpio_adapter_driver

struct adapter_driver bcm2835gpio_adapter_driver
extern

Definition at line 581 of file bcm2835gpio.c.

◆ buspirate_adapter_driver

struct adapter_driver buspirate_adapter_driver
extern

Definition at line 537 of file buspirate.c.

◆ cmsis_dap_adapter_driver

struct adapter_driver cmsis_dap_adapter_driver
extern

Definition at line 2307 of file cmsis_dap.c.

◆ dmem_dap_adapter_driver

struct adapter_driver dmem_dap_adapter_driver
extern

Definition at line 607 of file dmem.c.

◆ dummy_adapter_driver

struct adapter_driver dummy_adapter_driver
extern

Definition at line 117 of file dummy.c.

◆ ep93xx_adapter_driver

struct adapter_driver ep93xx_adapter_driver
extern

Definition at line 38 of file ep93xx.c.

◆ esp_usb_adapter_driver

struct adapter_driver esp_usb_adapter_driver
extern

Definition at line 719 of file esp_usb_jtag.c.

◆ ft232r_adapter_driver

struct adapter_driver ft232r_adapter_driver
extern

Definition at line 804 of file ft232r.c.

◆ ftdi_adapter_driver

struct adapter_driver ftdi_adapter_driver
extern

Definition at line 1250 of file ftdi.c.

◆ gw16012_adapter_driver

struct adapter_driver gw16012_adapter_driver
extern

Definition at line 481 of file gw16012.c.

◆ hl_adapter_driver

struct adapter_driver hl_adapter_driver
extern

Definition at line 307 of file hla_interface.c.

◆ imx_gpio_adapter_driver

struct adapter_driver imx_gpio_adapter_driver
extern

Definition at line 420 of file imx_gpio.c.

◆ jlink_adapter_driver

struct adapter_driver jlink_adapter_driver
extern

Definition at line 2267 of file jlink.c.

◆ jtag_dpi_adapter_driver

struct adapter_driver jtag_dpi_adapter_driver
extern

Definition at line 337 of file jtag_dpi.c.

◆ jtag_only

const char* const jtag_only[]
extern

Definition at line 27 of file adapter.c.

◆ jtag_vpi_adapter_driver

struct adapter_driver jtag_vpi_adapter_driver
extern

Definition at line 616 of file jtag_vpi.c.

◆ kitprog_adapter_driver

struct adapter_driver kitprog_adapter_driver
extern

Definition at line 911 of file kitprog.c.

◆ linuxgpiod_adapter_driver

struct adapter_driver linuxgpiod_adapter_driver
extern

Definition at line 428 of file linuxgpiod.c.

◆ opendous_adapter_driver

struct adapter_driver opendous_adapter_driver
extern

Definition at line 173 of file opendous.c.

◆ openjtag_adapter_driver

struct adapter_driver openjtag_adapter_driver
extern

Definition at line 881 of file openjtag.c.

◆ osbdm_adapter_driver

struct adapter_driver osbdm_adapter_driver
extern

Definition at line 661 of file osbdm.c.

◆ parport_adapter_driver

struct adapter_driver parport_adapter_driver
extern

Definition at line 447 of file parport.c.

◆ presto_adapter_driver

struct adapter_driver presto_adapter_driver
extern

Definition at line 517 of file presto.c.

◆ remote_bitbang_adapter_driver

struct adapter_driver remote_bitbang_adapter_driver
extern

Definition at line 466 of file remote_bitbang.c.

◆ rlink_adapter_driver

struct adapter_driver rlink_adapter_driver
extern

Definition at line 1653 of file rlink.c.

◆ rshim_dap_adapter_driver

struct adapter_driver rshim_dap_adapter_driver
extern

Definition at line 511 of file rshim.c.

◆ stlink_dap_adapter_driver

struct adapter_driver stlink_dap_adapter_driver
extern

Definition at line 5221 of file stlink_usb.c.

◆ sysfsgpio_adapter_driver

struct adapter_driver sysfsgpio_adapter_driver
extern

Definition at line 548 of file sysfsgpio.c.

◆ ulink_adapter_driver

struct adapter_driver ulink_adapter_driver
extern

Definition at line 2227 of file ulink.c.

◆ usb_blaster_adapter_driver

struct adapter_driver usb_blaster_adapter_driver
extern

Definition at line 997 of file usb_blaster.c.

◆ usbprog_adapter_driver

struct adapter_driver usbprog_adapter_driver
extern

Definition at line 572 of file usbprog.c.

◆ vdebug_adapter_driver

struct adapter_driver vdebug_adapter_driver
extern

Definition at line 1345 of file vdebug.c.

◆ vsllink_adapter_driver

struct adapter_driver vsllink_adapter_driver
extern

Definition at line 916 of file vsllink.c.

◆ xds110_adapter_driver

struct adapter_driver xds110_adapter_driver
extern

Definition at line 2061 of file xds110.c.

◆ xlnx_pcie_xvc_adapter_driver

struct adapter_driver xlnx_pcie_xvc_adapter_driver
extern

Definition at line 693 of file xlnx-pcie-xvc.c.