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];
353 uint64_t sel = (
reg_addr >> 4) & 0xf;
357 sel != (dap->
select & 0xf)) {
359 sel |= dap->
select & ~0xfull;
361 LOG_DEBUG(
"DP BANKSEL: %x", (uint32_t)sel);
446 LOG_ERROR(
"Invalid ACK (%1x) in DAP response", el->
ack);
511 LOG_ERROR(
"Invalid ACK (%1x) in DAP response", tmp->
ack);
522 LOG_ERROR(
"Timeout during WAIT recovery");
558 LOG_INFO(
"DAP transaction stalled (WAIT) - slowing down and resending");
595 LOG_ERROR(
"Invalid ACK (%1x) in DAP response", el->
ack);
600 LOG_DEBUG(
"DAP transaction stalled during replay (WAIT) - resending");
611 LOG_ERROR(
"Timeout during WAIT recovery");
635 uint32_t ctrlstat, pwrmask;
651 LOG_DEBUG(
"jtag-dp: CTRL/STAT 0x%" PRIx32, ctrlstat);
656 if ((ctrlstat & pwrmask) != pwrmask) {
657 LOG_ERROR(
"Debug regions are unpowered, an unexpected reset might have happened");
711 LOG_ERROR(
"Sequence %d not supported", seq);
754 if (sel == (dap->
select & ~0xfull))
848 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_write(struct adiv5_ap *ap, unsigned reg, uint32_t data)
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 int jtag_dp_q_read(struct adiv5_dap *dap, unsigned reg, uint32_t *data)
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 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_bankselect(struct adiv5_ap *ap, unsigned reg)
Select the AP register bank matching bits 7:4 of reg.
static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned reg, uint32_t *data)
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_check_reconnect(struct adiv5_dap *dap)
static void log_dap_cmd(struct adiv5_dap *dap, const char *header, struct dap_cmd *el)
static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned reg, uint32_t data)
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 DP_SELECT_INVALID
#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...
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 first, unsigned 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 first, unsigned num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
int jtag_add_tms_seq(unsigned 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...
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
void jtag_add_runtest(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,...
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)
list_add - add a new entry
static void list_move_tail(struct list_head *list, struct list_head *head)
list_move_tail - delete from one list and add as another's tail
#define list_entry(ptr, type, member)
list_entry - get the struct for this entry
#define list_first_entry(ptr, type, member)
list_first_entry - get the first element from a list
#define list_for_each_entry_from(pos, head, member)
list_for_each_entry_from - iterate over list of given type from the current point
static void list_add_tail(struct list_head *new, struct list_head *head)
list_add_tail - add a new entry
static int list_empty(const struct list_head *head)
list_empty - tests whether a list is empty
#define list_for_each_entry(pos, head, member)
list_for_each_entry - iterate over list of given type
static void list_del(struct list_head *entry)
list_del - deletes entry from list.
#define list_for_each_entry_safe_from(pos, n, head, member)
list_for_each_entry_safe_from - iterate over list from current point safe against removal
#define list_for_each_entry_safe(pos, n, head, member)
list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
static void INIT_LIST_HEAD(struct list_head *list)
INIT_LIST_HEAD - Initialize a list_head structure.
#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
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 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 swd_seq_swd_to_jtag_len
static const unsigned 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 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.