OpenOCD
arc_jtag.c File Reference
Include dependency graph for arc_jtag.c:

Go to the source code of this file.

Functions

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. More...
 
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)
 
static void arc_jtag_enque_reset_transaction (struct arc_jtag *jtag_info)
 Run reset through transaction set. More...
 
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. More...
 
static void arc_jtag_enque_status_read (struct arc_jtag *const jtag_info, uint8_t *const buffer)
 
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. More...
 
static void arc_jtag_enque_write_ir (struct arc_jtag *jtag_info, uint32_t new_instr)
 
int arc_jtag_read_aux_reg (struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, uint32_t *buffer)
 Read AUX registers. More...
 
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. More...
 
int arc_jtag_read_core_reg (struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, uint32_t *buffer)
 Read core registers. More...
 
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. More...
 
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. More...
 
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. More...
 
int arc_jtag_startup (struct arc_jtag *jtag_info)
 
int arc_jtag_status (struct arc_jtag *const jtag_info, uint32_t *const value)
 Read STATUS register. More...
 
int arc_jtag_write_aux_reg (struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, const uint32_t *buffer)
 Write AUX registers. More...
 
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. More...
 
int arc_jtag_write_core_reg (struct arc_jtag *jtag_info, uint32_t *addr, uint32_t count, const uint32_t *buffer)
 Write core registers. More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ arc_jtag_enque_read_dr()

static void arc_jtag_enque_read_dr ( struct arc_jtag jtag_info,
uint8_t *  data,
tap_state_t  end_state 
)
static

Read 4-byte word from data register.

Unlike arc_jtag_write_data, this function returns byte-buffer, caller must convert this data to required format himself. This is done, because it is impossible to convert data before jtag_execute_queue() is invoked, so it cannot be done inside this function, so it has to operate with byte-buffers. Write function on the other hand can "write-and-forget", data is converted to byte-buffer before jtag_execute_queue().

Parameters
jtag_info
dataArray of bytes to read into.
end_stateEnd state after reading.

Definition at line 68 of file arc_jtag.c.

References jtag_add_dr_scan(), scan_field::num_bits, and arc_jtag::tap.

Referenced by arc_jtag_enque_register_rw(), arc_jtag_enque_status_read(), and arc_jtag_read_memory().

◆ arc_jtag_enque_register_rw()

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 
)
static

◆ arc_jtag_enque_reset_transaction()

static void arc_jtag_enque_reset_transaction ( struct arc_jtag jtag_info)
static

Run reset through transaction set.

None of the previous settings/commands/etc. are used anymore (or no influence).

Definition at line 149 of file arc_jtag.c.

References ARC_JTAG_CMD_NOP, arc_jtag_enque_set_transaction(), and TAP_IDLE.

Referenced by arc_jtag_enque_register_rw(), arc_jtag_read_memory(), arc_jtag_read_registers(), arc_jtag_startup(), arc_jtag_status(), arc_jtag_write_memory(), and arc_jtag_write_registers().

◆ arc_jtag_enque_set_transaction()

static void arc_jtag_enque_set_transaction ( struct arc_jtag jtag_info,
uint32_t  new_trans,
tap_state_t  end_state 
)
static

Set transaction in command register.

This function sets instruction register and then transaction register, there is no need to invoke write_ir before invoking this function.

Parameters
jtag_info
new_transTransaction to write to transaction command register.
end_stateEnd state after writing.

Definition at line 118 of file arc_jtag.c.

References arc_jtag_enque_write_ir(), ARC_TRANSACTION_CMD_REG, ARC_TRANSACTION_CMD_REG_LENGTH, buf_set_u32(), arc_jtag::cur_trans, jtag_add_dr_scan(), scan_field::num_bits, scan_field::out_value, and arc_jtag::tap.

Referenced by arc_jtag_enque_reset_transaction(), arc_jtag_read_memory(), arc_jtag_read_registers(), arc_jtag_write_memory(), and arc_jtag_write_registers().

◆ arc_jtag_enque_status_read()

static void arc_jtag_enque_status_read ( struct arc_jtag *const  jtag_info,
uint8_t *const  buffer 
)
static

◆ arc_jtag_enque_write_dr()

static void arc_jtag_enque_write_dr ( struct arc_jtag jtag_info,
uint32_t  data,
tap_state_t  end_state 
)
static

Write 4-byte word to data register.

Parameters
jtag_info
data4-byte word to write into data register.
end_stateEnd state after writing.

