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

Go to the source code of this file.

Data Structures

struct  ac_cache
 
struct  dm013_info_t
 
struct  mem_access_result
 
struct  riscv013_info_t
 
struct  scratch_mem_t
 
struct  target_list_t
 

Macros

#define ABSTRACT_COMMAND_BATCH_SIZE   2
 
#define CMDERR_BUSY   DM_ABSTRACTCS_CMDERR_BUSY
 
#define CMDERR_EXCEPTION   DM_ABSTRACTCS_CMDERR_EXCEPTION
 
#define CMDERR_HALT_RESUME   DM_ABSTRACTCS_CMDERR_HALT_RESUME
 
#define CMDERR_NONE   DM_ABSTRACTCS_CMDERR_NONE
 
#define CMDERR_NOT_SUPPORTED   DM_ABSTRACTCS_CMDERR_NOT_SUPPORTED
 
#define CMDERR_OTHER   DM_ABSTRACTCS_CMDERR_OTHER
 
#define HART_INDEX_MULTIPLE   -1
 
#define HART_INDEX_UNKNOWN   -2
 
#define LIST_OF_MEM_ACCESS_RESULTS
 
#define LOG_DEBUG_REG(t, r, v)   log_debug_reg(t, r##_ORDINAL, v, __FILE__, __LINE__, __func__)
 
#define MEM_ACCESS_RESULT_HANDLER(name, kind, msg)   name,
 
#define MEM_ACCESS_RESULT_HANDLER(name, kind, msg)
 
#define MEM_ACCESS_RESULT_HANDLER(name, kind, msg)
 
#define MEM_ACCESS_RESULT_HANDLER(name, kind, msg)
 
#define MEM_ACCESS_RESULT_HANDLER(name, kind, msg)    [name] = msg,
 
#define RISCV013_INFO(r)   riscv013_info_t *r = get_info(target)
 Since almost everything can be accomplish by scanning the dbus register, all functions here assume dbus is already selected. More...
 

Enumerations

enum  dmi_op_t { DMI_OP_NOP = DTM_DMI_OP_NOP , DMI_OP_READ = DTM_DMI_OP_READ , DMI_OP_WRITE = DTM_DMI_OP_WRITE }
 
enum  dmi_status_t { DMI_STATUS_SUCCESS = DTM_DMI_OP_SUCCESS , DMI_STATUS_FAILED = DTM_DMI_OP_FAILED , DMI_STATUS_BUSY = DTM_DMI_OP_BUSY }
 
enum  grouptype { HALT_GROUP , RESUME_GROUP }
 
enum  mem_access_result_enum { LIST_OF_MEM_ACCESS_RESULTS }
 
enum  mem_access_result_type {
  MEM_ACCESS_RESULT_TYPE_OK , MEM_ACCESS_RESULT_TYPE_DISABLED , MEM_ACCESS_RESULT_TYPE_SKIPPED , MEM_ACCESS_RESULT_TYPE_FAILED ,
  MEM_ACCESS_RESULT_TYPE_ENUM_SIZE
}
 
enum  memory_space_t { SPACE_DM_DATA , SPACE_DMI_PROGBUF , SPACE_DMI_RAM }
 

Functions

static uint32_t __attribute__ ((unused))
 
static int abstract_cmd_batch_check_and_clear_cmderr (struct target *target, const struct riscv_batch *batch, size_t abstractcs_read_key, uint32_t *cmderr)
 
static size_t abstract_cmd_fill_batch (struct riscv_batch *batch, uint32_t command)
 
static riscv_reg_t abstract_data_get_from_batch (struct riscv_batch *batch, unsigned int index, unsigned int size_bits)
 
static void abstract_data_read_fill_batch (struct riscv_batch *batch, unsigned int index, unsigned int size_bits)
 Queue scans into a batch that read the value from abstract data registers: data[index] (and data[index+1] in case of 64-bit value). More...
 
static void abstract_data_write_fill_batch (struct riscv_batch *batch, riscv_reg_t value, unsigned int index, unsigned int size_bits)
 Queue scans into a batch that write the value to abstract data registers: data[index] (and data[index+1] in case of 64-bit value). More...
 
static uint32_t abstract_memory_size (unsigned int width)
 
static struct ac_cache ac_cache_construct (void)
 
static bool ac_cache_contains (const struct ac_cache *cache, uint32_t command)
 
static int ac_cache_elem_comparator (const void *p_lhs, const void *p_rhs)
 
static void ac_cache_free (struct ac_cache *cache)
 
static void ac_cache_insert (struct ac_cache *cache, uint32_t command)
 
static struct mem_access_result access_memory_abstract (struct target *target, const struct riscv_mem_access_args args)
 
static uint32_t access_memory_command (struct target *target, bool virtual, unsigned int width, bool postincrement, bool is_write)
 
static struct mem_access_result access_memory_progbuf (struct target *target, const struct riscv_mem_access_args args)
 
static struct mem_access_result access_memory_sysbus (struct target *target, const struct riscv_mem_access_args args)
 
static int arch_state (struct target *target)
 
static int assert_reset (struct target *target)
 
static void batch_fill_sb_write_address (const struct target *target, struct riscv_batch *batch, target_addr_t address, enum riscv_scan_delay_class sbaddr0_delay)
 
static int batch_run (struct target *target, struct riscv_batch *batch)
 
static int batch_run_timeout (struct target *target, struct riscv_batch *batch)
 
static bool check_dbgbase_exists (struct target *target)
 
static int cleanup_after_register_access (struct target *target, riscv_reg_t mstatus, enum gdb_regno regno)
 
static int cleanup_after_vector_access (struct target *target, riscv_reg_t mstatus, riscv_reg_t vtype, riscv_reg_t vl)
 
static COMMAND_HELPER (riscv013_print_info, struct target *target)
 
static int csr_read_progbuf (struct target *target, uint64_t *value, enum gdb_regno number)
 
static int csr_write_progbuf (struct target *target, enum gdb_regno number, riscv_reg_t value)
 
static bool dcsr_ebreak_config_equals_reset_value (const struct target *target)
 
static int deassert_reset (struct target *target)
 
static void decrement_reset_delays_counter (struct target *target, size_t finished_scans)
 
static void deinit_target (struct target *target)
 
static int dm013_select_hart (struct target *target, int hart_index)
 
static int dm013_select_target (struct target *target)
 
static int dm_read (struct target *target, uint32_t *value, uint32_t address)
 
static int dm_read_exec (struct target *target, uint32_t *value, uint32_t address)
 
static int dm_write (struct target *target, uint32_t address, uint32_t value)
 
static int dmi_read (struct target *target, uint32_t *value, uint32_t address)
 
static int dmi_write (struct target *target, uint32_t address, uint32_t value)
 
static int dmstatus_read (struct target *target, uint32_t *dmstatus, bool authenticated)
 
