47 int bypass_devices = 0;
66 for (
unsigned int i = 0; i < num_fields; ++i)
103 int num_out_fields,
struct scan_field *out_fields)
105 int num_fields = 2 + num_out_fields;
119 for (
int i = 0; i < num_out_fields; ++i)
128 int num_in_fields,
struct scan_field *in_fields)
135 int r_size = num_in_bytes ? num_in_bytes * 2 : 1;
148 fields[2].
num_bits = num_in_bits * 2;
159 if (num_in_fields > 0) {
163 for (
int i = 0; i < num_in_fields; ++i) {
176 LOG_ERROR(
"esirisc_jtag: bad status: 0x%02" PRIx8
" (DA: %" PRId32
", "
177 "S: %" PRId32
", EID: 0x%02" PRIx8
")",
187 int num_out_fields,
struct scan_field *out_fields,
188 int num_in_fields,
struct scan_field *in_fields)
216 return !!(jtag_info->
status & 1<<7);
221 return !!(jtag_info->
status & 1<<6);
226 return jtag_info->
status & 0x3f;
260 LOG_DEBUG(
"address: 0x%" PRIx32
", data: 0x%" PRIx8, address, *data);
288 LOG_DEBUG(
"address: 0x%" PRIx32
", data: 0x%" PRIx16, address, *data);
316 LOG_DEBUG(
"address: 0x%" PRIx32
", data: 0x%" PRIx32, address, *data);
326 LOG_DEBUG(
"address: 0x%" PRIx32
", data: 0x%" PRIx8, address, data);
346 LOG_DEBUG(
"address: 0x%" PRIx32
", data: 0x%" PRIx16, address, data);
367 LOG_DEBUG(
"address: 0x%" PRIx32
", data: 0x%" PRIx32, address, data);
404 LOG_DEBUG(
"register: 0x%" PRIx8
", data: 0x%" PRIx32,
reg, *data);
414 LOG_DEBUG(
"register: 0x%" PRIx8
", data: 0x%" PRIx32,
reg, data);
452 LOG_DEBUG(
"bank: 0x%" PRIx8
", csr: 0x%" PRIx8
", data: 0x%" PRIx32,
bank,
csr, *data);
462 LOG_DEBUG(
"bank: 0x%" PRIx8
", csr: 0x%" PRIx8
", data: 0x%" PRIx32,
bank,
csr, data);
void * buf_set_buf(const void *_src, unsigned int src_start, void *_dst, unsigned int dst_start, unsigned int len)
Support functions to access arbitrary bits in a byte array.
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_scan_field_clone(struct scan_field *dst, const struct scan_field *src)
Copy a struct scan_field for insertion into the queue.
void * cmd_queue_alloc(size_t size)
int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t *data)
static int esirisc_jtag_get_padding(void)
int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info)
int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t *data)
int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t *data)
int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t data)
static int esirisc_jtag_send_and_recv(struct esirisc_jtag *jtag_info, uint8_t command, int num_out_fields, struct scan_field *out_fields, int num_in_fields, struct scan_field *in_fields)
int esirisc_jtag_continue(struct esirisc_jtag *jtag_info)
uint8_t esirisc_jtag_get_eid(struct esirisc_jtag *jtag_info)
static int esirisc_jtag_recv(struct esirisc_jtag *jtag_info, int num_in_fields, struct scan_field *in_fields)
int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info)
static int esirisc_jtag_send(struct esirisc_jtag *jtag_info, uint8_t command, int num_out_fields, struct scan_field *out_fields)
bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info)
static void esirisc_jtag_unstuff(uint8_t *data, size_t len)
int esirisc_jtag_disable_debug(struct esirisc_jtag *jtag_info)
int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t data)
static int esirisc_jtag_count_bits(unsigned int num_fields, struct scan_field *fields)
static int esirisc_jtag_check_status(struct esirisc_jtag *jtag_info)
int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t *data)
bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info)
int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info)
int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t data)
static int esirisc_jtag_send_ctrl(struct esirisc_jtag *jtag_info, uint8_t command)
static void esirisc_jtag_set_instr(struct esirisc_jtag *jtag_info, uint32_t new_instr)
int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t data)
int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info)
int esirisc_jtag_break(struct esirisc_jtag *jtag_info)
#define DEBUG_WRITE_HWORD
#define DEBUG_ASSERT_RESET
#define DEBUG_ENABLE_DEBUG
#define DEBUG_DEASSERT_RESET
#define DEBUG_DISABLE_DEBUG
#define DEBUG_FLUSH_CACHES
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
struct jtag_tap * jtag_tap_next_enabled(struct jtag_tap *p)
void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap_state_t state)
Generate an IR SCAN with a list of scan fields with one entry for each enabled TAP.
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.
The JTAG interface can be implemented with a software or hardware fifo.
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
uint8_t * cur_instr
current instruction
unsigned int ir_length
size of instruction register
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.
static void h_u32_to_be(uint8_t *buf, uint32_t val)
static void h_u16_to_be(uint8_t *buf, uint16_t val)
static uint16_t le_to_h_u16(const uint8_t *buf)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static uint32_t le_to_h_u32(const uint8_t *buf)