Definition at line 90 of file arc_jtag.c.

References buf_set_u32(), jtag_add_dr_scan(), scan_field::num_bits, scan_field::out_value, and arc_jtag::tap.

Referenced by arc_jtag_enque_register_rw(), arc_jtag_read_memory(), and arc_jtag_write_memory().

◆ arc_jtag_enque_write_ir()

◆ arc_jtag_read_aux_reg()

int arc_jtag_read_aux_reg ( struct arc_jtag jtag_info,
uint32_t *  addr,
uint32_t  count,
uint32_t *  buffer 
)

Read AUX registers.

addr is an array of addresses, and those addresses can be in any order, though it is recommended that they are in sequential order where possible, as this reduces number of JTAG commands to transfer.

Parameters
jtag_info
addrArray of AUX register numbers.
countAmount of registers in arrays.
bufferArray of register values.

Definition at line 414 of file arc_jtag.c.

References addr, ARC_JTAG_AUX_REG, arc_jtag_read_registers(), buffer, and count.

Referenced by arc_jtag_read_aux_reg_one(), and arc_save_context().

◆ arc_jtag_read_aux_reg_one()

int arc_jtag_read_aux_reg_one ( struct arc_jtag jtag_info,
uint32_t  addr,
uint32_t *  value 
)

◆ arc_jtag_read_core_reg()

int arc_jtag_read_core_reg ( struct arc_jtag jtag_info,
uint32_t *  addr,
uint32_t  count,
uint32_t *  buffer 
)

Read core registers.

addr is an array of addresses, and those addresses can be in any order, though it is recommended that they are in sequential order where possible, as this reduces number of JTAG commands to transfer.

Parameters
jtag_info
addrArray of core register numbers.
countAmount of registers in arrays.
bufferArray of register values.

Definition at line 366 of file arc_jtag.c.

References addr, ARC_JTAG_CORE_REG, arc_jtag_read_registers(), buffer, and count.

Referenced by arc_jtag_read_core_reg_one(), and arc_save_context().

◆ arc_jtag_read_core_reg_one()

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.

Definition at line 350 of file arc_jtag.c.

References addr, and arc_jtag_read_core_reg().

Referenced by arc_get_register(), and COMMAND_HANDLER().

◆ arc_jtag_read_memory()

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.

We can read only 4byte words via JTAG.

This function read directly from the memory, so it can read invalid data if data cache hasn't been flushed before hand. It is responsibility of upper level to resolve this.

Parameters
jtag_info
addrAddress of first word to read from.
countAmount of words to read.
bufferArray of words to read into.
slow_memoryWhether this is a slow memory (DDR) or fast (CCM).

Definition at line 484 of file arc_jtag.c.

References addr, ARC_JTAG_ADDRESS_REG, ARC_JTAG_DATA_REG, arc_jtag_enque_read_dr(), arc_jtag_enque_reset_transaction(), arc_jtag_enque_set_transaction(), arc_jtag_enque_write_dr(), arc_jtag_enque_write_ir(), ARC_JTAG_READ_FROM_MEMORY, buf_get_u32(), buffer, count, ERROR_FAIL, ERROR_OK, jtag_execute_queue(), LOG_DEBUG, LOG_ERROR, arc_jtag::tap, TAP_DRPAUSE, and TAP_IDLE.

Referenced by arc_mem_read_block(), arc_mem_write_block16(), and arc_mem_write_block8().

◆ arc_jtag_read_registers()

static int arc_jtag_read_registers ( struct arc_jtag jtag_info,
uint32_t  type,
uint32_t *  addr,
uint32_t  count,
uint32_t *  buffer 
)
static

Read registers.

addr is an array of addresses, and those addresses can be in any order, though it is recommended that they are in sequential order where possible, as this reduces number of JTAG commands to transfer.

Parameters
jtag_info
typeType of registers to read: core or aux.
addrArray of registers numbers.
countAmount of registers in arrays.
bufferArray of register values.

Definition at line 277 of file arc_jtag.c.

References addr, ARC_JTAG_CORE_REG, arc_jtag_enque_register_rw(), arc_jtag_enque_reset_transaction(), arc_jtag_enque_set_transaction(), ARC_JTAG_READ_FROM_AUX_REG, ARC_JTAG_READ_FROM_CORE_REG, buf_get_u32(), buffer, count, ERROR_FAIL, ERROR_OK, jtag_execute_queue(), LOG_DEBUG, LOG_ERROR, NULL, arc_jtag::tap, TAP_DRPAUSE, and type.