static int examine (struct target *target)
 
static int examine_dm (struct target *target)
 
static int examine_progbuf (struct target *target)
 
static int execute_autofence (struct target *target)
 
static int fpr_read_progbuf (struct target *target, uint64_t *value, enum gdb_regno number)
 
static int fpr_write_progbuf (struct target *target, enum gdb_regno number, riscv_reg_t value)
 
enum riscv_debug_reg_ordinal get_cmdtype (uint32_t command)
 
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 struct riscv_debug_reg_ctx get_riscv_debug_reg_ctx (const struct target *target)
 
static unsigned int get_sbaadress_reg_count (const struct target *target)
 
static int halt_set_dcsr_ebreak (struct target *target)
 
static int handle_became_unavailable (struct target *target, enum riscv_hart_state previous_riscv_state)
 
static bool has_sufficient_progbuf (struct target *target, unsigned int size)
 
static int increase_ac_busy_delay (struct target *target)
 
static int increase_dmi_busy_delay (struct target *target)
 
static int init_target (struct command_context *cmd_ctx, struct target *target)
 
static int internal_register_read64_progbuf_scratch (struct target *target, struct riscv_program *program, riscv_reg_t *value)
 This function is used to read a 64-bit value from a register by executing a program. More...
 
static int internal_register_write64_progbuf_scratch (struct target *target, struct riscv_program *program, riscv_reg_t value)
 This function is used to write a 64-bit value to a register by executing a program. More...
 
static bool is_command_unsupported (struct target *target, uint32_t command)
 
static int is_fpu_reg (enum gdb_regno gdb_regno)
 
bool is_mem_access_failed (struct mem_access_result status)
 
bool is_mem_access_ok (struct mem_access_result status)
 
bool is_mem_access_skipped (struct mem_access_result status)
 
static int is_vector_reg (enum gdb_regno gdb_regno)
 
static void log_debug_reg (struct target *target, enum riscv_debug_reg_ordinal reg, riscv_reg_t value, const char *file, unsigned int line, const char *func)
 
static void log_mem_access_result (struct target *target, bool success, enum riscv_mem_access_method method, bool is_read)
 
static void log_memory_access (target_addr_t address, uint32_t *sbvalue, unsigned int size_bytes, bool is_read)
 
static void log_memory_access128 (target_addr_t address, uint64_t value_h, uint64_t value_l, bool is_read)
 
static void log_memory_access64 (target_addr_t address, uint64_t value, unsigned int size_bytes, bool is_read)
 
static void mark_command_as_unsupported (struct target *target, uint32_t command)
 
static struct mem_access_result mem_access_result (enum mem_access_result_enum value)
 
const char * mem_access_result_to_str (struct mem_access_result status)
 
static struct mem_access_result mem_should_skip_abstract (struct target *target, const struct riscv_mem_access_args args)
 
static struct mem_access_result mem_should_skip_progbuf (struct target *target, const struct riscv_mem_access_args args)
 
static struct mem_access_result mem_should_skip_sysbus (struct target *target, const struct riscv_mem_access_args args)
 
static int modify_privilege_for_virt2phys_mode (struct target *target, riscv_reg_t *mstatus, riscv_reg_t *mstatus_old, riscv_reg_t *dcsr, riscv_reg_t *dcsr_old)
 
static OOCD_LIST_HEAD (dm_list)
 
static int prep_for_register_access (struct target *target, riscv_reg_t *orig_mstatus, enum gdb_regno regno)
 
static int prep_for_vector_access (struct target *target, riscv_reg_t *orig_mstatus, riscv_reg_t *orig_vtype, riscv_reg_t *orig_vl, unsigned int *debug_vl, unsigned int *debug_vsew)
 
static int read_abstract_arg (struct target *target, riscv_reg_t *value, unsigned int index, unsigned int size_bits)
 
static struct mem_access_result read_memory_abstract (struct target *target, const struct riscv_mem_access_args args)
 
static int read_memory_bus_v0 (struct target *target, const struct riscv_mem_access_args args)
 
static int read_memory_bus_v1 (struct target *target, const struct riscv_mem_access_args args)
 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 struct mem_access_result read_memory_progbuf (struct target *target, const struct riscv_mem_access_args args)
 Read the requested memory, silently handling memory access errors. More...
 
static struct mem_access_result read_memory_progbuf_inner (struct target *target, const struct riscv_mem_access_args args)
 Read the requested memory, taking care to minimize the number of reads and re-read the data only if abstract command busy or DMI busy is encountered in the process. More...
 
static int read_memory_progbuf_inner_ensure_forward_progress (struct target *target, const struct riscv_mem_access_args args, uint32_t start_index)
 read_memory_progbuf_inner_startup() must be called before calling this function with the address argument equal to curr_target_address. More...
 
static int read_memory_progbuf_inner_extract_batch_data (struct target *target, const struct riscv_batch *batch, uint32_t start_index, uint32_t elements_to_read, uint32_t *elements_read, const struct riscv_mem_access_args args)
 This function extracts the data from the batch. More...
 
static uint32_t read_memory_progbuf_inner_fill_batch (struct riscv_batch *batch, uint32_t count, uint32_t size)
 
static int read_memory_progbuf_inner_fill_progbuf (struct target *target, uint32_t increment, uint32_t size)
 
static int read_memory_progbuf_inner_on_ac_busy (struct target *target, uint32_t start_index, uint32_t *elements_read, const struct riscv_mem_access_args args)
 This function attempts to restore the pipeline after a busy on abstract access. More...
 
static int read_memory_progbuf_inner_on_dmi_busy (struct target *target, uint32_t start_index, uint32_t next_start_index, const struct riscv_mem_access_args args)
 This function attempts to restore the pipeline after a dmi busy. More...
 
static struct mem_access_result read_memory_progbuf_inner_one (struct target *target, const struct riscv_mem_access_args args)
 Only need to save/restore one GPR to read a single word, and the progbuf program doesn't need to increment. More...
 
static int read_memory_progbuf_inner_run_and_process_batch (struct target *target, struct riscv_batch *batch, const struct riscv_mem_access_args args, uint32_t start_index, uint32_t elements_to_read, uint32_t *elements_read)
 This function reads a batch of elements from memory. More...
 
static int read_memory_progbuf_inner_startup (struct target *target, target_addr_t address, uint32_t increment, uint32_t index)
 This function is used to start the memory-reading pipeline. More...
 
static int read_memory_progbuf_inner_try_to_read (struct target *target, const struct riscv_mem_access_args args, uint32_t *elements_read, uint32_t index, uint32_t loop_count)
 
static int read_sbcs_nonbusy (struct target *target, uint32_t *sbcs)
 
static int read_word_from_dm_data_regs (struct target *target, const struct riscv_mem_access_args args, uint32_t index)
 
