OpenOCD
riscv-013.c File Reference
Include dependency graph for riscv-013.c:

Go to the source code of this file.

Data Structures

struct  dm013_info_t
 
struct  riscv013_info_t
 
struct  scratch_mem_t
 
struct  target_list_t
 
struct  trigger
 

Macros

#define CMDERR_BUSY   1
 
#define CMDERR_EXCEPTION   3
 
#define CMDERR_HALT_RESUME   4
 
#define CMDERR_NONE   0
 
#define CMDERR_NOT_SUPPORTED   2
 
#define CMDERR_OTHER   7
 
#define CSR_DCSR_CAUSE_DEBUGINT   3
 
#define CSR_DCSR_CAUSE_GROUP   6
 
#define CSR_DCSR_CAUSE_HALT   5
 
#define CSR_DCSR_CAUSE_STEP   4
 
#define CSR_DCSR_CAUSE_SWBP   1
 
#define CSR_DCSR_CAUSE_TRIGGER   2
 
#define get_field(reg, mask)   (((reg) & (mask)) / ((mask) & ~((mask) << 1)))
 Since almost everything can be accomplish by scanning the dbus register, all functions here assume dbus is already selected. More...
 
#define RISCV013_INFO(r)   riscv013_info_t *r = get_info(target)
 
#define set_field(reg, mask, val)   (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask)))
 

Typedefs

typedef enum slot slot_t
 

Enumerations

enum  dmi_op_t { DMI_OP_NOP = 0 , DMI_OP_READ = 1 , DMI_OP_WRITE = 2 }
 
enum  dmi_status_t { DMI_STATUS_SUCCESS = 0 , DMI_STATUS_FAILED = 2 , DMI_STATUS_BUSY = 3 }
 
enum  memory_space_t { SPACE_DM_DATA , SPACE_DMI_PROGBUF , SPACE_DMI_RAM }
 
enum  slot {
  SLOT0 , SLOT1 , SLOT_LAST , SLOT0 ,
  SLOT1 , SLOT_LAST , SLOT0 , SLOT1 ,
  SLOT_LAST
}
 
enum  yes_no_maybe_t { YNM_MAYBE , YNM_YES , YNM_NO }
 

Functions

static uint32_t __attribute__ ((unused))
 
static uint32_t abstract_memory_size (unsigned int width)
 
static uint32_t access_memory_command (struct target *target, bool virtual, unsigned int width, bool postincrement, bool write)
 
static uint32_t access_register_command (struct target *target, uint32_t number, unsigned int size, uint32_t flags)
 
static int arch_state (struct target *target)
 
static int assert_reset (struct target *target)
 
static int batch_run (const struct target *target, struct riscv_batch *batch)
 
static int cleanup_after_register_access (struct target *target, uint64_t mstatus, int regno)
 
static int cleanup_after_vector_access (struct target *target, uint64_t vtype, uint64_t vl)
 
static COMMAND_HELPER (riscv013_print_info, struct target *target)
 
static int deassert_reset (struct target *target)
 
static void decode_dmi (char *text, unsigned int address, unsigned int data)
 
static void deinit_target (struct target *target)
 
static int discover_vlenb (struct target *target)
 
static int dmi_op (struct target *target, uint32_t *data_in, bool *dmi_busy_encountered, int dmi_op, uint32_t address, uint32_t data_out, bool exec, bool ensure_success)
 
static int dmi_op_timeout (struct target *target, uint32_t *data_in, bool *dmi_busy_encountered, int dmi_op, uint32_t address, uint32_t data_out, int timeout_sec, bool exec, bool ensure_success)
 
static int dmi_read (struct target *target, uint32_t *value, uint32_t address)
 
static int dmi_read_exec (struct target *target, uint32_t *value, uint32_t address)
 
static dmi_status_t dmi_scan (struct target *target, uint32_t *address_in, uint32_t *data_in, dmi_op_t op, uint32_t address_out, uint32_t data_out, bool exec)
 exec: If this is set, assume the scan results in an execution, so more run-test/idle cycles may be required. More...
 
static int dmi_write (struct target *target, uint32_t address, uint32_t value)
 
