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) {
119 if ((batch->
fields + i)->in_value)
124 for (
size_t i = 0; i < batch->
used_scans; ++i)
161 assert(key < batch->read_keys_used);
163 assert(index <= batch->used_scans);
171 assert(key < batch->read_keys_used);
173 assert(index <= batch->used_scans);
194 static const char *
const op_string[] = {
"-",
"r",
"w",
"?"};
195 static const char *
const status_string[] = {
"+",
"?",
"F",
"b"};
213 __FILE__, __LINE__, __PRETTY_FUNCTION__,
214 "%ub %s %08x @%02x -> %s %08x @%02x; %di",
215 field->
num_bits, op_string[out_op], out_data, out_address,
216 status_string[in_op], in_data, in_address, idle);
219 __FILE__, __LINE__, __PRETTY_FUNCTION__,
"%ub %s %08x @%02x -> ?; %di",
220 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)
size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address)
void riscv_batch_add_nop(struct riscv_batch *batch)
uint32_t riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key)
#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 int address, uint64_t data)
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 int buf_len, unsigned int count)
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 uint64_t buf_get_u64(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 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
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.
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 int 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.
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.
unsigned int num_bits
The number of bits this field specifies.