Referenced by arc_jtag_read_aux_reg(), and arc_jtag_read_core_reg().

◆ arc_jtag_startup()

int arc_jtag_startup ( struct arc_jtag jtag_info)

Definition at line 169 of file arc_jtag.c.

References arc_jtag_enque_reset_transaction(), and jtag_execute_queue().

Referenced by arc_examine().

◆ arc_jtag_status()

int arc_jtag_status ( struct arc_jtag *const  jtag_info,
uint32_t *const  value 
)

◆ arc_jtag_write_aux_reg()

int arc_jtag_write_aux_reg ( struct arc_jtag jtag_info,
uint32_t *  addr,
uint32_t  count,
const uint32_t *  buffer 
)

Write AUX registers.

addr is an array of addresses, and those addresses can be in any order, though it is recommended that they are in sequential order where possible, as this reduces number of JTAG commands to transfer.

Parameters
jtag_info
addrArray of registers numbers.
countAmount of registers in arrays.
bufferArray of register values.

Definition at line 390 of file arc_jtag.c.

References addr, ARC_JTAG_AUX_REG, arc_jtag_write_registers(), buffer, and count.

Referenced by arc_jtag_write_aux_reg_one(), and arc_restore_context().

◆ arc_jtag_write_aux_reg_one()

int arc_jtag_write_aux_reg_one ( struct arc_jtag jtag_info,
uint32_t  addr,
uint32_t  value 
)

◆ arc_jtag_write_core_reg()

int arc_jtag_write_core_reg ( struct arc_jtag jtag_info,
uint32_t *  addr,
uint32_t  count,
const uint32_t *  buffer 
)

Write core registers.

addr is an array of addresses, and those addresses can be in any order, though it is recommended that they are in sequential order where possible, as this reduces number of JTAG commands to transfer.

Parameters
jtag_info
addrArray of registers numbers.
countAmount of registers in arrays.
bufferArray of register values.

Definition at line 342 of file arc_jtag.c.

References addr, ARC_JTAG_CORE_REG, arc_jtag_write_registers(), buffer, and count.

Referenced by arc_jtag_write_core_reg_one(), and arc_restore_context().

◆ arc_jtag_write_core_reg_one()

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.

Definition at line 326 of file arc_jtag.c.

References addr, and arc_jtag_write_core_reg().

◆ arc_jtag_write_memory()

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.

We can write only 4byte words via JTAG, so any non-word writes should be handled at higher levels by read-modify-write.

This function writes directly to the memory, leaving any caches (if there are any) in inconsistent state. It is responsibility of upper level to resolve this.

Parameters
jtag_info
addrAddress of first word to write into.
countAmount of word to write.
bufferArray to write into memory.

Definition at line 436 of file arc_jtag.c.

References addr, ARC_JTAG_ADDRESS_REG, ARC_JTAG_DATA_REG, arc_jtag_enque_reset_transaction(), arc_jtag_enque_set_transaction(), arc_jtag_enque_write_dr(), arc_jtag_enque_write_ir(), ARC_JTAG_WRITE_TO_MEMORY, buffer, count, ERROR_OK, jtag_execute_queue(), LOG_DEBUG, TAP_DRPAUSE, and TAP_IDLE.

Referenced by arc_mem_write_block16(), arc_mem_write_block32(), and arc_mem_write_block8().

◆ arc_jtag_write_registers()

static int arc_jtag_write_registers ( struct arc_jtag jtag_info,
uint32_t  type,
uint32_t *  addr,
uint32_t  count,
const uint32_t *  buffer 
)
static

Write registers.

addr is an array of addresses, and those addresses can be in any order, though it is recommended that they are in sequential order where possible, as this reduces number of JTAG commands to transfer.

Parameters
jtag_info
typeType of registers to write: core or aux.
addrArray of registers numbers.
countAmount of registers in arrays.
bufferArray of register values.

Definition at line 242 of file arc_jtag.c.

References addr, ARC_JTAG_CORE_REG, arc_jtag_enque_register_rw(), arc_jtag_enque_reset_transaction(), arc_jtag_enque_set_transaction(), ARC_JTAG_WRITE_TO_AUX_REG, ARC_JTAG_WRITE_TO_CORE_REG, buffer, count, ERROR_FAIL, jtag_execute_queue(), LOG_DEBUG, LOG_ERROR, NULL, TAP_DRPAUSE, and type.

Referenced by arc_jtag_write_aux_reg(), and arc_jtag_write_core_reg().