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 width)
 
static uint32_t access_memory_command (struct target *target, bool virtual, unsigned width, bool postincrement, bool write)
 
static uint32_t access_register_command (struct target *target, uint32_t number, unsigned 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 address, unsigned 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 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 int get_max_sbaccess (struct target *target)
 
static uint32_t get_num_sbdata_regs (struct target *target)
 
static bool has_sufficient_progbuf (struct target *target, unsigned 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 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 *debug_vl)
 
static riscv_reg_t read_abstract_arg (struct target *target, unsigned index, unsigned 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 void read_memory_sba_simple (struct target *target, target_addr_t addr, uint32_t *rd_buf, uint32_t read_size, uint32_t sbcs)
 
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 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 register_size (struct target *target, unsigned number)
 Return register size in bits. More...
 
static int register_write_abstract (struct target *target, uint32_t number, uint64_t value, unsigned size)
 
static int register_write_direct (struct target *target, unsigned 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 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 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_test_sba_config_reg (struct target *target, target_addr_t legal_address, uint32_t num_words, target_addr_t illegal_address, bool run_sbbusyerror_test)
 
static int riscv013_write_debug_buffer (struct target *target, unsigned 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 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 index, riscv_reg_t value, unsigned 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)
 
static void write_memory_sba_simple (struct target *target, target_addr_t addr, uint32_t *write_data, uint32_t write_size, uint32_t sbcs)
 

Variables

struct target_type riscv013_target
 

Macro Definition Documentation

◆ CMDERR_BUSY

#define CMDERR_BUSY   1

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

◆ CMDERR_EXCEPTION

#define CMDERR_EXCEPTION   3

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

◆ CMDERR_HALT_RESUME

#define CMDERR_HALT_RESUME   4

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

◆ CMDERR_NONE

#define CMDERR_NONE   0

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

◆ CMDERR_NOT_SUPPORTED

#define CMDERR_NOT_SUPPORTED   2

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

◆ CMDERR_OTHER

#define CMDERR_OTHER   7

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

◆ CSR_DCSR_CAUSE_DEBUGINT

#define CSR_DCSR_CAUSE_DEBUGINT   3

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

◆ CSR_DCSR_CAUSE_GROUP

#define CSR_DCSR_CAUSE_GROUP   6

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

◆ CSR_DCSR_CAUSE_HALT

#define CSR_DCSR_CAUSE_HALT   5

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

◆ CSR_DCSR_CAUSE_STEP

#define CSR_DCSR_CAUSE_STEP   4

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

◆ CSR_DCSR_CAUSE_SWBP

#define CSR_DCSR_CAUSE_SWBP   1

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

◆ CSR_DCSR_CAUSE_TRIGGER

#define CSR_DCSR_CAUSE_TRIGGER   2

Definition at line 86 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 82 of file riscv-013.c.

◆ RISCV013_INFO

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

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

◆ set_field

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

Definition at line 83 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 96 of file riscv-013.c.

◆ dmi_status_t

Enumerator
DMI_STATUS_SUCCESS 
DMI_STATUS_FAILED 
DMI_STATUS_BUSY 

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

◆ memory_space_t

Enumerator
SPACE_DM_DATA 
SPACE_DMI_PROGBUF 
SPACE_DMI_RAM 

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

◆ slot

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

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

◆ yes_no_maybe_t

Enumerator
YNM_MAYBE 
YNM_YES 
YNM_NO 

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

Function Documentation

◆ __attribute__()

static uint32_t __attribute__ ( (unused)  )
staticpure virtual

Definition at line 724 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  width)
static

Definition at line 975 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  width,
bool  postincrement,
bool  write 
)
static

◆ access_register_command()

◆ arch_state()

static int arch_state ( struct target target)
static

Definition at line 4047 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 1524 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 563 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, 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 670 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 680 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  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

◆ get_max_sbaccess()

static int get_max_sbaccess ( struct target target)
static

◆ get_num_sbdata_regs()

static uint32_t get_num_sbdata_regs ( struct target target)
static

◆ has_sufficient_progbuf()

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

◆ increase_ac_busy_delay()

static void increase_ac_busy_delay ( struct target target)
static

Definition at line 715 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 456 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  size_bytes,
bool  read 
)
static

◆ maybe_execute_fence_i()

static int maybe_execute_fence_i ( struct target target)
static

Definition at line 4771 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 2919 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 2851 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 *  debug_vl 
)
static

◆ read_abstract_arg()

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

Definition at line 814 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_memory_sba_simple()

static void read_memory_sba_simple ( struct target target,
target_addr_t  addr,
uint32_t *  rd_buf,
uint32_t  read_size,
uint32_t  sbcs 
)
static

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

◆ register_read_direct()

◆ register_size()

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

Return register size in bits.

Definition at line 1278 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  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 1786 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 4765 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 4207 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 1833 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 4293 of file riscv-013.c.

Referenced by init_target().

◆ riscv013_on_halt()

static int riscv013_on_halt ( struct target target)
static

Definition at line 4288 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 4283 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  index 
)
static

Definition at line 4369 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 4278 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 4273 of file riscv-013.c.

References riscv013_step_or_resume_current_hart().

Referenced by init_target().

◆ riscv013_step_or_resume_current_hart()

◆ riscv013_test_sba_config_reg()

◆ riscv013_write_debug_buffer()

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

Definition at line 4354 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 2267 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 2062 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 1199 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  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  index,
riscv_reg_t  value,
unsigned  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()

◆ write_memory_sba_simple()

static void write_memory_sba_simple ( struct target target,
target_addr_t  addr,
uint32_t *  write_data,
uint32_t  write_size,
uint32_t  sbcs 
)
static

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:1566
static int deassert_reset(struct target *target)
Definition: riscv-013.c:2394
static int assert_reset(struct target *target)
Definition: riscv-013.c:2344
static int init_target(struct command_context *cmd_ctx, struct target *target)
Definition: riscv-013.c:2278
static int arch_state(struct target *target)
Definition: riscv-013.c:4047
static void deinit_target(struct target *target)
Definition: riscv-013.c:1524
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:3986
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:2305
int riscv_openocd_poll(struct target *target)
Definition: riscv.c:2184

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

Referenced by get_target_type().