OpenOCD
interface.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2005 by Dominic Rath *
5  * Dominic.Rath@gmx.de *
6  * *
7  * Copyright (C) 2007,2008 Øyvind Harboe *
8  * oyvind.harboe@zylin.com *
9  * *
10  * Copyright (C) 2009 Zachary T Welch *
11  * zw@superlucidity.net *
12  ***************************************************************************/
13 
14 #ifndef OPENOCD_JTAG_INTERFACE_H
15 #define OPENOCD_JTAG_INTERFACE_H
16 
17 #include <jtag/jtag.h>
18 #include <jtag/swim.h>
19 #include <target/arm_tpiu_swo.h>
20 
21 /* @file
22  * The "Cable Helper API" is what the cable drivers can use to help
23  * implement their "Cable API". So a Cable Helper API is a set of
24  * helper functions used by cable drivers, and this is different from a
25  * Cable API. A "Cable API" is what higher level code used to talk to a
26  * cable.
27  */
28 
29 
31 void tap_set_state_impl(tap_state_t new_state);
32 
49 #define tap_set_state(new_state) \
50  do { \
51  LOG_DEBUG_IO("tap_set_state(%s)", tap_state_name(new_state)); \
52  tap_set_state_impl(new_state); \
53  } while (0)
54 
61 
73 void tap_set_end_state(tap_state_t new_end_state);
74 
80 
95 
113 
114 
128 int tap_move_ndx(tap_state_t astate);
129 
134 bool tap_is_state_stable(tap_state_t astate);
135 
143 tap_state_t tap_state_transition(tap_state_t current_state, bool tms);
144 
146 void tap_use_new_tms_table(bool use_new);
148 bool tap_uses_new_tms_table(void);
149 
150 
159 static inline tap_state_t jtag_debug_state_machine(const void *tms_buf,
160  const void *tdi_buf, unsigned tap_len, tap_state_t start_tap_state)
161 {
162  /* Private declaration */
163  tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf,
164  unsigned tap_len, tap_state_t start_tap_state);
165 
167  return jtag_debug_state_machine_(tms_buf, tdi_buf, tap_len, start_tap_state);
168  else
169  return start_tap_state;
170 }
171 
188  unsigned supported;
189 #define DEBUG_CAP_TMS_SEQ (1 << 0)
190 
195  int (*execute_queue)(void);
196 };
197 
209  const char * const name;
210 
212  const char * const *transports;
213 
219 
231  int (*init)(void);
232 
239  int (*quit)(void);
240 
255  int (*reset)(int srst, int trst);
256 
262  int (*speed)(int speed);
263 
274  int (*khz)(int khz, int *jtag_speed);
275 
283  int (*speed_div)(int speed, int *khz);
284 
297 
311 
326  int (*config_trace)(bool enabled, enum tpiu_pin_protocol pin_protocol,
327  uint32_t port_size, unsigned int *trace_freq,
328  unsigned int traceclkin_freq, uint16_t *prescaler);
329 
339  int (*poll_trace)(uint8_t *buf, size_t *size);
340 
343 
345  const struct swd_driver *swd_ops;
346 
347  /* DAP APIs over JTAG transport */
348  const struct dap_ops *dap_jtag_ops;
349 
350  /* DAP APIs over SWD transport */
351  const struct dap_ops *dap_swd_ops;
352 
353  /* SWIM APIs */
354  const struct swim_driver *swim_ops;
355 };
356 
357 extern const char * const jtag_only[];
358 
359 int adapter_resets(int assert_trst, int assert_srst);
360 int adapter_assert_reset(void);
361 int adapter_deassert_reset(void);
362 int adapter_config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol,
363  uint32_t port_size, unsigned int *trace_freq,
364  unsigned int traceclkin_freq, uint16_t *prescaler);
365 int adapter_poll_trace(uint8_t *buf, size_t *size);
366 
367 #endif /* OPENOCD_JTAG_INTERFACE_H */
tpiu_pin_protocol
Definition: arm_tpiu_swo.h:7
tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf, unsigned tap_bits, tap_state_t next_state)
Definition: interface.c:374
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 t...
Definition: interface.c:223
static tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf, unsigned tap_len, tap_state_t start_tap_state)
Prints verbose TAP state transitions for the given TMS/TDI buffers.
Definition: interface.h:159
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
const char *const jtag_only[]
Definition: adapter.c:31
int adapter_resets(int assert_trst, int assert_srst)
Definition: jtag/core.c:1833
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
void tap_use_new_tms_table(bool use_new)
Allow switching between old and new TMS tables.
Definition: interface.c:447
tap_state_t tap_get_end_state(void)
For more information,.
Definition: interface.c:56
bool tap_uses_new_tms_table(void)
Definition: interface.c:451
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
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: jtag/core.c:1917
int adapter_poll_trace(uint8_t *buf, size_t *size)
Definition: jtag/core.c:1932
int tap_move_ndx(tap_state_t astate)
Function tap_move_ndx when given a stable state, returns an index from 0-5.
Definition: interface.c:61
void tap_set_state_impl(tap_state_t new_state)
implementation of wrapper function tap_set_state()
Definition: interface.c:31
int adapter_deassert_reset(void)
Definition: jtag/core.c:1900
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
int adapter_assert_reset(void)
Definition: jtag/core.c:1880
The JTAG interface can be implemented with a software or hardware fifo.
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
#define LOG_LEVEL_IS(FOO)
Definition: log.h:99
@ LOG_LVL_DEBUG_IO
Definition: log.h:48
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
struct jtag_interface * jtag_ops
Low-level JTAG APIs.
Definition: interface.h:342
int(* 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)
Configure trace parameters for the adapter.
Definition: interface.h:326
int(* speed)(int speed)
Set the interface speed.
Definition: interface.h:262
const struct swim_driver * swim_ops
Definition: interface.h:354
int(* khz)(int khz, int *jtag_speed)
Returns JTAG maximum speed for KHz.
Definition: interface.h:274
const struct command_registration * commands
The interface driver may register additional commands to expose additional features not covered by th...
Definition: interface.h:218
int(* speed_div)(int speed, int *khz)
Calculate the clock frequency (in KHz) for the given speed.
Definition: interface.h:283
int(* init)(void)
Interface driver must initialize any resources and connect to a JTAG device.
Definition: interface.h:231
const struct swd_driver * swd_ops
Low-level SWD APIs.
Definition: interface.h:345
int(* reset)(int srst, int trst)
Control (assert/deassert) the signals SRST and TRST on the interface.
Definition: interface.h:255
const struct dap_ops * dap_swd_ops
Definition: interface.h:351
int(* power_dropout)(int *power_dropout)
Read and clear the power dropout flag.
Definition: interface.h:296
const char *const * transports
transports supported in C code (NULL terminated vector)
Definition: interface.h:212
const struct dap_ops * dap_jtag_ops
Definition: interface.h:348
int(* poll_trace)(uint8_t *buf, size_t *size)
Poll for new trace data.
Definition: interface.h:339
int(* srst_asserted)(int *srst_asserted)
Read and clear the srst asserted detection flag.
Definition: interface.h:310
const char *const name
The name of the interface driver.
Definition: interface.h:209
int(* quit)(void)
Interface driver must tear down all resources and disconnect from the JTAG device.
Definition: interface.h:239
Transport-neutral representation of queued DAP transactions, supporting both JTAG and SWD transports.
Definition: arm_adi_v5.h:408
Represents a driver for a debugging interface.
Definition: interface.h:184
unsigned supported
Bit vector listing capabilities exposed by this driver.
Definition: interface.h:188
int(* execute_queue)(void)
Execute queued commands.
Definition: interface.h:195
This file implements support for STMicroelectronics debug protocol SWIM (Single Wire Interface Module...