static struct mem_access_result read_word_from_s1 (struct target *target, const struct riscv_mem_access_args args, uint32_t index)
 
static int register_read_abstract (struct target *target, riscv_reg_t *value, enum gdb_regno number)
 
static int register_read_abstract_with_size (struct target *target, riscv_reg_t *value, enum gdb_regno number, unsigned int size)
 
static int register_read_direct (struct target *target, riscv_reg_t *value, enum gdb_regno number)
 Actually read registers from the target right now. More...
 
static int register_read_progbuf (struct target *target, uint64_t *value, enum gdb_regno number)
 This function reads a register by writing a program to program buffer and executing it. More...
 
static unsigned int register_size (struct target *target, enum gdb_regno number)
 Return register size in bits. More...
 
static int register_write_abstract (struct target *target, enum gdb_regno number, riscv_reg_t value)
 
static int register_write_direct (struct target *target, enum gdb_regno number, riscv_reg_t value)
 Immediately write the new value to the requested register. More...
 
static int register_write_progbuf (struct target *target, enum gdb_regno number, riscv_reg_t value)
 This function writes a register by writing a program to program buffer and executing it. More...
 
static int reset_dm (struct target *target)
 
static void reset_learned_delays (struct target *target)
 
static int restore_privilege_from_virt2phys_mode (struct target *target, riscv_reg_t mstatus, riscv_reg_t mstatus_old, riscv_reg_t dcsr, riscv_reg_t dcsr_old)
 
static int riscv013_access_memory (struct target *target, const struct riscv_mem_access_args args)
 
uint32_t riscv013_access_register_command (struct target *target, uint32_t number, unsigned int size, uint32_t flags)
 
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 int riscv013_clear_abstract_error (struct target *target)
 
static unsigned int riscv013_data_bits (struct target *target)
 
static void riscv013_dm_free (struct target *target)
 
int riscv013_execute_abstract_command (struct target *target, uint32_t command, uint32_t *cmderr)
 
static int riscv013_execute_progbuf (struct target *target, uint32_t *cmderr)
 
static void riscv013_fill_dm_nop (const struct target *target, uint8_t *buf)
 
static void riscv013_fill_dmi_read (const struct target *target, uint8_t *buf, uint32_t a)
 
static void riscv013_fill_dmi_write (const struct target *target, uint8_t *buf, uint32_t a, uint32_t d)
 
static uint32_t riscv013_get_dmi_address (const struct target *target, uint32_t address)
 
static unsigned int riscv013_get_dmi_address_bits (const struct target *target)
 
static int riscv013_get_hart_state (struct target *target, enum riscv_hart_state *state)
 
static bool riscv013_get_impebreak (const struct target *target)
 
static unsigned int riscv013_get_progbufsize (const struct target *target)
 
int riscv013_get_register (struct target *target, riscv_reg_t *value, enum gdb_regno rid)
 
int riscv013_get_register_buf (struct target *target, uint8_t *value, enum gdb_regno 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_invalidate_cached_progbuf (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_progbuf (struct target *target, unsigned int index)
 
static int riscv013_resume_go (struct target *target)
 
static int riscv013_resume_prep (struct target *target)
 
int riscv013_set_register (struct target *target, enum gdb_regno rid, riscv_reg_t value)
 
int riscv013_set_register_buf (struct target *target, enum gdb_regno 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)
 
static int riscv013_write_progbuf (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, enum riscv_scan_delay_class sbaddr0_delay)
 
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 jtag_tap *tap)
 
static int select_prepped_harts (struct target *target)
 
static void set_buffer_and_log_read (const struct riscv_mem_access_args args, uint32_t index, uint64_t value)
 
static int set_dcsr_ebreak (struct target *target, bool step)
 
static uint32_t set_dmcontrol_hartsel (uint32_t initial, int hart_index)
 
static int set_group (struct target *target, bool *supported, unsigned int group, enum grouptype grouptype)
 
static int set_group (struct target *target, bool *supported, unsigned int group, enum grouptype grouptype)
 
static int tick (struct target *target)
 
static int try_set_vsew (struct target *target, unsigned int *debug_vsew)
 
static int vl_write_progbuf (struct target *target, riscv_reg_t value)
 
static int vtype_write_progbuf (struct target *target, riscv_reg_t value)
 
static int wait_for_authbusy (struct target *target, uint32_t *dmstatus)
 
static int wait_for_idle (struct target *target, uint32_t *abstractcs)
 
static int wait_for_idle_if_needed (struct target *target)
 
static int write_abstract_arg (struct target *target, unsigned int index, riscv_reg_t value, unsigned int size_bits)
 
static struct mem_access_result write_memory_abstract (struct target *target, const struct riscv_mem_access_args args)
 
static int write_memory_bus_v0 (struct target *target, const struct riscv_mem_access_args args)
 
static int write_memory_bus_v1 (struct target *target, const struct riscv_mem_access_args args)
 
static struct mem_access_result write_memory_progbuf (struct target *target, const struct riscv_mem_access_args args)
 
static target_addr_t write_memory_progbuf_fill_batch (struct riscv_batch *batch, target_addr_t start_address, target_addr_t end_address, uint32_t size, const uint8_t *buffer)
 This function fills the batch with DMI writes (but does not execute the batch). More...
 
static int write_memory_progbuf_fill_progbuf (struct target *target, uint32_t size)
 
static int write_memory_progbuf_handle_busy (struct target *target, target_addr_t *address_p, target_addr_t end_address, uint32_t size, const uint8_t *buffer)
 This function attempts to restore the pipeline after a busy on abstract access or a DMI busy by reading the content of s0 – the address of the failed write. More...
 
static struct mem_access_result write_memory_progbuf_inner (struct target *target, const struct riscv_mem_access_args args)
 
static int write_memory_progbuf_run_batch (struct target *target, struct riscv_batch *batch, target_addr_t *address_p, target_addr_t end_address, uint32_t size, const uint8_t *buffer)
 This function runs the batch of writes and updates address_p with the address of the next write. More...
 
static int write_memory_progbuf_startup (struct target *target, target_addr_t *address_p, const uint8_t *buffer, uint32_t size)
 This function is used to start the memory-writing pipeline. More...
 
static int write_memory_progbuf_teardown (struct target *target)
 This function reverts the changes made by write_memory_progbuf_startup() More...
 
static int write_memory_progbuf_try_to_write (struct target *target, target_addr_t *address_p, target_addr_t end_address, uint32_t size, const uint8_t *buffer)
 

Variables

struct target_type riscv013_target
 

Macro Definition Documentation

◆ ABSTRACT_COMMAND_BATCH_SIZE

#define ABSTRACT_COMMAND_BATCH_SIZE   2

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

◆ CMDERR_BUSY

#define CMDERR_BUSY   DM_ABSTRACTCS_CMDERR_BUSY

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

◆ CMDERR_EXCEPTION

#define CMDERR_EXCEPTION   DM_ABSTRACTCS_CMDERR_EXCEPTION

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

◆ CMDERR_HALT_RESUME

#define CMDERR_HALT_RESUME   DM_ABSTRACTCS_CMDERR_HALT_RESUME

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

◆ CMDERR_NONE

#define CMDERR_NONE   DM_ABSTRACTCS_CMDERR_NONE

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

◆ CMDERR_NOT_SUPPORTED

#define CMDERR_NOT_SUPPORTED   DM_ABSTRACTCS_CMDERR_NOT_SUPPORTED

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

◆ CMDERR_OTHER

#define CMDERR_OTHER   DM_ABSTRACTCS_CMDERR_OTHER

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

◆ HART_INDEX_MULTIPLE

#define HART_INDEX_MULTIPLE   -1

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

◆ HART_INDEX_UNKNOWN

#define HART_INDEX_UNKNOWN   -2

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

◆ LIST_OF_MEM_ACCESS_RESULTS

#define LIST_OF_MEM_ACCESS_RESULTS

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

◆ LOG_DEBUG_REG

#define LOG_DEBUG_REG (   t,
  r,
 
)    log_debug_reg(t, r##_ORDINAL, v, __FILE__, __LINE__, __func__)

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

◆ MEM_ACCESS_RESULT_HANDLER [1/5]

#define MEM_ACCESS_RESULT_HANDLER (   name,
  kind,
  msg 
)    name,

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

