11 #define get_field(reg, mask) (((reg) & (mask)) / ((mask) & ~((mask) << 1)))
12 #define set_field(reg, mask, val) (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask)))
14 #define DTM_DMI_MAX_ADDRESS_LENGTH ((1<<DTM_DTMCS_ABITS_LENGTH)-1)
15 #define DMI_SCAN_MAX_BIT_LENGTH (DTM_DMI_MAX_ADDRESS_LENGTH + DTM_DMI_DATA_LENGTH + DTM_DMI_OP_LENGTH)
16 #define DMI_SCAN_BUF_SIZE (DIV_ROUND_UP(DMI_SCAN_MAX_BIT_LENGTH, 8))
31 LOG_ERROR(
"Failed to allocate data_out in RISC-V batch.");
36 LOG_ERROR(
"Failed to allocate data_in in RISC-V batch.");
41 LOG_ERROR(
"Failed to allocate fields in RISC-V batch.");
47 LOG_ERROR(
"Failed to allocate bscan_ctxt in RISC-V batch.");
54 LOG_ERROR(
"Failed to allocate read_keys in RISC-V batch.");
97 for (
size_t i = 0; i < batch->
used_scans; ++i) {
110 LOG_ERROR(
"Unable to execute JTAG queue");
118 for (
size_t i = 0; i < batch->
used_scans; ++i)
122 for (
size_t i = 0; i < batch->
used_scans; ++i)
159 assert(key < batch->read_keys_used);
161 assert(index <= batch->used_scans);
169 assert(key < batch->read_keys_used);
171 assert(index <= batch->used_scans);
192 static const char *
const op_string[] = {
"-",
"r",
"w",
"?"};
193 static const char *
const status_string[] = {
"+",
"?",
"F",
"b"};
211 __FILE__, __LINE__, __PRETTY_FUNCTION__,
212 "%db %s %08x @%02x -> %s %08x @%02x; %di",
213 field->
num_bits, op_string[out_op], out_data, out_address,
214 status_string[in_op], in_data, in_address, idle);
217 __FILE__, __LINE__, __PRETTY_FUNCTION__,
"%db %s %08x @%02x -> ?; %di",
218 field->
num_bits, op_string[out_op], out_data, out_address, idle);
uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key)
void riscv_batch_add_nop(struct riscv_batch *batch)
size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address)
#define DMI_SCAN_BUF_SIZE
size_t riscv_batch_available_scans(struct riscv_batch *batch)
struct riscv_batch * riscv_batch_alloc(struct target *target, size_t scans, size_t idle)
int riscv_batch_run(struct riscv_batch *batch)
#define get_field(reg, mask)
void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data)
unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key)
void riscv_batch_free(struct riscv_batch *batch)
static void dump_field(int idle, const struct scan_field *field)
bool riscv_batch_full(struct riscv_batch *batch)
@ RISCV_SCAN_TYPE_INVALID
void buffer_shr(void *_buf, unsigned buf_len, unsigned count)
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 uint64_t buf_get_u64(const uint8_t *_buffer, unsigned first, unsigned num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 64-bit word.
#define DTM_DMI_DATA_OFFSET
#define DTM_DMI_OP_OFFSET
#define DTM_DMI_ADDRESS_OFFSET
#define DTM_DMI_DATA_LENGTH
#define DTM_DMI_OP_LENGTH
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 log_printf_lf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format,...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
void riscv_fill_dmi_nop_u64(struct target *target, char *buf)
void riscv_add_bscan_tunneled_scan(struct target *target, struct scan_field *field, riscv_bscan_tunneled_scan_context_t *ctxt)
int riscv_dmi_write_u64_bits(struct target *target)
void riscv_fill_dmi_write_u64(struct target *target, char *buf, int a, uint64_t d)
void riscv_fill_dmi_read_u64(struct target *target, char *buf, int a)
int bscan_tunnel_ir_width
riscv_bscan_tunneled_scan_context_t * bscan_ctxt
enum riscv_scan_type last_scan
struct scan_field * fields
This structure defines a single scan field in the scan.
int num_bits
The number of bits this field specifies.
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
const uint8_t * out_value
A pointer to value to be scanned into the device.