OpenOCD
adi_v5_jtag.c File Reference

This file implements JTAG transport support for cores implementing the ARM Debug Interface version 5 (ADIv5) and version 6 (ADIv6). More...

Include dependency graph for adi_v5_jtag.c:

Go to the source code of this file.

Data Structures

struct  dap_cmd
 
struct  dap_cmd_pool
 

Macros

#define JTAG_ACK_FAULT   0x2 /* ADIv6 */
 
#define JTAG_ACK_OK   0x4 /* ADIV6 */
 
#define JTAG_ACK_OK_FAULT   0x2 /* ADIv5 */
 
#define JTAG_ACK_WAIT   0x1 /* ADIv5 and ADIv6 */
 
#define JTAG_DP_ABORT   0xF8
 
#define JTAG_DP_APACC   0xFB
 
#define JTAG_DP_DPACC   0xFA
 
#define JTAG_DP_IDCODE   0xFE
 
#define MAX_DAP_COMMAND_NUM   65536
 

Functions

static int adi_jtag_dp_scan (struct adiv5_dap *dap, uint8_t instr, uint16_t reg_addr, uint8_t rnw, uint8_t *outvalue, uint8_t *invalue, uint32_t memaccess_tck, uint8_t *ack)
 Scan DPACC or APACC using target ordered uint8_t buffers. More...
 
static int adi_jtag_dp_scan_cmd (struct adiv5_dap *dap, struct dap_cmd *cmd, uint8_t *ack)
 
static int adi_jtag_dp_scan_cmd_sync (struct adiv5_dap *dap, struct dap_cmd *cmd, uint8_t *ack)
 
static int adi_jtag_dp_scan_u32 (struct adiv5_dap *dap, uint8_t instr, uint16_t reg_addr, uint8_t rnw, uint32_t outvalue, uint32_t *invalue, uint32_t memaccess_tck, uint8_t *ack)
 Scan DPACC or APACC out and in from host ordered uint32_t buffers. More...
 
static int adi_jtag_finish_read (struct adiv5_dap *dap)
 
static int adi_jtag_scan_inout_check_u32 (struct adiv5_dap *dap, uint8_t instr, uint16_t reg_addr, uint8_t rnw, uint32_t outvalue, uint32_t *invalue, uint32_t memaccess_tck)
 
static struct dap_cmddap_cmd_new (struct adiv5_dap *dap, uint8_t instr, uint16_t reg_addr, uint8_t rnw, uint8_t *outvalue, uint8_t *invalue, uint32_t memaccess_tck)
 
static void dap_cmd_release (struct adiv5_dap *dap, struct dap_cmd *cmd)
 
static void flush_journal (struct adiv5_dap *dap, struct list_head *lh)
 
static int jtag_ap_q_abort (struct adiv5_dap *dap, uint8_t *ack)
 
static int jtag_ap_q_bankselect (struct adiv5_ap *ap, unsigned int reg)
 Select the AP register bank. More...
 