◆ MEM_ACCESS_RESULT_HANDLER [2/5]

#define MEM_ACCESS_RESULT_HANDLER (   name,
  kind,
  msg 
)
Value:
case name: return MEM_ACCESS_RESULT_TYPE_##kind \
const char * name
Definition: armv4_5.c:76
@ MEM_ACCESS_RESULT_TYPE_OK
Definition: riscv-013.c:3533

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

◆ MEM_ACCESS_RESULT_HANDLER [3/5]

#define MEM_ACCESS_RESULT_HANDLER (   name,
  kind,
  msg 
)
Value:
case name: return MEM_ACCESS_RESULT_TYPE_##kind \
@ MEM_ACCESS_RESULT_TYPE_FAILED
Definition: riscv-013.c:3536

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

◆ MEM_ACCESS_RESULT_HANDLER [4/5]

#define MEM_ACCESS_RESULT_HANDLER (   name,
  kind,
  msg 
)
Value:
case name: return MEM_ACCESS_RESULT_TYPE_##kind \
@ MEM_ACCESS_RESULT_TYPE_SKIPPED
Definition: riscv-013.c:3535

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

◆ MEM_ACCESS_RESULT_HANDLER [5/5]

#define MEM_ACCESS_RESULT_HANDLER (   name,
  kind,
  msg 
)     [name] = msg,

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

◆ RISCV013_INFO

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

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 85 of file riscv-013.c.

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.

◆ grouptype

enum grouptype
Enumerator
HALT_GROUP 
RESUME_GROUP 

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

◆ mem_access_result_enum

Enumerator
LIST_OF_MEM_ACCESS_RESULTS 

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

◆ mem_access_result_type

Enumerator
MEM_ACCESS_RESULT_TYPE_OK 
MEM_ACCESS_RESULT_TYPE_DISABLED 
MEM_ACCESS_RESULT_TYPE_SKIPPED 
MEM_ACCESS_RESULT_TYPE_FAILED 
MEM_ACCESS_RESULT_TYPE_ENUM_SIZE 

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

◆ memory_space_t

Enumerator
SPACE_DM_DATA 
SPACE_DMI_PROGBUF 
SPACE_DMI_RAM 

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

Function Documentation

◆ __attribute__()

static uint32_t __attribute__ ( (unused)  )
staticpure virtual

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

References AC_ACCESS_REGISTER_AARSIZE, LOG_ERROR, set_field(), and width.

◆ abstract_cmd_batch_check_and_clear_cmderr()

static int abstract_cmd_batch_check_and_clear_cmderr ( struct target target,
const struct riscv_batch batch,
size_t  abstractcs_read_key,
uint32_t *  cmderr 
)
static

◆ abstract_cmd_fill_batch()

static size_t abstract_cmd_fill_batch ( struct riscv_batch batch,
uint32_t  command 
)
static

◆ abstract_data_get_from_batch()

static riscv_reg_t abstract_data_get_from_batch ( struct riscv_batch batch,
unsigned int  index,
unsigned int  size_bits 
)
static

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

References riscv_batch_get_dmi_read_data().

Referenced by read_abstract_arg().

◆ abstract_data_read_fill_batch()

static void abstract_data_read_fill_batch ( struct riscv_batch batch,
unsigned int  index,
unsigned int  size_bits 
)
static

Queue scans into a batch that read the value from abstract data registers: data[index] (and data[index+1] in case of 64-bit value).

No extra DTM delay is added after the write to data[N]. It is assumed that this is a one-shot abstract command, that means no auto-execution is set up (abstractauto.autoexecdata bits are zero).

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

References DM_DATA0, offset, riscv_batch_add_dm_read(), and RISCV_DELAY_BASE.

Referenced by read_abstract_arg().

◆ abstract_data_write_fill_batch()

static void abstract_data_write_fill_batch ( struct riscv_batch batch,
riscv_reg_t  value,
unsigned int  index,
unsigned int  size_bits 
)
static

Queue scans into a batch that write the value to abstract data registers: data[index] (and data[index+1] in case of 64-bit value).

No extra DTM delay is added after the write to data[N]. It is assumed that this is a one-shot abstract command, that means no auto-execution is set up (abstractauto.autoexecdata bits are zero).

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

References DM_DATA0, offset, riscv_batch_add_dm_write(), and RISCV_DELAY_BASE.

Referenced by register_write_abstract().

◆ abstract_memory_size()

static uint32_t abstract_memory_size ( unsigned int  width)
static

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

References AC_ACCESS_MEMORY_AAMSIZE, LOG_ERROR, set_field(), and width.

Referenced by access_memory_command().

◆ ac_cache_construct()

static struct ac_cache ac_cache_construct ( void  )
static

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

Referenced by init_target().

◆ ac_cache_contains()

static bool ac_cache_contains ( const struct ac_cache cache,
uint32_t  command 
)
static

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

References ac_cache_elem_comparator(), ac_cache::commands, and ac_cache::size.

Referenced by is_command_unsupported().

◆ ac_cache_elem_comparator()

static int ac_cache_elem_comparator ( const void *  p_lhs,
const void *  p_rhs 
)
static

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

Referenced by ac_cache_contains(), and ac_cache_insert().

◆ ac_cache_free()

static void ac_cache_free ( struct ac_cache cache)
static

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

References ac_cache::commands, NULL, and ac_cache::size.

Referenced by deinit_target().

