3 #ifndef OPENOCD_TARGET_RISCV_RISCV_H
4 #define OPENOCD_TARGET_RISCV_RISCV_H
18 #define RISCV_COMMON_MAGIC 0x52495356U
20 #define RISCV_MAX_HARTS ((int)BIT(20))
21 #define RISCV_MAX_TRIGGERS 32
22 #define RISCV_MAX_HWBPS 16
23 #define RISCV_MAX_DMS 100
25 #define DEFAULT_COMMAND_TIMEOUT_SEC 5
27 #define RISCV_SATP_MODE(xlen) ((xlen) == 32 ? SATP32_MODE : SATP64_MODE)
28 #define RISCV_SATP_PPN(xlen) ((xlen) == 32 ? SATP32_PPN : SATP64_PPN)
29 #define RISCV_HGATP_MODE(xlen) ((xlen) == 32 ? HGATP32_MODE : HGATP64_MODE)
30 #define RISCV_HGATP_PPN(xlen) ((xlen) == 32 ? HGATP32_PPN : HGATP64_PPN)
31 #define RISCV_PGSHIFT 12
32 #define RISCV_PGSIZE BIT(RISCV_PGSHIFT)
33 #define RISCV_PGBASE(addr) ((addr) & ~(RISCV_PGSIZE - 1))
34 #define RISCV_PGOFFSET(addr) ((addr) & (RISCV_PGSIZE - 1))
36 #define PG_MAX_LEVEL 5
38 #define RISCV_BATCH_ALLOC_SIZE 128
102 #define RISCV_SAMPLE_BUF_TIMESTAMP_BEFORE 0x80
103 #define RISCV_SAMPLE_BUF_TIMESTAMP_AFTER 0x81
125 #define DTM_DTMCS_VERSION_UNKNOWN ((unsigned int)-1)
126 #define RISCV_TINFO_VERSION_UNKNOWN (-1)
128 #define RISCV013_DTMCS_ABITS_MIN 7
129 #define RISCV013_DTMCS_ABITS_MAX 32
390 COMMAND_HELPER(riscv_print_info_line,
const char *section,
const char *key,
394 uint8_t tunneled_dr_width;
426 #define RISCV_INFO(R) struct riscv_info *R = riscv_info(target);
455 bool handle_breakpoints
uint64_t buffer
Pointer to data buffer to send over SPI.
uint32_t size
Size of dw_spi_transaction::buffer.
uint32_t address
Starting address. Sector aligned.
static struct device_config config
The JTAG interface can be implemented with a software or hardware fifo.
struct qn908x_flash_bank __attribute__
static bool riscv_mem_access_is_valid(const struct riscv_mem_access_args args)
struct scan_field select_idcode
unsigned int riscv_xlen(const struct target *target)
struct target_type riscv011_target
uint32_t bscan_tunneled_select_dmi_num_fields
struct scan_field select_dbus
void riscv_add_bscan_tunneled_scan(struct jtag_tap *tap, const struct scan_field *field, riscv_bscan_tunneled_scan_context_t *ctxt)
static struct riscv_info * riscv_info(const struct target *target) __attribute__((unused))
static bool is_riscv(const struct riscv_info *riscv_info)
unsigned int riscv_get_dmi_address_bits(const struct target *target)
bool riscv_supports_extension(const struct target *target, char letter)
void select_dmi_via_bscan(struct jtag_tap *tap)
int riscv_read_by_any_size(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
Read one memory item using any memory access size that will work.
void riscv_semihosting_init(struct target *target)
Initialize RISC-V semihosting.
int riscv_halt(struct target *target)
@ RISCV_MEM_ACCESS_MAX_METHODS_NUM
@ RISCV_MEM_ACCESS_SYSBUS
@ RISCV_MEM_ACCESS_PROGBUF
@ RISCV_MEM_ACCESS_ABSTRACT
int riscv_write_by_any_size(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
Write one memory item using any memory access size that will work.
unsigned int riscv_vlenb(const struct target *target)
int riscv_get_hart_state(struct target *target, enum riscv_hart_state *state)
@ RISCV_STATE_UNAVAILABLE
@ RISCV_STATE_NON_EXISTENT
struct target_type riscv013_target
bool riscv_virt2phys_mode_is_hw(const struct target *target)
COMMAND_HELPER(riscv_print_info_line, const char *section, const char *key, unsigned int value)
unsigned int riscv_progbuf_size(struct target *target)
enum semihosting_result riscv_semihosting(struct target *target, int *retval)
Check for and process a semihosting request using the ARM protocol).
#define RISCV_MAX_TRIGGERS
uint8_t bscan_tunnel_ir_width
struct scan_field * bscan_tunneled_select_dmi
struct scan_field select_dtmcontrol
void riscv_fill_dmi_write(const struct target *target, uint8_t *buf, uint32_t a, uint32_t d)
int dtmcs_scan(struct jtag_tap *tap, uint32_t out, uint32_t *in_ptr)
const char * riscv_virt2phys_mode_to_str(enum riscv_virt2phys_mode mode)
int riscv_openocd_poll(struct target *target)
int riscv_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
#define RISCV_COMMON_MAGIC
uint32_t riscv_get_dmi_address(const struct target *target, uint32_t dm_address)
static bool riscv_mem_access_is_write(const struct riscv_mem_access_args args)
int riscv_write_progbuf(struct target *target, unsigned int index, riscv_insn_t insn)
riscv_insn_t riscv_read_progbuf(struct target *target, int index)
@ BSCAN_TUNNEL_NESTED_TAP
@ BSCAN_TUNNEL_DATA_REGISTER
void riscv_fill_dm_nop(const struct target *target, uint8_t *buf)
static bool riscv_mem_access_is_read(const struct riscv_mem_access_args args)
void riscv_fill_dmi_read(const struct target *target, uint8_t *buf, uint32_t a)
int riscv_execute_progbuf(struct target *target, uint32_t *cmderr)
static struct riscv_private_config * riscv_private_config(const struct target *target)
bool riscv_virt2phys_mode_is_sw(const struct target *target)
int riscv_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
int riscv_get_command_timeout_sec(void)
int riscv_enumerate_triggers(struct target *target)
Count triggers, and initialize trigger_count for each hart.
int riscv_openocd_step(struct target *target, bool current, target_addr_t address, bool handle_breakpoints)
@ RISCV_VIRT2PHYS_MODE_HW
@ RISCV_VIRT2PHYS_MODE_OFF
@ RISCV_VIRT2PHYS_MODE_SW
int(* on_step)(struct target *target)
bool(* get_impebreak)(const struct target *target)
int(* tick)(struct target *target)
int(* dmi_read)(struct target *target, uint32_t *value, uint32_t address)
struct reg_data_type_vector vector_uint8
enum target_event halted_callback_event
int(* select_target)(struct target *target)
enum riscv_virt2phys_mode virt2phys_mode
struct reg_data_type type_uint64_vector
unsigned int trigger_tinfo[RISCV_MAX_TRIGGERS]
struct reg_data_type type_uint16_vector
bool wp_allow_equality_match_trigger
struct list_head expose_custom
struct reg_data_type_vector vector_uint16
struct list_head * wp_triggers_negative_cache
int(* handle_became_unavailable)(struct target *target, enum riscv_hart_state previous_riscv_state)
int(* halt_go)(struct target *target)
struct reg_data_type type_vector
int(* handle_became_halted)(struct target *target, enum riscv_hart_state previous_riscv_state)
struct reg_data_type_union_field vector_fields[5]
unsigned int(* get_progbufsize)(const struct target *target)
int64_t trigger_unique_id[RISCV_MAX_HWBPS]
riscv_insn_t(* read_progbuf)(struct target *target, unsigned int index)
struct reg_data_type type_uint128_vector
unsigned int num_enabled_mem_access_methods
enum riscv_isrmasking_mode isrmask_mode
int(* handle_became_running)(struct target *target, enum riscv_hart_state previous_riscv_state)
unsigned int(* get_dmi_address_bits)(const struct target *target)
int(* authdata_write)(struct target *target, uint32_t value, unsigned int index)
int(* write_progbuf)(struct target *target, unsigned int index, riscv_insn_t d)
struct reg_name_table custom_register_names
int(* execute_progbuf)(struct target *target, uint32_t *cmderr)
unsigned int halt_group_repoll_count
unsigned int(* data_bits)(struct target *target)
struct list_head expose_csr
bool halted_needs_event_callback
struct reg_data_type type_uint32_vector
int(* resume_prep)(struct target *target)
int(* halt_prep)(struct target *target)
enum yes_no_maybe vsew64_supported
int(* dmi_write)(struct target *target, uint32_t address, uint32_t value)
void(* fill_dmi_write)(const struct target *target, uint8_t *buf, uint32_t a, uint32_t d)
void(* fill_dmi_read)(const struct target *target, uint8_t *buf, uint32_t a)
riscv_sample_config_t sample_config
COMMAND_HELPER((*print_info), struct target *target)
bool range_trigger_fallback_encountered
unsigned int common_magic
bool mem_access_warn[RISCV_MEM_ACCESS_MAX_METHODS_NUM]
int(* sample_memory)(struct target *target, struct riscv_sample_buf *buf, riscv_sample_config_t *config, int64_t until_ms)
int(* authdata_read)(struct target *target, uint32_t *value, unsigned int index)
int(* access_memory)(struct target *target, const struct riscv_mem_access_args args)
uint32_t(* get_dmi_address)(const struct target *target, uint32_t dm_address)
struct reg_data_type type_uint8_vector
bool wp_allow_ge_lt_trigger
int(* get_hart_state)(struct target *target, enum riscv_hart_state *state)
riscv_reg_info_t shared_reg_info
struct reg_data_type_vector vector_uint32
struct riscv_sample_buf sample_buf
struct reg_data_type_union vector_union
unsigned int trigger_count
int(* step_current_hart)(struct target *target)
struct reg_data_type_vector vector_uint64
struct command_context * cmd_ctx
void(* fill_dm_nop)(const struct target *target, uint8_t *buf)
enum riscv_halt_reason(* halt_reason)(struct target *target)
int(* invalidate_cached_progbuf)(struct target *target)
enum riscv_mem_access_method mem_access_methods[RISCV_MEM_ACCESS_MAX_METHODS_NUM]
bool wp_allow_napot_trigger
struct list_head hide_csr
struct reg_data_type_vector vector_uint128
int(* resume_go)(struct target *target)
const uint8_t * write_buffer
bool dcsr_ebreak_fields[N_RISCV_MODE]
unsigned int custom_number
This structure defines a single scan field in the scan.
This holds methods shared between all instances of a given target type.
static struct ublast_lowlevel low