static int dmi_write_exec (struct target *target, uint32_t address, uint32_t value, bool ensure_success)
 
static int dmstatus_read (struct target *target, uint32_t *dmstatus, bool authenticated)
 
static int dmstatus_read_timeout (struct target *target, uint32_t *dmstatus, bool authenticated, unsigned int timeout_sec)
 
static uint32_t dtmcontrol_scan (struct target *target, uint32_t out)
 
static void dump_field (int idle, const struct scan_field *field)
 
static int examine (struct target *target)
 
static int examine_progbuf (struct target *target)
 
static int execute_abstract_command (struct target *target, uint32_t command)
 
static int execute_fence (struct target *target)
 
static dm013_info_tget_dm (struct target *target)
 Return the DM structure for this target. More...
 
static riscv013_info_tget_info (const struct target *target)
 
static bool has_sufficient_progbuf (struct target *target, unsigned int size)
 
static void increase_ac_busy_delay (struct target *target)
 
static void increase_dmi_busy_delay (struct target *target)
 
static int init_target (struct command_context *cmd_ctx, struct target *target)
 
static int is_fpu_reg (uint32_t gdb_regno)
 
static int is_vector_reg (uint32_t gdb_regno)
 
static LIST_HEAD (dm_list)
 
static void log_mem_access_result (struct target *target, bool success, int method, bool read)
 
static void log_memory_access (target_addr_t address, uint64_t value, unsigned int size_bytes, bool read)
 
static int maybe_execute_fence_i (struct target *target)
 
static bool mem_should_skip_abstract (struct target *target, target_addr_t address, uint32_t size, uint32_t increment, bool read, char **skip_reason)
 
static bool mem_should_skip_progbuf (struct target *target, target_addr_t address, uint32_t size, bool read, char **skip_reason)
 
static bool mem_should_skip_sysbus (struct target *target, target_addr_t address, uint32_t size, uint32_t increment, bool read, char **skip_reason)
 
static int modify_privilege (struct target *target, uint64_t *mstatus, uint64_t *mstatus_old)
 
static int prep_for_register_access (struct target *target, uint64_t *mstatus, int regno)
 
static int prep_for_vector_access (struct target *target, uint64_t *vtype, uint64_t *vl, unsigned int *debug_vl)
 
static riscv_reg_t read_abstract_arg (struct target *target, unsigned int index, unsigned int size_bits)
 