◆ ac_cache_insert()

static void ac_cache_insert ( struct ac_cache cache,
uint32_t  command 
)
static

◆ access_memory_abstract()

static struct mem_access_result access_memory_abstract ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

Referenced by riscv013_access_memory().

◆ access_memory_command()

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

◆ access_memory_progbuf()

static struct mem_access_result access_memory_progbuf ( struct target target,
const struct riscv_mem_access_args  args 
)
static

◆ access_memory_sysbus()

static struct mem_access_result access_memory_sysbus ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

Referenced by riscv013_access_memory().

◆ arch_state()

static int arch_state ( struct target target)
static

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

References ERROR_OK.

◆ assert_reset()

◆ batch_fill_sb_write_address()

static void batch_fill_sb_write_address ( const struct target target,
struct riscv_batch batch,
target_addr_t  address,
enum riscv_scan_delay_class  sbaddr0_delay 
)
static

◆ batch_run()

◆ batch_run_timeout()

◆ check_dbgbase_exists()

static bool check_dbgbase_exists ( struct target target)
static

◆ cleanup_after_register_access()

static int cleanup_after_register_access ( struct target target,
riscv_reg_t  mstatus,
enum gdb_regno  regno 
)
static

◆ cleanup_after_vector_access()

static int cleanup_after_vector_access ( struct target target,
riscv_reg_t  mstatus,
riscv_reg_t  vtype,
riscv_reg_t  vl 
)
static

◆ COMMAND_HELPER()

static COMMAND_HELPER ( riscv013_print_info  ,
struct target target 
)
static

◆ csr_read_progbuf()

static int csr_read_progbuf ( struct target target,
uint64_t *  value,
enum gdb_regno  number 
)
static

◆ csr_write_progbuf()

static int csr_write_progbuf ( struct target target,
enum gdb_regno  number,
riscv_reg_t  value 
)
static

◆ dcsr_ebreak_config_equals_reset_value()

static bool dcsr_ebreak_config_equals_reset_value ( const struct target target)
static

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

References config, N_RISCV_MODE, and riscv_private_config().

Referenced by deassert_reset().

◆ deassert_reset()

◆ decrement_reset_delays_counter()

static void decrement_reset_delays_counter ( struct target target,
size_t  finished_scans 
)
static

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

References LOG_TARGET_DEBUG, reset_learned_delays(), and RISCV_INFO.

Referenced by batch_run(), and batch_run_timeout().

◆ deinit_target()

static void deinit_target ( struct target target)
static

◆ dm013_select_hart()

static int dm013_select_hart ( struct target target,
int  hart_index 
)
static

◆ dm013_select_target()

◆ dm_read()

◆ dm_read_exec()

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

◆ dm_write()

◆ dmi_read()

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

◆ dmi_write()

static int dmi_write ( struct target target,
uint32_t  address,
uint32_t  value 
)
static

◆ dmstatus_read()

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

◆ examine()

◆ examine_dm()

◆ examine_progbuf()

◆ execute_autofence()

◆ fpr_read_progbuf()

◆ fpr_write_progbuf()

◆ get_cmdtype()

enum riscv_debug_reg_ordinal get_cmdtype ( uint32_t  command)

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

Referenced by is_command_unsupported(), and mark_command_as_unsupported().

◆ get_dm()

◆ get_info()

◆ get_riscv_debug_reg_ctx()

static struct riscv_debug_reg_ctx get_riscv_debug_reg_ctx ( const struct target target)
static

◆ get_sbaadress_reg_count()

static unsigned int get_sbaadress_reg_count ( const struct target target)
static

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

References DIV_ROUND_UP, DM_SBCS_SBASIZE, get_field(), info, and RISCV013_INFO.

Referenced by batch_fill_sb_write_address(), and sb_write_address().

◆ halt_set_dcsr_ebreak()

◆ handle_became_unavailable()

static int handle_became_unavailable ( struct target target,
enum riscv_hart_state  previous_riscv_state 
)
static

◆ has_sufficient_progbuf()

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

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

References info, RISCV013_INFO, and size.

Referenced by examine(), execute_autofence(), riscv013_data_bits(), and riscv013_on_step_or_resume().

◆ increase_ac_busy_delay()

static int increase_ac_busy_delay ( struct target target)
static

◆ increase_dmi_busy_delay()

static int increase_dmi_busy_delay ( struct target target)
static

◆ init_target()

◆ internal_register_read64_progbuf_scratch()

static int internal_register_read64_progbuf_scratch ( struct target target,
struct riscv_program program,
riscv_reg_t value 
)
static

This function is used to read a 64-bit value from a register by executing a program.

The program stores a register to address located in S0. The caller should save S0.

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

References ERROR_FAIL, ERROR_OK, GDB_REGNO_S0, scratch_mem_t::hart_address, register_write_abstract(), riscv_program_exec(), scratch_read64(), scratch_release(), and scratch_reserve().

Referenced by fpr_read_progbuf().

◆ internal_register_write64_progbuf_scratch()

static int internal_register_write64_progbuf_scratch ( struct target target,
struct riscv_program program,
riscv_reg_t  value 
)
static

This function is used to write a 64-bit value to a register by executing a program.

The program loads a value from address located in S0 to a register. The caller should save S0.

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

References ERROR_FAIL, ERROR_OK, GDB_REGNO_S0, scratch_mem_t::hart_address, register_write_abstract(), riscv_program_exec(), scratch_release(), scratch_reserve(), and scratch_write64().

Referenced by fpr_write_progbuf().

◆ is_command_unsupported()

static bool is_command_unsupported ( struct target target,
uint32_t  command 
)
static

◆ is_fpu_reg()

static int is_fpu_reg ( enum gdb_regno  gdb_regno)
static

◆ is_mem_access_failed()

bool is_mem_access_failed ( struct mem_access_result  status)

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

References LIST_OF_MEM_ACCESS_RESULTS, LOG_ERROR, and status.

Referenced by riscv013_access_memory().

◆ is_mem_access_ok()

bool is_mem_access_ok ( struct mem_access_result  status)

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

References LIST_OF_MEM_ACCESS_RESULTS, LOG_ERROR, and status.

Referenced by riscv013_access_memory().

◆ is_mem_access_skipped()

bool is_mem_access_skipped ( struct mem_access_result  status)

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

References LIST_OF_MEM_ACCESS_RESULTS, LOG_ERROR, and status.

◆ is_vector_reg()

static int is_vector_reg ( enum gdb_regno  gdb_regno)
static

◆ log_debug_reg()

static void log_debug_reg ( struct target target,
enum riscv_debug_reg_ordinal  reg,
riscv_reg_t  value,
const char *  file,
unsigned int  line,
const char *  func 
)
static

◆ log_mem_access_result()

static void log_mem_access_result ( struct target target,
bool  success,
enum riscv_mem_access_method  method,
bool  is_read 
)
static

