27 uint32_t current_instr;
29 uint8_t instr_buffer[
sizeof(uint32_t)] = {0};
32 assert(jtag_info->
tap);
38 if (current_instr == new_instr)
43 .out_value = instr_buffer
73 assert(jtag_info->
tap);
93 uint8_t
out_value[
sizeof(uint32_t)] = {0};
96 assert(jtag_info->
tap);
121 uint8_t
out_value[
sizeof(uint32_t)] = {0};
124 assert(jtag_info->
tap);
158 assert(jtag_info->
tap);
181 uint8_t
buffer[
sizeof(uint32_t)];
184 assert(jtag_info->
tap);
201 uint8_t *read_buffer,
const uint32_t *write_buffer, uint32_t
count)
205 for (i = 0; i <
count; i++) {
209 if (i == 0 || (
addr[i] !=
addr[i-1] + 1)) {
245 LOG_DEBUG(
"Writing to %s registers: addr[0]=0x%" PRIx32
";count=%" PRIu32
246 ";buffer[0]=0x%08" PRIx32,
250 LOG_ERROR(
"Trying to write 0 registers");
284 assert(jtag_info->
tap);
286 LOG_DEBUG(
"Reading %s registers: addr[0]=0x%" PRIx32
";count=%" PRIu32,
301 uint8_t *data_buf = calloc(
sizeof(uint8_t),
count * 4);
307 LOG_ERROR(
"Failed to execute jtag queue: %d", retval);
313 for (i = 0; i <
count; i++)
442 LOG_DEBUG(
"Writing to memory: addr=0x%08" PRIx32
";count=%" PRIu32
";buffer[0]=0x%08" PRIx32,
463 for (i = 0; i <
count; i++)
485 uint32_t
count, uint32_t *
buffer,
bool slow_memory)
493 assert(jtag_info->
tap);
495 LOG_DEBUG(
"Reading memory: addr=0x%" PRIx32
";count=%" PRIu32
";slow=%c",
501 data_buf = calloc(
sizeof(uint8_t),
count * 4);
508 for (i = 0; i <
count; i++) {
517 if (slow_memory || i == 0) {
528 LOG_ERROR(
"Failed to execute jtag queue: %d", retval);
534 for (i = 0; i <
count; i++)
#define CHECK_RETVAL(action)
int arc_jtag_startup(struct arc_jtag *jtag_info)
int arc_jtag_write_core_reg(struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, const uint32_t *buffer)
Write core registers.
int arc_jtag_read_core_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t *value)
Wrapper function to ease reading of one core register.
int arc_jtag_status(struct arc_jtag *const jtag_info, uint32_t *const value)
Read STATUS register.
int arc_jtag_read_memory(struct arc_jtag *jtag_info, uint32_t addr, uint32_t count, uint32_t *buffer, bool slow_memory)
Read a sequence of 4-byte words from target memory.
int arc_jtag_write_aux_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t value)
Wrapper function to ease writing of one AUX register.
static void arc_jtag_enque_set_transaction(struct arc_jtag *jtag_info, uint32_t new_trans, tap_state_t end_state)
Set transaction in command register.
static void arc_jtag_enque_read_dr(struct arc_jtag *jtag_info, uint8_t *data, tap_state_t end_state)
Read 4-byte word from data register.
static void arc_jtag_enque_write_dr(struct arc_jtag *jtag_info, uint32_t data, tap_state_t end_state)
Write 4-byte word to data register.
int arc_jtag_write_memory(struct arc_jtag *jtag_info, uint32_t addr, uint32_t count, const uint32_t *buffer)
Write a sequence of 4-byte words into target memory.
static void arc_jtag_enque_write_ir(struct arc_jtag *jtag_info, uint32_t new_instr)
int arc_jtag_write_core_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t value)
Wrapper function to ease writing of one core register.
static void arc_jtag_enque_register_rw(struct arc_jtag *jtag_info, uint32_t *addr, uint8_t *read_buffer, const uint32_t *write_buffer, uint32_t count)
int arc_jtag_read_core_reg(struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, uint32_t *buffer)
Read core registers.
static void arc_jtag_enque_reset_transaction(struct arc_jtag *jtag_info)
Run reset through transaction set.
static int arc_jtag_read_registers(struct arc_jtag *jtag_info, uint32_t type, uint32_t *addr, uint32_t count, uint32_t *buffer)
Read registers.
int arc_jtag_read_aux_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t *value)
Wrapper function to ease reading of one AUX register.
static int arc_jtag_write_registers(struct arc_jtag *jtag_info, uint32_t type, uint32_t *addr, uint32_t count, const uint32_t *buffer)
Write registers.
int arc_jtag_write_aux_reg(struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, const uint32_t *buffer)
Write AUX registers.
static void arc_jtag_enque_status_read(struct arc_jtag *const jtag_info, uint8_t *const buffer)
int arc_jtag_read_aux_reg(struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, uint32_t *buffer)
Read AUX registers.
#define ARC_JTAG_READ_FROM_CORE_REG
#define ARC_JTAG_WRITE_TO_AUX_REG
#define ARC_JTAG_DATA_REG
#define ARC_JTAG_ADDRESS_REG
#define ARC_TRANSACTION_CMD_REG
#define ARC_JTAG_WRITE_TO_CORE_REG
#define ARC_JTAG_WRITE_TO_MEMORY
#define ARC_JTAG_STATUS_REG
#define ARC_JTAG_CORE_REG
#define ARC_JTAG_READ_FROM_MEMORY
#define ARC_TRANSACTION_CMD_REG_LENGTH
#define ARC_JTAG_READ_FROM_AUX_REG
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_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
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.
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
uint8_t * cur_instr
current instruction
int ir_length
size of instruction register
This structure defines a single scan field in the scan.
int num_bits
The number of bits this field specifies.
const uint8_t * out_value
A pointer to value to be scanned into the device.