static int read_memory (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
 
static int read_memory_abstract (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
 
static int read_memory_bus_v0 (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
 
static int read_memory_bus_v1 (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
 Read the requested memory using the system bus interface. More...
 
static int read_memory_bus_word (struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
 
static int read_memory_progbuf (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
 Read the requested memory, silently handling memory access errors. More...
 
static int read_memory_progbuf_inner (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
 Read the requested memory, taking care to execute every read exactly once, even if cmderr=busy is encountered. More...
 
static int read_memory_progbuf_one (struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
 
static int read_sbcs_nonbusy (struct target *target, uint32_t *sbcs)
 
static int register_read (struct target *target, uint64_t *value, uint32_t number)
 Read register value from the target. More...
 
static int register_read_abstract (struct target *target, uint64_t *value, uint32_t number, unsigned int size)
 
static int register_read_direct (struct target *target, uint64_t *value, uint32_t number)
 Actually read registers from the target right now. More...
 
static unsigned int register_size (struct target *target, unsigned int number)
 Return register size in bits. More...
 
static int register_write_abstract (struct target *target, uint32_t number, uint64_t value, unsigned int size)
 
static int register_write_direct (struct target *target, unsigned int number, uint64_t value)
 Immediately write the new value to the requested register. More...
 
static int riscv013_authdata_read (struct target *target, uint32_t *value, unsigned int index)
 
static int riscv013_authdata_write (struct target *target, uint32_t value, unsigned int index)
 
static void riscv013_clear_abstract_error (struct target *target)
 
static unsigned int riscv013_data_bits (struct target *target)
 
static int riscv013_dmi_write_u64_bits (struct target *target)
 
static int riscv013_execute_debug_buffer (struct target *target)
 
static void riscv013_fill_dmi_nop_u64 (struct target *target, char *buf)
 
static void riscv013_fill_dmi_read_u64 (struct target *target, char *buf, int a)
 
static void riscv013_fill_dmi_write_u64 (struct target *target, char *buf, int a, uint64_t d)
 
static int riscv013_get_register (struct target *target, riscv_reg_t *value, int rid)
 
static int riscv013_get_register_buf (struct target *target, uint8_t *value, int regno)
 
static int riscv013_halt_go (struct target *target)
 
static int riscv013_halt_prep (struct target *target)
 
static enum riscv_halt_reason riscv013_halt_reason (struct target *target)
 
static int riscv013_hart_count (struct target *target)
 
static bool riscv013_is_halted (struct target *target)
 
static int riscv013_on_halt (struct target *target)
 
static int riscv013_on_step (struct target *target)
 
static int riscv013_on_step_or_resume (struct target *target, bool step)
 
static riscv_insn_t riscv013_read_debug_buffer (struct target *target, unsigned int index)
 
static int riscv013_resume_go (struct target *target)
 
static int riscv013_resume_prep (struct target *target)
 
static int riscv013_select_current_hart (struct target *target)
 
static int riscv013_set_register (struct target *target, int regid, uint64_t value)
 
static int riscv013_set_register_buf (struct target *target, int regno, const uint8_t *value)
 
static int riscv013_step_current_hart (struct target *target)
 
static int riscv013_step_or_resume_current_hart (struct target *target, bool step, bool use_hasel)
 
static int riscv013_write_debug_buffer (struct target *target, unsigned int index, riscv_insn_t d)
 
static int sample_memory (struct target *target, struct riscv_sample_buf *buf, riscv_sample_config_t *config, int64_t until_ms)
 
static int sample_memory_bus_v1 (struct target *target, struct riscv_sample_buf *buf, const riscv_sample_config_t *config, int64_t until_ms)
 
static target_addr_t sb_read_address (struct target *target)
 
static uint32_t sb_sbaccess (unsigned int size_bytes)
 
static int sb_write_address (struct target *target, target_addr_t address, bool ensure_success)
 
static int sba_supports_access (struct target *target, unsigned int size_bytes)
 
static int scratch_read64 (struct target *target, scratch_mem_t *scratch, uint64_t *value)
 
static int scratch_release (struct target *target, scratch_mem_t *scratch)
 
static int scratch_reserve (struct target *target, scratch_mem_t *scratch, struct riscv_program *program, unsigned int size_bytes)
 Find some scratch memory to be used with the given program. More...
 
static int scratch_write64 (struct target *target, scratch_mem_t *scratch, uint64_t value)
 
static void select_dmi (struct target *target)
 
static int select_prepped_harts (struct target *target, bool *use_hasel)
 
static int set_haltgroup (struct target *target, bool *supported)
 
static uint32_t set_hartsel (uint32_t initial, uint32_t index)
 
static int wait_for_authbusy (struct target *target, uint32_t *dmstatus)
 
static int wait_for_idle (struct target *target, uint32_t *abstractcs)
 
static int write_abstract_arg (struct target *target, unsigned int index, riscv_reg_t value, unsigned int size_bits)
 
static int write_memory (struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int write_memory_abstract (struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int write_memory_bus_v0 (struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int write_memory_bus_v1 (struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int write_memory_progbuf (struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 

Variables

struct target_type riscv013_target
 

Macro Definition Documentation

◆ CMDERR_BUSY

#define CMDERR_BUSY   1

Definition at line 109 of file riscv-013.c.

◆ CMDERR_EXCEPTION

#define CMDERR_EXCEPTION   3

Definition at line 111 of file riscv-013.c.

◆ CMDERR_HALT_RESUME

#define CMDERR_HALT_RESUME   4

Definition at line 112 of file riscv-013.c.

◆ CMDERR_NONE

#define CMDERR_NONE   0

Definition at line 108 of file riscv-013.c.

◆ CMDERR_NOT_SUPPORTED

#define CMDERR_NOT_SUPPORTED   2

Definition at line 110 of file riscv-013.c.

◆ CMDERR_OTHER

#define CMDERR_OTHER   7

Definition at line 113 of file riscv-013.c.

◆ CSR_DCSR_CAUSE_DEBUGINT

#define CSR_DCSR_CAUSE_DEBUGINT   3

Definition at line 80 of file riscv-013.c.

◆ CSR_DCSR_CAUSE_GROUP

#define CSR_DCSR_CAUSE_GROUP   6

Definition at line 83 of file riscv-013.c.

◆ CSR_DCSR_CAUSE_HALT

#define CSR_DCSR_CAUSE_HALT   5

Definition at line 82 of file riscv-013.c.

◆ CSR_DCSR_CAUSE_STEP

#define CSR_DCSR_CAUSE_STEP   4

Definition at line 81 of file riscv-013.c.

◆ CSR_DCSR_CAUSE_SWBP

#define CSR_DCSR_CAUSE_SWBP   1

Definition at line 78 of file riscv-013.c.

◆ CSR_DCSR_CAUSE_TRIGGER

#define CSR_DCSR_CAUSE_TRIGGER   2

Definition at line 79 of file riscv-013.c.

◆ get_field

#define get_field (   reg,
  mask 
)    (((reg) & (mask)) / ((mask) & ~((mask) << 1)))

Since almost everything can be accomplish by scanning the dbus register, all functions here assume dbus is already selected.

The exception are functions called directly by OpenOCD, which can't assume anything about what's currently in IR. They should set IR to dbus explicitly.

Definition at line 75 of file riscv-013.c.

◆ RISCV013_INFO

#define RISCV013_INFO (   r)    riscv013_info_t *r = get_info(target)

Definition at line 85 of file riscv-013.c.

◆ set_field

#define set_field (   reg,
  mask,
  val 
)    (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask)))

Definition at line 76 of file riscv-013.c.

Typedef Documentation

◆ slot_t

typedef enum slot slot_t

Enumeration Type Documentation

◆ dmi_op_t

enum dmi_op_t
Enumerator
DMI_OP_NOP 
DMI_OP_READ 
DMI_OP_WRITE 

Definition at line 89 of file riscv-013.c.

◆ dmi_status_t

Enumerator
DMI_STATUS_SUCCESS 
DMI_STATUS_FAILED 
DMI_STATUS_BUSY 

Definition at line 94 of file riscv-013.c.

◆ memory_space_t

Enumerator
SPACE_DM_DATA 
SPACE_DMI_PROGBUF 
SPACE_DMI_RAM 

Definition at line 1114 of file riscv-013.c.

◆ slot

enum slot
Enumerator
SLOT0 
SLOT1 
SLOT_LAST 
SLOT0 
SLOT1 
SLOT_LAST 
SLOT0 
SLOT1 
SLOT_LAST 

Definition at line 100 of file riscv-013.c.

◆ yes_no_maybe_t

Enumerator
YNM_MAYBE 
YNM_YES 
YNM_NO 

Definition at line 126 of file riscv-013.c.

Function Documentation

◆ __attribute__()

static uint32_t __attribute__ ( (unused)  )
staticpure virtual

Definition at line 719 of file riscv-013.c.

References AC_ACCESS_REGISTER_AARSIZE, LOG_ERROR, set_field, and width.

◆ abstract_memory_size()

static uint32_t abstract_memory_size ( unsigned int  width)
static

Definition at line 970 of file riscv-013.c.

References AC_ACCESS_MEMORY_AAMSIZE, LOG_ERROR, set_field, and width.

Referenced by access_memory_command().

◆ access_memory_command()

static uint32_t access_memory_command ( struct target target,
bool  virtual,
unsigned int  width,
bool  postincrement,
bool  write 
)
static

◆ access_register_command()

◆ arch_state()

static int arch_state ( struct target target)
static

Definition at line 4041 of file riscv-013.c.

References ERROR_OK.

◆ assert_reset()

◆ batch_run()

static int batch_run ( const struct target target,
struct riscv_batch batch 
)
static

◆ cleanup_after_register_access()

static int cleanup_after_register_access ( struct target target,
uint64_t  mstatus,
int  regno 
)
static

◆ cleanup_after_vector_access()

static int cleanup_after_vector_access ( struct target target,
uint64_t  vtype,
uint64_t  vl 
)
static

◆ COMMAND_HELPER()

static COMMAND_HELPER ( riscv013_print_info  ,
struct target target 
)
static

◆ deassert_reset()

◆ decode_dmi()

◆ deinit_target()

static void deinit_target ( struct target target)
static

Definition at line 1519 of file riscv-013.c.

References target::arch_info, info, LOG_DEBUG, and NULL.

◆ discover_vlenb()

static int discover_vlenb ( struct target target)
static

◆ dmi_op()

static int dmi_op ( struct target target,
uint32_t *  data_in,
bool *  dmi_busy_encountered,
int  dmi_op,
uint32_t  address,
uint32_t  data_out,
bool  exec,
bool  ensure_success 
)
static

◆ dmi_op_timeout()

static int dmi_op_timeout ( struct target target,
uint32_t *  data_in,
bool *  dmi_busy_encountered,
int  dmi_op,
uint32_t  address,
uint32_t  data_out,
int  timeout_sec,
bool  exec,
bool  ensure_success 
)
static
Parameters
target
data_inThe data we received from the target.
dmi_busy_encounteredIf non-NULL, will be updated to reflect whether DMI busy was encountered while executing this operation or not.
dmi_opThe operation to perform (read/write/nop).
addressThe address argument to that operation.
data_outThe data to send to the target.
timeout_sec
execWhen true, this scan will execute something, so extra RTI cycles may be added.
ensure_successScan a nop after the requested operation, ensuring the DMI operation succeeded.

Definition at line 556 of file riscv-013.c.

References dmi_op(), DMI_OP_NOP, DMI_OP_READ, DMI_OP_WRITE, dmi_scan(), DMI_STATUS_BUSY, DMI_STATUS_SUCCESS, DTM_DTMCS_DMIRESET, dtmcontrol_scan(), ERROR_FAIL, ERROR_OK, ERROR_TIMEOUT_REACHED, increase_dmi_busy_delay(), keep_alive(), LOG_ERROR, NULL, select_dmi(), start, and status.

Referenced by dmi_op(), and dmstatus_read_timeout().

◆ dmi_read()

◆ dmi_read_exec()

static int dmi_read_exec ( struct target target,
uint32_t *  value,
uint32_t  address 
)
static

Definition at line 665 of file riscv-013.c.

References dmi_op(), DMI_OP_READ, and NULL.

Referenced by read_memory_progbuf_inner().

◆ dmi_scan()

static dmi_status_t dmi_scan ( struct target target,
uint32_t *  address_in,
uint32_t *  data_in,
dmi_op_t  op,
uint32_t  address_out,
uint32_t  data_out,
bool  exec 
)
static

◆ dmi_write()

◆ dmi_write_exec()

static int dmi_write_exec ( struct target target,
uint32_t  address,
uint32_t  value,
bool  ensure_success 
)
static

Definition at line 675 of file riscv-013.c.

References dmi_op(), DMI_OP_WRITE, and NULL.

Referenced by execute_abstract_command(), and read_memory_progbuf_inner().

◆ dmstatus_read()

static int dmstatus_read ( struct target target,
uint32_t *  dmstatus,
bool  authenticated 
)
static

◆ dmstatus_read_timeout()

static int dmstatus_read_timeout ( struct target target,
uint32_t *  dmstatus,
bool  authenticated,
unsigned int  timeout_sec 
)
static

◆ dtmcontrol_scan()

◆ dump_field()

static void dump_field ( int  idle,
const struct scan_field field 
)
static

◆ examine()

◆ examine_progbuf()

◆ execute_abstract_command()

◆ execute_fence()

static int execute_fence ( struct target target)
static

◆ get_dm()

◆ get_info()

static riscv013_info_t* get_info ( const struct target target)
static

◆ has_sufficient_progbuf()

static bool has_sufficient_progbuf ( struct target target,
unsigned int  size 
)
static

◆ increase_ac_busy_delay()

static void increase_ac_busy_delay ( struct target target)
static

Definition at line 710 of file riscv-013.c.

References get_info(), info, and LOG_DEBUG.

Referenced by read_memory_progbuf_inner(), and write_memory_progbuf().

◆ increase_dmi_busy_delay()

static void increase_dmi_busy_delay ( struct target target)
static

Definition at line 449 of file riscv-013.c.

References DTM_DTMCS_DMIRESET, dtmcontrol_scan(), get_info(), info, and LOG_DEBUG.

Referenced by dmi_op_timeout(), and read_memory_bus_v1().

◆ init_target()

◆ is_fpu_reg()

static int is_fpu_reg ( uint32_t  gdb_regno)
static

◆ is_vector_reg()

static int is_vector_reg ( uint32_t  gdb_regno)
static

◆ LIST_HEAD()

static LIST_HEAD ( dm_list  )
static

◆ log_mem_access_result()

static void log_mem_access_result ( struct target target,
bool  success,
int  method,
bool  read 
)
static

◆ log_memory_access()

static void log_memory_access ( target_addr_t  address,
uint64_t  value,
unsigned int  size_bytes,
bool  read 
)
static

◆ maybe_execute_fence_i()

static int maybe_execute_fence_i ( struct target target)
static

Definition at line 4411 of file riscv-013.c.

References ERROR_OK, execute_fence(), and has_sufficient_progbuf().

Referenced by riscv013_on_step_or_resume().

◆ mem_should_skip_abstract()

static bool mem_should_skip_abstract ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  increment,
bool  read,
char **  skip_reason 
)
static

Definition at line 2913 of file riscv-013.c.

References LOG_DEBUG, LOG_ERROR, riscv_xlen(), and size.

Referenced by read_memory(), and write_memory().

◆ mem_should_skip_progbuf()

static bool mem_should_skip_progbuf ( struct target target,
target_addr_t  address,
uint32_t  size,
bool  read,
char **  skip_reason 
)
static

Definition at line 2845 of file riscv-013.c.

References has_sufficient_progbuf(), LOG_DEBUG, riscv_xlen(), size, target::state, and TARGET_HALTED.

Referenced by read_memory(), and write_memory().

◆ mem_should_skip_sysbus()

static bool mem_should_skip_sysbus ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  increment,
bool  read,
char **  skip_reason 
)
static

◆ modify_privilege()

static int modify_privilege ( struct target target,
uint64_t *  mstatus,
uint64_t *  mstatus_old 
)
static

◆ prep_for_register_access()

static int prep_for_register_access ( struct target target,
uint64_t *  mstatus,
int  regno 
)
static

◆ prep_for_vector_access()

static int prep_for_vector_access ( struct target target,
uint64_t *  vtype,
uint64_t *  vl,
unsigned int *  debug_vl 
)
static

◆ read_abstract_arg()

static riscv_reg_t read_abstract_arg ( struct target target,
unsigned int  index,
unsigned int  size_bits 
)
static

Definition at line 809 of file riscv-013.c.

References DM_DATA0, dmi_read(), LOG_ERROR, and offset.

Referenced by read_memory_abstract(), register_read_abstract(), and write_memory_abstract().

◆ read_memory()

◆ read_memory_abstract()

static int read_memory_abstract ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer,
uint32_t  increment 
)
static

◆ read_memory_bus_v0()

static int read_memory_bus_v0 ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer,
uint32_t  increment 
)
static

◆ read_memory_bus_v1()

◆ read_memory_bus_word()

static int read_memory_bus_word ( struct target target,
target_addr_t  address,
uint32_t  size,
uint8_t *  buffer 
)
static

◆ read_memory_progbuf()

◆ read_memory_progbuf_inner()

◆ read_memory_progbuf_one()

◆ read_sbcs_nonbusy()

static int read_sbcs_nonbusy ( struct target target,
uint32_t *  sbcs 
)
static

◆ register_read()

◆ register_read_abstract()

static int register_read_abstract ( struct target target,
uint64_t *  value,
uint32_t  number,
unsigned int  size 
)
static

◆ register_read_direct()

◆ register_size()

static unsigned int register_size ( struct target target,
unsigned int  number 
)
static

Return register size in bits.

Definition at line 1273 of file riscv-013.c.

References number, target::reg_cache, reg_cache::reg_list, riscv_xlen(), and reg::size.

Referenced by register_read_direct(), and register_write_direct().

◆ register_write_abstract()

static int register_write_abstract ( struct target target,
uint32_t  number,
uint64_t  value,
unsigned int  size 
)
static

◆ register_write_direct()

◆ riscv013_authdata_read()

static int riscv013_authdata_read ( struct target target,
uint32_t *  value,
unsigned int  index 
)
static

Definition at line 1781 of file riscv-013.c.

References DM_AUTHDATA, dmi_read(), ERROR_FAIL, ERROR_OK, LOG_ERROR, NULL, and wait_for_authbusy().

Referenced by init_target().

◆ riscv013_authdata_write()

static int riscv013_authdata_write ( struct target target,
uint32_t  value,
unsigned int  index 
)
static

◆ riscv013_clear_abstract_error()

void riscv013_clear_abstract_error ( struct target target)
static

◆ riscv013_data_bits()

◆ riscv013_dmi_write_u64_bits()

int riscv013_dmi_write_u64_bits ( struct target target)
static

Definition at line 4405 of file riscv-013.c.

References DTM_DMI_DATA_LENGTH, DTM_DMI_OP_LENGTH, info, and RISCV013_INFO.

Referenced by init_target().

◆ riscv013_execute_debug_buffer()

int riscv013_execute_debug_buffer ( struct target target)
static

◆ riscv013_fill_dmi_nop_u64()

void riscv013_fill_dmi_nop_u64 ( struct target target,
char *  buf 
)
static

◆ riscv013_fill_dmi_read_u64()

void riscv013_fill_dmi_read_u64 ( struct target target,
char *  buf,
int  a 
)
static

◆ riscv013_fill_dmi_write_u64()

void riscv013_fill_dmi_write_u64 ( struct target target,
char *  buf,
int  a,
uint64_t  d 
)
static

◆ riscv013_get_register()

static int riscv013_get_register ( struct target target,
riscv_reg_t value,
int  rid 
)
static

◆ riscv013_get_register_buf()

◆ riscv013_halt_go()

◆ riscv013_halt_prep()

static int riscv013_halt_prep ( struct target target)
static

Definition at line 4201 of file riscv-013.c.

References ERROR_OK.

Referenced by init_target().

◆ riscv013_halt_reason()

◆ riscv013_hart_count()

static int riscv013_hart_count ( struct target target)
static

Definition at line 1828 of file riscv-013.c.

References get_dm(), and dm013_info_t::hart_count.

Referenced by init_target().

◆ riscv013_is_halted()

static bool riscv013_is_halted ( struct target target)
static

Definition at line 4287 of file riscv-013.c.

Referenced by init_target().

◆ riscv013_on_halt()

static int riscv013_on_halt ( struct target target)
static

Definition at line 4282 of file riscv-013.c.

References ERROR_OK.

Referenced by init_target().

◆ riscv013_on_step()

static int riscv013_on_step ( struct target target)
static

Definition at line 4277 of file riscv-013.c.

References riscv013_on_step_or_resume().

Referenced by init_target().

◆ riscv013_on_step_or_resume()

static int riscv013_on_step_or_resume ( struct target target,
bool  step 
)
static

◆ riscv013_read_debug_buffer()

riscv_insn_t riscv013_read_debug_buffer ( struct target target,
unsigned int  index 
)
static

Definition at line 4363 of file riscv-013.c.

References DM_PROGBUF0, and dmi_read().

Referenced by init_target().

◆ riscv013_resume_go()

static int riscv013_resume_go ( struct target target)
static

◆ riscv013_resume_prep()

static int riscv013_resume_prep ( struct target target)
static

Definition at line 4272 of file riscv-013.c.

References riscv013_on_step_or_resume().

Referenced by init_target().

◆ riscv013_select_current_hart()

static int riscv013_select_current_hart ( struct target target)
static

◆ riscv013_set_register()

◆ riscv013_set_register_buf()

◆ riscv013_step_current_hart()

static int riscv013_step_current_hart ( struct target target)
static

Definition at line 4267 of file riscv-013.c.

References riscv013_step_or_resume_current_hart().

Referenced by init_target().

◆ riscv013_step_or_resume_current_hart()

◆ riscv013_write_debug_buffer()

int riscv013_write_debug_buffer ( struct target target,
unsigned int  index,
riscv_insn_t  d 
)
static

Definition at line 4348 of file riscv-013.c.

References DM_PROGBUF0, dmi_write(), ERROR_FAIL, ERROR_OK, get_dm(), LOG_DEBUG, and dm013_info_t::progbuf_cache.

Referenced by init_target().

◆ sample_memory()

static int sample_memory ( struct target target,
struct riscv_sample_buf buf,
riscv_sample_config_t config,
int64_t  until_ms 
)
static

Definition at line 2262 of file riscv-013.c.

References config, ERROR_OK, and sample_memory_bus_v1().

Referenced by init_target().

◆ sample_memory_bus_v1()

◆ sb_read_address()

static target_addr_t sb_read_address ( struct target target)
static

◆ sb_sbaccess()

static uint32_t sb_sbaccess ( unsigned int  size_bytes)
static

Definition at line 2057 of file riscv-013.c.

References DM_SBCS_SBACCESS, and set_field.

Referenced by read_memory_bus_v1(), sample_memory_bus_v1(), and write_memory_bus_v1().

◆ sb_write_address()

static int sb_write_address ( struct target target,
target_addr_t  address,
bool  ensure_success 
)
static

◆ sba_supports_access()

static int sba_supports_access ( struct target target,
unsigned int  size_bytes 
)
static

◆ scratch_read64()

static int scratch_read64 ( struct target target,
scratch_mem_t scratch,
uint64_t *  value 
)
static

◆ scratch_release()

static int scratch_release ( struct target target,
scratch_mem_t scratch 
)
static

Definition at line 1194 of file riscv-013.c.

References scratch_mem_t::area, and target_free_working_area().

Referenced by register_read_direct(), and register_write_direct().

◆ scratch_reserve()

static int scratch_reserve ( struct target target,
scratch_mem_t scratch,
struct riscv_program program,
unsigned int  size_bytes 
)
static

◆ scratch_write64()

static int scratch_write64 ( struct target target,
scratch_mem_t scratch,
uint64_t  value 
)
static

◆ select_dmi()

◆ select_prepped_harts()

◆ set_haltgroup()

static int set_haltgroup ( struct target target,
bool *  supported 
)
static

◆ set_hartsel()

◆ wait_for_authbusy()

static int wait_for_authbusy ( struct target target,
uint32_t *  dmstatus 
)
static

◆ wait_for_idle()

static int wait_for_idle ( struct target target,
uint32_t *  abstractcs 
)
static

◆ write_abstract_arg()

static int write_abstract_arg ( struct target target,
unsigned int  index,
riscv_reg_t  value,
unsigned int  size_bits 
)
static

◆ write_memory()

◆ write_memory_abstract()

static int write_memory_abstract ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ write_memory_bus_v0()

static int write_memory_bus_v0 ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ write_memory_bus_v1()

◆ write_memory_progbuf()

Variable Documentation

◆ riscv013_target

struct target_type riscv013_target
Initial value:
= {
.name = "riscv",
.init_target = init_target,
.deinit_target = deinit_target,
.examine = examine,
.halt = &riscv_halt,
.assert_reset = assert_reset,
.deassert_reset = deassert_reset,
.write_memory = write_memory,
.arch_state = arch_state
}
static int examine(struct target *target)
Definition: riscv-013.c:1561
static int deassert_reset(struct target *target)
Definition: riscv-013.c:2388
static int assert_reset(struct target *target)
Definition: riscv-013.c:2338
static int init_target(struct command_context *cmd_ctx, struct target *target)
Definition: riscv-013.c:2273
static int arch_state(struct target *target)
Definition: riscv-013.c:4041
static void deinit_target(struct target *target)
Definition: riscv-013.c:1519
static int write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: riscv-013.c:3980
int riscv_halt(struct target *target)
Definition: riscv.c:1226
int riscv_openocd_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
Definition: riscv.c:2303
int riscv_openocd_poll(struct target *target)
Definition: riscv.c:2184

Definition at line 4041 of file riscv-013.c.

Referenced by get_target_type().