◆ log_memory_access()

static void log_memory_access ( target_addr_t  address,
uint32_t *  sbvalue,
unsigned int  size_bytes,
bool  is_read 
)
static

◆ log_memory_access128()

static void log_memory_access128 ( target_addr_t  address,
uint64_t  value_h,
uint64_t  value_l,
bool  is_read 
)
static

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

References address, LOG_DEBUG, LOG_LEVEL_IS, LOG_LVL_DEBUG, and TARGET_PRIxADDR.

Referenced by log_memory_access().

◆ log_memory_access64()

static void log_memory_access64 ( target_addr_t  address,
uint64_t  value,
unsigned int  size_bytes,
bool  is_read 
)
static

◆ mark_command_as_unsupported()

static void mark_command_as_unsupported ( struct target target,
uint32_t  command 
)
static

◆ mem_access_result()

static struct mem_access_result mem_access_result ( enum mem_access_result_enum  value)
static

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

References ARRAY_SIZE, LIST_OF_MEM_ACCESS_RESULTS, and status.

Referenced by riscv013_access_memory().

◆ mem_access_result_to_str()

const char* mem_access_result_to_str ( struct mem_access_result  status)

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

Referenced by riscv013_access_memory().

◆ mem_should_skip_abstract()

static struct mem_access_result mem_should_skip_abstract ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

◆ mem_should_skip_progbuf()

static struct mem_access_result mem_should_skip_progbuf ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

◆ mem_should_skip_sysbus()

static struct mem_access_result mem_should_skip_sysbus ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

◆ modify_privilege_for_virt2phys_mode()

static int modify_privilege_for_virt2phys_mode ( struct target target,
riscv_reg_t mstatus,
riscv_reg_t mstatus_old,
riscv_reg_t dcsr,
riscv_reg_t dcsr_old 
)
static

◆ OOCD_LIST_HEAD()

static OOCD_LIST_HEAD ( dm_list  )
static

◆ prep_for_register_access()

◆ prep_for_vector_access()

static int prep_for_vector_access ( struct target target,
riscv_reg_t orig_mstatus,
riscv_reg_t orig_vtype,
riscv_reg_t orig_vl,
unsigned int *  debug_vl,
unsigned int *  debug_vsew 
)
static

◆ read_abstract_arg()

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

◆ read_memory_abstract()

static struct mem_access_result read_memory_abstract ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

◆ read_memory_bus_v0()

◆ 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()

static struct mem_access_result read_memory_progbuf ( struct target target,
const struct riscv_mem_access_args  args 
)
static

Read the requested memory, silently handling memory access errors.

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

◆ read_memory_progbuf_inner()

static struct mem_access_result read_memory_progbuf_inner ( struct target target,
const struct riscv_mem_access_args  args 
)
static

Read the requested memory, taking care to minimize the number of reads and re-read the data only if abstract command busy or DMI busy is encountered in the process.

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

◆ read_memory_progbuf_inner_ensure_forward_progress()

static int read_memory_progbuf_inner_ensure_forward_progress ( struct target target,
const struct riscv_mem_access_args  args,
uint32_t  start_index 
)
static

◆ read_memory_progbuf_inner_extract_batch_data()

static int read_memory_progbuf_inner_extract_batch_data ( struct target target,
const struct riscv_batch batch,
uint32_t  start_index,
uint32_t  elements_to_read,
uint32_t *  elements_read,
const struct riscv_mem_access_args  args 
)
static

◆ read_memory_progbuf_inner_fill_batch()

static uint32_t read_memory_progbuf_inner_fill_batch ( struct riscv_batch batch,
uint32_t  count,
uint32_t  size 
)
static

◆ read_memory_progbuf_inner_fill_progbuf()

static int read_memory_progbuf_inner_fill_progbuf ( struct target target,
uint32_t  increment,
uint32_t  size 
)
static

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

◆ read_memory_progbuf_inner_on_ac_busy()

static int read_memory_progbuf_inner_on_ac_busy ( struct target target,
uint32_t  start_index,
uint32_t *  elements_read,
const struct riscv_mem_access_args  args 
)
static

This function attempts to restore the pipeline after a busy on abstract access.

Target's state is as follows: s0 contains address + index_on_target * increment s1 contains mem[address + (index_on_target - 1) * increment] dm_data[0:1] contains mem[address + (index_on_target - 2) * increment]

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

References riscv_mem_access_args::address, DM_ABSTRACTAUTO, dm_write(), ERROR_FAIL, ERROR_OK, GDB_REGNO_A0, GDB_REGNO_S0, increase_ac_busy_delay(), riscv_mem_access_args::increment, LOG_TARGET_DEBUG, LOG_TARGET_ERROR, LOG_TARGET_WARNING, read_memory_progbuf_inner_startup(), register_read_direct(), riscv013_clear_abstract_error(), riscv_mem_access_is_read(), and TARGET_PRIxADDR.

Referenced by read_memory_progbuf_inner_run_and_process_batch().

◆ read_memory_progbuf_inner_on_dmi_busy()

static int read_memory_progbuf_inner_on_dmi_busy ( struct target target,
uint32_t  start_index,
uint32_t  next_start_index,
const struct riscv_mem_access_args  args 
)
static

◆ read_memory_progbuf_inner_one()

static struct mem_access_result read_memory_progbuf_inner_one ( struct target target,
const struct riscv_mem_access_args  args 
)
static

Only need to save/restore one GPR to read a single word, and the progbuf program doesn't need to increment.

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

◆ read_memory_progbuf_inner_run_and_process_batch()

static int read_memory_progbuf_inner_run_and_process_batch ( struct target target,
struct riscv_batch batch,
const struct riscv_mem_access_args  args,
uint32_t  start_index,
uint32_t  elements_to_read,
uint32_t *  elements_read 
)
static

This function reads a batch of elements from memory.

Prior to calling this function the folowing conditions should be met:

  • Appropriate program loaded to program buffer.
  • DM_ABSTRACTAUTO_AUTOEXECDATA is set.

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

References dm013_info_t::abstract_cmd_maybe_busy, batch_run(), CMDERR_BUSY, CMDERR_NONE, DM_ABSTRACTCS_CMDERR, ERROR_FAIL, ERROR_OK, get_dm(), get_field32(), LOG_TARGET_DEBUG, read_memory_progbuf_inner_extract_batch_data(), read_memory_progbuf_inner_on_ac_busy(), riscv013_clear_abstract_error(), riscv_mem_access_is_read(), and wait_for_idle().

Referenced by read_memory_progbuf_inner_try_to_read().

◆ read_memory_progbuf_inner_startup()

static int read_memory_progbuf_inner_startup ( struct target target,
target_addr_t  address,
uint32_t  increment,
uint32_t  index 
)
static

This function is used to start the memory-reading pipeline.