static int jtag_ap_q_read (struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
 
static int jtag_ap_q_write (struct adiv5_ap *ap, unsigned int reg, uint32_t data)
 
static int jtag_check_reconnect (struct adiv5_dap *dap)
 
static int jtag_connect (struct adiv5_dap *dap)
 
static int jtag_dp_q_read (struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
 
static int jtag_dp_q_write (struct adiv5_dap *dap, unsigned int reg, uint32_t data)
 
static int jtag_dp_run (struct adiv5_dap *dap)
 
static int jtag_dp_sync (struct adiv5_dap *dap)
 
static int jtag_limit_queue_size (struct adiv5_dap *dap)
 
static void jtag_quit (struct adiv5_dap *dap)
 
static int jtag_send_sequence (struct adiv5_dap *dap, enum swd_special_seq seq)
 
static int jtagdp_overrun_check (struct adiv5_dap *dap)
 
static int jtagdp_transaction_endcheck (struct adiv5_dap *dap)
 
static void log_dap_cmd (struct adiv5_dap *dap, const char *header, struct dap_cmd *el)
 

Variables

const struct dap_ops jtag_dp_ops
 

Detailed Description

This file implements JTAG transport support for cores implementing the ARM Debug Interface version 5 (ADIv5) and version 6 (ADIv6).

Definition in file adi_v5_jtag.c.

Macro Definition Documentation

◆ JTAG_ACK_FAULT

#define JTAG_ACK_FAULT   0x2 /* ADIv6 */

Definition at line 45 of file adi_v5_jtag.c.

◆ JTAG_ACK_OK

#define JTAG_ACK_OK   0x4 /* ADIV6 */

Definition at line 46 of file adi_v5_jtag.c.

◆ JTAG_ACK_OK_FAULT

#define JTAG_ACK_OK_FAULT   0x2 /* ADIv5 */

Definition at line 44 of file adi_v5_jtag.c.

◆ JTAG_ACK_WAIT

#define JTAG_ACK_WAIT   0x1 /* ADIv5 and ADIv6 */

Definition at line 43 of file adi_v5_jtag.c.

◆ JTAG_DP_ABORT

#define JTAG_DP_ABORT   0xF8

Definition at line 37 of file adi_v5_jtag.c.

◆ JTAG_DP_APACC

#define JTAG_DP_APACC   0xFB

Definition at line 39 of file adi_v5_jtag.c.

◆ JTAG_DP_DPACC

#define JTAG_DP_DPACC   0xFA

Definition at line 38 of file adi_v5_jtag.c.

◆ JTAG_DP_IDCODE

#define JTAG_DP_IDCODE   0xFE

Definition at line 40 of file adi_v5_jtag.c.

◆ MAX_DAP_COMMAND_NUM

#define MAX_DAP_COMMAND_NUM   65536

Definition at line 127 of file adi_v5_jtag.c.

Function Documentation

◆ adi_jtag_dp_scan()

static int adi_jtag_dp_scan ( struct adiv5_dap dap,
uint8_t  instr,
uint16_t  reg_addr,
uint8_t  rnw,
uint8_t *  outvalue,
uint8_t *  invalue,
uint32_t  memaccess_tck,
uint8_t *  ack 
)
static

Scan DPACC or APACC using target ordered uint8_t buffers.

No endianness conversions are performed. See section 4.4.3 of the ADIv5/ADIv6 spec, which discusses operations which access these registers.

Note that only one scan is performed. If rnw is set, a separate scan will be needed to collect the data which was read; the "invalue" collects the posted result of a preceding operation, not the current one.

Parameters
dapthe DAP
instrJTAG_DP_APACC (AP access) or JTAG_DP_DPACC (DP access)
reg_addrtwo significant bits; A[3:2]; for APACC access, the SELECT register has more addressing bits.
rnwfalse iff outvalue will be written to the DP or AP
outvaluepoints to a 32-bit (little-endian) integer
invalueNULL, or points to a 32-bit (little-endian) integer
ackpoints to where the three bit JTAG_ACK_* code will be stored
memaccess_tcknumber of idle cycles to add after AP access

Definition at line 319 of file adi_v5_jtag.c.

References dap_cmd::ack, adi_jtag_dp_scan_cmd(), cmd, adiv5_dap::cmd_journal, dap_cmd_new(), ERROR_JTAG_DEVICE_ERROR, ERROR_OK, dap_cmd::instr, dap_cmd::invalue, list_add_tail(), dap_cmd::memaccess_tck, dap_cmd::reg_addr, dap_cmd::rnw, and adiv5_dap::select.

Referenced by adi_jtag_dp_scan_u32().

◆ adi_jtag_dp_scan_cmd()

static int adi_jtag_dp_scan_cmd ( struct adiv5_dap dap,
struct dap_cmd cmd,
uint8_t *  ack 
)
static

◆ adi_jtag_dp_scan_cmd_sync()

static int adi_jtag_dp_scan_cmd_sync ( struct adiv5_dap dap,
struct dap_cmd cmd,
uint8_t *  ack 
)
static

Definition at line 288 of file adi_v5_jtag.c.

References adi_jtag_dp_scan_cmd(), cmd, ERROR_OK, and jtag_execute_queue().

Referenced by jtagdp_overrun_check().

◆ adi_jtag_dp_scan_u32()

static int adi_jtag_dp_scan_u32 ( struct adiv5_dap dap,
uint8_t  instr,
uint16_t  reg_addr,
uint8_t  rnw,
uint32_t  outvalue,
uint32_t *  invalue,
uint32_t  memaccess_tck,
uint8_t *  ack 
)
static

Scan DPACC or APACC out and in from host ordered uint32_t buffers.

This is exactly like adi_jtag_dp_scan(), except that endianness conversions are performed (so the types of invalue and outvalue must be different).

Definition at line 346 of file adi_v5_jtag.c.

References dap_cmd::ack, adi_jtag_dp_scan(), arm_le_to_h_u32(), buf_set_u32(), DP_RDBUFF, DP_SELECT, DP_SELECT_DPBANK, DPAP_WRITE, ERROR_OK, dap_cmd::instr, dap_cmd::invalue, jtag_add_callback(), JTAG_DP_DPACC, LOG_DEBUG_IO, dap_cmd::memaccess_tck, NULL, dap_cmd::reg_addr, dap_cmd::rnw, adiv5_dap::select, SELECT_AP_MASK, and adiv5_dap::select_valid.

Referenced by adi_jtag_finish_read(), adi_jtag_scan_inout_check_u32(), jtag_ap_q_abort(), jtag_ap_q_read(), jtag_ap_q_write(), jtag_dp_q_read(), and jtag_dp_q_write().

◆ adi_jtag_finish_read()

static int adi_jtag_finish_read ( struct adiv5_dap dap)
static

Definition at line 390 of file adi_v5_jtag.c.

References adi_jtag_dp_scan_u32(), DP_RDBUFF, DPAP_READ, ERROR_OK, JTAG_DP_DPACC, adiv5_dap::last_read, and NULL.

Referenced by jtag_dp_run().

◆ adi_jtag_scan_inout_check_u32()

static int adi_jtag_scan_inout_check_u32 ( struct adiv5_dap dap,
uint8_t  instr,
uint16_t  reg_addr,
uint8_t  rnw,
uint32_t  outvalue,
uint32_t *  invalue,
uint32_t  memaccess_tck 
)
static

◆ dap_cmd_new()

static struct dap_cmd* dap_cmd_new ( struct adiv5_dap dap,
uint8_t  instr,
uint16_t  reg_addr,
uint8_t  rnw,
uint8_t *  outvalue,
uint8_t *  invalue,
uint32_t  memaccess_tck 
)
static

◆ dap_cmd_release()

static void dap_cmd_release ( struct adiv5_dap dap,
struct dap_cmd cmd 
)
static

◆ flush_journal()

static void flush_journal ( struct adiv5_dap dap,
struct list_head lh 
)
static

◆ jtag_ap_q_abort()

static int jtag_ap_q_abort ( struct adiv5_dap dap,
uint8_t *  ack 
)
static

◆ jtag_ap_q_bankselect()

static int jtag_ap_q_bankselect ( struct adiv5_ap ap,
unsigned int  reg 
)
static

◆ jtag_ap_q_read()

static int jtag_ap_q_read ( struct adiv5_ap ap,
unsigned int  reg,
uint32_t *  data 
)
static

◆ jtag_ap_q_write()

static int jtag_ap_q_write ( struct adiv5_ap ap,
unsigned int  reg,
uint32_t  data 
)
static

◆ jtag_check_reconnect()

static int jtag_check_reconnect ( struct adiv5_dap dap)
static

Definition at line 709 of file adi_v5_jtag.c.

References adiv5_dap::do_reconnect, ERROR_OK, and jtag_connect().

Referenced by jtag_ap_q_read(), and jtag_ap_q_write().

◆ jtag_connect()

static int jtag_connect ( struct adiv5_dap dap)
static

Definition at line 703 of file adi_v5_jtag.c.

References dap_dp_init(), and adiv5_dap::do_reconnect.

Referenced by jtag_check_reconnect().

◆ jtag_dp_q_read()

static int jtag_dp_q_read ( struct adiv5_dap dap,
unsigned int  reg,
uint32_t *  data 
)
static

◆ jtag_dp_q_write()

static int jtag_dp_q_write ( struct adiv5_dap dap,
unsigned int  reg,
uint32_t  data 
)
static

◆ jtag_dp_run()

static int jtag_dp_run ( struct adiv5_dap dap)
static

◆ jtag_dp_sync()

static int jtag_dp_sync ( struct adiv5_dap dap)
static

Definition at line 890 of file adi_v5_jtag.c.

◆ jtag_limit_queue_size()

static int jtag_limit_queue_size ( struct adiv5_dap dap)
static

◆ jtag_quit()

static void jtag_quit ( struct adiv5_dap dap)
static

◆ jtag_send_sequence()

◆ jtagdp_overrun_check()

◆ jtagdp_transaction_endcheck()

◆ log_dap_cmd()

static void log_dap_cmd ( struct adiv5_dap dap,
const char *  header,
struct dap_cmd el 
)
static

Variable Documentation

◆ jtag_dp_ops

const struct dap_ops jtag_dp_ops
Initial value:
= {
.connect = jtag_connect,
.send_sequence = jtag_send_sequence,
.queue_dp_read = jtag_dp_q_read,
.queue_dp_write = jtag_dp_q_write,
.queue_ap_read = jtag_ap_q_read,
.queue_ap_write = jtag_ap_q_write,
.queue_ap_abort = jtag_ap_q_abort,
.run = jtag_dp_run,
.sync = jtag_dp_sync,
.quit = jtag_quit,
}
static int jtag_dp_sync(struct adiv5_dap *dap)
Definition: adi_v5_jtag.c:890
static int jtag_send_sequence(struct adiv5_dap *dap, enum swd_special_seq seq)
Definition: adi_v5_jtag.c:717
static int jtag_connect(struct adiv5_dap *dap)
Definition: adi_v5_jtag.c:703
static void jtag_quit(struct adiv5_dap *dap)
Definition: adi_v5_jtag.c:231
static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
Definition: adi_v5_jtag.c:752
static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
Definition: adi_v5_jtag.c:821
static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
Definition: adi_v5_jtag.c:864
static int jtag_dp_run(struct adiv5_dap *dap)
Definition: adi_v5_jtag.c:875
static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
Definition: adi_v5_jtag.c:739
static int jtag_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
Definition: adi_v5_jtag.c:843

Definition at line 890 of file adi_v5_jtag.c.

Referenced by dap_init_all().