37 #define JTAG_DP_ABORT 0xF8
38 #define JTAG_DP_DPACC 0xFA
39 #define JTAG_DP_APACC 0xFB
40 #define JTAG_DP_IDCODE 0xFE
43 #define JTAG_ACK_WAIT 0x1
44 #define JTAG_ACK_OK_FAULT 0x2
45 #define JTAG_ACK_FAULT 0x2
46 #define JTAG_ACK_OK 0x4
51 static const char *dap_reg_name(
struct adiv5_dap *dap, uint8_t instr, uint16_t reg_addr)
53 char *reg_name =
"UNK";
61 reg_name =
"CTRL/STAT";
127 #define MAX_DAP_COMMAND_NUM 65536
159 LOG_DEBUG(
"%s: %2s %6s %5s 0x%08x 0x%08x %2s", header,
179 uint8_t *outvalue, uint8_t *
invalue,
203 memcpy(
cmd->outvalue_buf, outvalue, 4);
260 cmd->fields[0].num_bits = 3;
262 cmd->fields[0].out_value = &
cmd->out_addr_buf;
263 cmd->fields[0].in_value = (ack) ? ack : &
cmd->ack;
270 cmd->fields[1].num_bits = 32;
271 cmd->fields[1].out_value =
cmd->outvalue_buf;
272 cmd->fields[1].in_value =
cmd->invalue;
320 uint8_t instr, uint16_t reg_addr, uint8_t rnw,
321 uint8_t *outvalue, uint8_t *invalue,
322 uint32_t memaccess_tck, uint8_t *ack)
348 uint32_t outvalue, uint32_t *
invalue,
351 uint8_t out_value_buf[4];
364 LOG_DEBUG_IO(
"DP BANK SELECT: %" PRIx32, (uint32_t)sel);
454 LOG_ERROR(
"Invalid ACK (%1x) in DAP response", el->
ack);
519 LOG_ERROR(
"Invalid ACK (%1x) in DAP response", tmp->
ack);
530 LOG_ERROR(
"Timeout during WAIT recovery");
569 LOG_INFO(
"DAP transaction stalled (WAIT) - slowing down and resending");
581 uint8_t out_value_buf[4];
612 LOG_ERROR(
"Invalid ACK (%1x) in DAP response", el->
ack);
617 LOG_DEBUG(
"DAP transaction stalled during replay (WAIT) - resending");
628 LOG_ERROR(
"Timeout during WAIT recovery");
655 uint32_t ctrlstat, pwrmask;
671 LOG_DEBUG(
"jtag-dp: CTRL/STAT 0x%" PRIx32, ctrlstat);
676 if ((ctrlstat & pwrmask) != pwrmask) {
677 LOG_ERROR(
"Debug regions are unpowered, an unexpected reset might have happened");
731 LOG_ERROR(
"Sequence %d not supported", seq);
779 bool set_select = !dap->
select_valid || (sel_diff & 0xffffffffull);
782 || sel_diff & (0xffffffffull << 32));
784 if (set_select && set_select1) {
798 LOG_DEBUG_IO(
"AP BANK SELECT: %" PRIx32, (uint32_t)sel);
808 LOG_DEBUG_IO(
"AP BANK SELECT1: %" PRIx32, (uint32_t)(sel >> 32));
887 return (retval2 !=
ERROR_OK) ? retval2 : retval;
const struct dap_ops jtag_dp_ops
#define JTAG_ACK_OK_FAULT
static int jtag_dp_sync(struct adiv5_dap *dap)
static int jtagdp_overrun_check(struct adiv5_dap *dap)
static int jtag_send_sequence(struct adiv5_dap *dap, enum swd_special_seq seq)
static int jtag_ap_q_bankselect(struct adiv5_ap *ap, unsigned int reg)
Select the AP register bank.
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_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 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.
static void flush_journal(struct adiv5_dap *dap, struct list_head *lh)
#define MAX_DAP_COMMAND_NUM
static void dap_cmd_release(struct adiv5_dap *dap, struct dap_cmd *cmd)
static int jtag_connect(struct adiv5_dap *dap)
static void jtag_quit(struct adiv5_dap *dap)
static int adi_jtag_dp_scan_cmd_sync(struct adiv5_dap *dap, struct dap_cmd *cmd, uint8_t *ack)
static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
static int jtagdp_transaction_endcheck(struct adiv5_dap *dap)
static int adi_jtag_finish_read(struct adiv5_dap *dap)
static int jtag_limit_queue_size(struct adiv5_dap *dap)
static int adi_jtag_dp_scan_cmd(struct adiv5_dap *dap, struct dap_cmd *cmd, uint8_t *ack)
static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
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.
static int jtag_dp_run(struct adiv5_dap *dap)
static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
static int jtag_check_reconnect(struct adiv5_dap *dap)
static int jtag_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
static void log_dap_cmd(struct adiv5_dap *dap, const char *header, struct dap_cmd *el)
Holds the interface to ARM cores.
int dap_dp_init(struct adiv5_dap *dap)
Initialize a DAP.
This defines formats and data structures used to talk to ADIv5 entities.
#define MEM_AP_REG_CSW(dap)
#define MEM_AP_REG_CFG(dap)
#define MEM_AP_REG_TAR(dap)
#define MEM_AP_REG_BD3(dap)
#define MEM_AP_REG_BD1(dap)
#define MEM_AP_REG_DRW(dap)
#define MEM_AP_REG_BASE(dap)
#define MEM_AP_REG_BD2(dap)
#define MEM_AP_REG_BASE64(dap)
#define MEM_AP_REG_BD0(dap)
static bool is_adiv6(const struct adiv5_dap *dap)
Check if DAP is ADIv6.
#define MEM_AP_REG_TAR64(dap)
static int dap_run(struct adiv5_dap *dap)
Perform all queued DAP operations, and clear any errors posted in the CTRL_STAT register when they ar...
#define ADIV5_DP_SELECT_APBANK
static int arm_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
static void arm_le_to_h_u32(jtag_callback_data_t arg)
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
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.
void jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
Goes to TAP_IDLE (if we're not already there), cycle precisely num_cycles in the TAP_IDLE state,...
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
int jtag_add_tms_seq(unsigned int nbits, const uint8_t *seq, enum tap_state state)
If supported by the underlying adapter, this clocks a raw bit sequence onto TMS for switching between...
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
Generate a DR SCAN using the fields passed to the function.
void jtag_add_callback(jtag_callback1_t f, jtag_callback_data_t data0)
A simpler version of jtag_add_callback4().
#define ERROR_JTAG_DEVICE_ERROR
intptr_t jtag_callback_data_t
Defines the type of data passed to the jtag_callback_t interface.
static void list_add(struct list_head *new, struct list_head *head)
static void list_move_tail(struct list_head *entry, struct list_head *head)
#define list_first_entry(ptr, type, member)
#define list_for_each_entry_from(p, h, field)
static void list_add_tail(struct list_head *new, struct list_head *head)
static int list_empty(const struct list_head *head)
#define list_for_each_entry_safe(p, n, h, field)
#define list_for_each_entry(p, h, field)
static void list_del(struct list_head *entry)
#define list_for_each_entry_safe_from(pos, n, head, member)
#define list_entry(ptr, type, field)
static void INIT_LIST_HEAD(struct list_head *list)
#define LOG_DEBUG_IO(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
This represents an ARM Debug Interface (v5) Access Port (AP).
uint64_t ap_num
ADIv5: Number of this AP (0~255) ADIv6: Base address of this AP (4k aligned) TODO: to be more coheren...
struct adiv5_dap * dap
DAP this AP belongs to.
uint32_t memaccess_tck
Configures how many extra tck clocks are added after starting a MEM-AP access before we try to read i...
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
struct list_head cmd_journal
bool select_valid
Validity of DP SELECT cache.
struct adiv5_ap ap[DP_APSEL_MAX+1]
bool do_reconnect
Signals that an attempt to reestablish communication afresh should be performed before the next acces...
uint32_t * last_read
Holds the pointer to the destination word for the last queued read, for use with posted AP read seque...
uint64_t select
Cache for DP SELECT and SELECT1 (ADIv6) register.
struct list_head cmd_pool
bool ignore_syspwrupack
Flag saying whether to ignore the syspwrupack flag in DAP.
struct scan_field fields[2]
Transport-neutral representation of queued DAP transactions, supporting both JTAG and SWD transports.
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
This structure defines a single scan field in the scan.
static const unsigned int swd_seq_jtag_to_swd_len
static const uint8_t swd_seq_jtag_to_swd[]
JTAG-to-SWD sequence.
static const uint8_t swd_seq_swd_to_jtag[]
SWD-to-JTAG sequence.
static const unsigned int swd_seq_swd_to_jtag_len
static uint32_t le_to_h_u32(const uint8_t *buf)
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.