The pipeline looks like this: memory -> s1 -> dm_data[0:1] -> debugger Prior to calling it, the program buffer should contain the appropriate program. This function sets DM_ABSTRACTAUTO_AUTOEXECDATA to trigger second stage of the pipeline (s1 -> dm_data[0:1]) whenever dm_data is read.

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

References AC_ACCESS_REGISTER_POSTEXEC, AC_ACCESS_REGISTER_TRANSFER, address, CMDERR_BUSY, CMDERR_NONE, DM_ABSTRACTAUTO, DM_ABSTRACTAUTO_AUTOEXECDATA, DM_ABSTRACTCS_CMDERR, DM_DATA0, dm_read_exec(), dm_write(), ERROR_FAIL, ERROR_OK, GDB_REGNO_A0, GDB_REGNO_S0, GDB_REGNO_S1, get_field32(), LOG_TARGET_DEBUG, LOG_TARGET_ERROR, NULL, register_write_direct(), riscv013_access_register_command(), riscv013_clear_abstract_error(), riscv013_execute_abstract_command(), riscv_xlen(), set_field(), and wait_for_idle().

Referenced by read_memory_progbuf_inner_on_ac_busy(), and read_memory_progbuf_inner_on_dmi_busy().

◆ read_memory_progbuf_inner_try_to_read()

static int read_memory_progbuf_inner_try_to_read ( struct target target,
const struct riscv_mem_access_args  args,
uint32_t *  elements_read,
uint32_t  index,
uint32_t  loop_count 
)
static

◆ read_sbcs_nonbusy()

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

◆ read_word_from_dm_data_regs()

static int read_word_from_dm_data_regs ( struct target target,
const struct riscv_mem_access_args  args,
uint32_t  index 
)
static

◆ read_word_from_s1()

static struct mem_access_result read_word_from_s1 ( struct target target,
const struct riscv_mem_access_args  args,
uint32_t  index 
)
static

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

◆ register_read_abstract()

static int register_read_abstract ( struct target target,
riscv_reg_t value,
enum gdb_regno  number 
)
static

◆ register_read_abstract_with_size()

static int register_read_abstract_with_size ( struct target target,
riscv_reg_t value,
enum gdb_regno  number,
unsigned int  size 
)
static

◆ register_read_direct()

◆ register_read_progbuf()

static int register_read_progbuf ( struct target target,
uint64_t *  value,
enum gdb_regno  number 
)
static

This function reads a register by writing a program to program buffer and executing it.

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

References csr_read_progbuf(), ERROR_FAIL, fpr_read_progbuf(), GDB_REGNO_CSR0, GDB_REGNO_CSR4095, GDB_REGNO_FPR0, GDB_REGNO_FPR31, LOG_TARGET_ERROR, number, riscv_reg_gdb_regno_name(), target::state, and TARGET_HALTED.

Referenced by register_read_direct().

◆ register_size()

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

Return register size in bits.

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

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

Referenced by register_read_abstract(), and register_write_abstract().

◆ register_write_abstract()

◆ register_write_direct()

static int register_write_direct ( struct target target,
enum gdb_regno  number,
riscv_reg_t  value 
)
static

◆ register_write_progbuf()

static int register_write_progbuf ( struct target target,
enum gdb_regno  number,
riscv_reg_t  value 
)
static

◆ reset_dm()

◆ reset_learned_delays()

static void reset_learned_delays ( struct target target)
static

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

References info, and RISCV013_INFO.

Referenced by decrement_reset_delays_counter(), and init_target().

◆ restore_privilege_from_virt2phys_mode()

static int restore_privilege_from_virt2phys_mode ( struct target target,
riscv_reg_t  mstatus,
riscv_reg_t  mstatus_old,
riscv_reg_t  dcsr,
riscv_reg_t  dcsr_old 
)
static

◆ riscv013_access_memory()

◆ riscv013_access_register_command()

◆ riscv013_authdata_read()

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

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

References DM_AUTHDATA, dm_read(), ERROR_FAIL, ERROR_OK, LOG_TARGET_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()

◆ riscv013_data_bits()

◆ riscv013_dm_free()

static void riscv013_dm_free ( struct target target)
static

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

Referenced by deinit_target().

◆ riscv013_execute_abstract_command()

◆ riscv013_execute_progbuf()

static int riscv013_execute_progbuf ( struct target target,
uint32_t *  cmderr 
)
static

◆ riscv013_fill_dm_nop()

static void riscv013_fill_dm_nop ( const struct target target,
uint8_t *  buf 
)
static

◆ riscv013_fill_dmi_read()

static void riscv013_fill_dmi_read ( const struct target target,
uint8_t *  buf,
uint32_t  a 
)
static

◆ riscv013_fill_dmi_write()

static void riscv013_fill_dmi_write ( const struct target target,
uint8_t *  buf,
uint32_t  a,
uint32_t  d 
)
static

◆ riscv013_get_dmi_address()

static uint32_t riscv013_get_dmi_address ( const struct target target,
uint32_t  address 
)
static

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

References address, info, and RISCV013_INFO.

Referenced by dm_read(), dm_write(), and init_target().

◆ riscv013_get_dmi_address_bits()

static unsigned int riscv013_get_dmi_address_bits ( const struct target target)
static

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

References info, and RISCV013_INFO.

Referenced by init_target().

◆ riscv013_get_hart_state()

◆ riscv013_get_impebreak()

static bool riscv013_get_impebreak ( const struct target target)
static

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

References RISCV013_INFO.

Referenced by init_target().

◆ riscv013_get_progbufsize()

static unsigned int riscv013_get_progbufsize ( const struct target target)
static

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

References RISCV013_INFO.

Referenced by init_target().

◆ riscv013_get_register()

◆ riscv013_get_register_buf()

◆ riscv013_halt_go()

◆ riscv013_halt_prep()

static int riscv013_halt_prep ( struct target target)
static

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

References ERROR_OK.

Referenced by init_target().

◆ riscv013_halt_reason()

static enum riscv_halt_reason riscv013_halt_reason ( struct target target)
static

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

References riscv013_on_step_or_resume().

Referenced by init_target().

◆ riscv013_invalidate_cached_progbuf()

static int riscv013_invalidate_cached_progbuf ( struct target target)
static

◆ riscv013_on_step()

static int riscv013_on_step ( struct target target)
static

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

Referenced by init_target().

◆ riscv013_on_step_or_resume()

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

◆ riscv013_read_progbuf()

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

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

References DM_PROGBUF0, dm_read(), and ERROR_OK.

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 5347 of file riscv-013.c.

References riscv013_on_step_or_resume(), target::state, and TARGET_HALTED.

Referenced by init_target().

◆ riscv013_set_register()

int riscv013_set_register ( struct target target,
enum gdb_regno  rid,
riscv_reg_t  value 
)

◆ riscv013_set_register_buf()

◆ riscv013_step_current_hart()

static int riscv013_step_current_hart ( struct target target)
static

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

References riscv013_step_or_resume_current_hart().

Referenced by init_target().

◆ riscv013_step_or_resume_current_hart()

◆ riscv013_write_progbuf()

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

◆ 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 2767 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 2458 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,
enum riscv_scan_delay_class  sbaddr0_delay 
)
static

◆ sba_supports_access()

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

◆ scratch_read64()

◆ scratch_release()

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

◆ scratch_reserve()

◆ scratch_write64()

◆ select_dmi()

◆ select_prepped_harts()

◆ set_buffer_and_log_read()

static void set_buffer_and_log_read ( const struct riscv_mem_access_args  args,
uint32_t  index,
uint64_t  value 
)
static

◆ set_dcsr_ebreak()

◆ set_dmcontrol_hartsel()

◆ set_group() [1/2]

static int set_group ( struct target target,
bool *  supported,
unsigned int  group,
enum grouptype  grouptype 
)
static

Referenced by examine(), and halt_set_dcsr_ebreak().

◆ set_group() [2/2]

static int set_group ( struct target target,
bool *  supported,
unsigned int  group,
enum grouptype  grouptype 
)
static

◆ tick()

static int tick ( struct target target)
static

◆ try_set_vsew()

static int try_set_vsew ( struct target target,
unsigned int *  debug_vsew 
)
static

◆ vl_write_progbuf()

◆ vtype_write_progbuf()

◆ wait_for_authbusy()

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

◆ wait_for_idle()

◆ wait_for_idle_if_needed()

◆ write_abstract_arg()

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

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

References DM_DATA0, dm_write(), ERROR_FAIL, ERROR_OK, LOG_TARGET_ERROR, and offset.

Referenced by write_memory_progbuf_startup().

◆ write_memory_abstract()

static struct mem_access_result write_memory_abstract ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

◆ write_memory_bus_v0()

◆ write_memory_bus_v1()

◆ write_memory_progbuf()

static struct mem_access_result write_memory_progbuf ( struct target target,
const struct riscv_mem_access_args  args 
)
static

◆ write_memory_progbuf_fill_batch()

static target_addr_t write_memory_progbuf_fill_batch ( struct riscv_batch batch,
target_addr_t  start_address,
target_addr_t  end_address,
uint32_t  size,
const uint8_t *  buffer 
)
static

This function fills the batch with DMI writes (but does not execute the batch).

It returns the next address – the address that will be the start of the next batch.

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

References address, buf_get_u64(), buffer, DM_DATA0, DM_DATA1, log_memory_access64(), MIN, riscv_batch_add_dm_write(), riscv_batch_available_scans(), RISCV_DELAY_ABSTRACT_COMMAND, RISCV_DELAY_BASE, and size.

Referenced by write_memory_progbuf_try_to_write().

◆ write_memory_progbuf_fill_progbuf()

static int write_memory_progbuf_fill_progbuf ( struct target target,
uint32_t  size 
)
static

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

◆ write_memory_progbuf_handle_busy()

static int write_memory_progbuf_handle_busy ( struct target target,
target_addr_t address_p,
target_addr_t  end_address,
uint32_t  size,
const uint8_t *  buffer 
)
static

This function attempts to restore the pipeline after a busy on abstract access or a DMI busy by reading the content of s0 – the address of the failed write.

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

References buffer, ERROR_FAIL, ERROR_OK, GDB_REGNO_S0, increase_ac_busy_delay(), LOG_TARGET_DEBUG, register_read_direct(), riscv013_clear_abstract_error(), size, TARGET_PRIxADDR, write_memory_progbuf_startup(), and write_memory_progbuf_teardown().

Referenced by write_memory_progbuf_run_batch().

◆ write_memory_progbuf_inner()

static struct mem_access_result write_memory_progbuf_inner ( struct target target,
const struct riscv_mem_access_args  args 
)
static

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

◆ write_memory_progbuf_run_batch()

static int write_memory_progbuf_run_batch ( struct target target,
struct riscv_batch batch,
target_addr_t address_p,
target_addr_t  end_address,
uint32_t  size,
const uint8_t *  buffer 
)
static

◆ write_memory_progbuf_startup()

static int write_memory_progbuf_startup ( struct target target,
target_addr_t address_p,
const uint8_t *  buffer,
uint32_t  size 
)
static

This function is used to start the memory-writing pipeline.

As part of the process, the function writes the first item and waits for completion, so forward progress is ensured. The pipeline looks like this: debugger -> dm_data[0:1] -> s1 -> memory Prior to calling it, the program buffer should contain the appropriate program. This function sets DM_ABSTRACTAUTO_AUTOEXECDATA to trigger second stage of the pipeline (dm_data[0:1] -> s1) whenever dm_data is written.

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

References AC_ACCESS_REGISTER_POSTEXEC, AC_ACCESS_REGISTER_TRANSFER, AC_ACCESS_REGISTER_WRITE, buf_get_u64(), buffer, DM_ABSTRACTAUTO, DM_ABSTRACTAUTO_AUTOEXECDATA_OFFSET, dm_write(), ERROR_FAIL, ERROR_OK, GDB_REGNO_S0, GDB_REGNO_S1, log_memory_access64(), register_write_direct(), riscv013_access_register_command(), riscv013_execute_abstract_command(), riscv_xlen(), size, and write_abstract_arg().

Referenced by write_memory_progbuf_handle_busy().

◆ write_memory_progbuf_teardown()

static int write_memory_progbuf_teardown ( struct target target)
static

This function reverts the changes made by write_memory_progbuf_startup()

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

References DM_ABSTRACTAUTO, and dm_write().

Referenced by write_memory_progbuf_handle_busy().

◆ write_memory_progbuf_try_to_write()

static int write_memory_progbuf_try_to_write ( struct target target,
target_addr_t address_p,
target_addr_t  end_address,
uint32_t  size,
const uint8_t *  buffer 
)
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,
.arch_state = arch_state
}
static int examine(struct target *target)
Definition: riscv-013.c:1994
static int deassert_reset(struct target *target)
Definition: riscv-013.c:2958
static int assert_reset(struct target *target)
Definition: riscv-013.c:2907
static int init_target(struct command_context *cmd_ctx, struct target *target)
Definition: riscv-013.c:2854
static int arch_state(struct target *target)
Definition: riscv-013.c:5087
static void deinit_target(struct target *target)
Definition: riscv-013.c:1776
int riscv_halt(struct target *target)
Definition: riscv.c:2708
int riscv_openocd_poll(struct target *target)
Definition: riscv.c:4016
int riscv_openocd_step(struct target *target, bool current, target_addr_t address, bool handle_breakpoints)
Definition: riscv.c:4287

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

Referenced by get_target_type().