|
OpenOCD
|


Go to the source code of this file.
Data Structures | |
| struct | range_list_t |
| struct | reg_name_table |
| struct | riscv_bscan_tunneled_scan_context_t |
| struct | riscv_info |
| struct | riscv_mem_access_args |
| struct | riscv_private_config |
| struct | riscv_reg_info_t |
| struct | riscv_sample_buf |
| struct | riscv_sample_config_t |
| struct | virt2phys_info_t |
Macros | |
| #define | DEFAULT_COMMAND_TIMEOUT_SEC 5 |
| #define | DTM_DTMCS_VERSION_UNKNOWN ((unsigned int)-1) |
| #define | PG_MAX_LEVEL 5 |
| #define | RISCV013_DTMCS_ABITS_MAX 32 |
| #define | RISCV013_DTMCS_ABITS_MIN 7 |
| #define | RISCV_BATCH_ALLOC_SIZE 128 |
| #define | RISCV_COMMON_MAGIC 0x52495356U |
| #define | RISCV_HGATP_MODE(xlen) ((xlen) == 32 ? HGATP32_MODE : HGATP64_MODE) |
| #define | RISCV_HGATP_PPN(xlen) ((xlen) == 32 ? HGATP32_PPN : HGATP64_PPN) |
| #define | RISCV_INFO(R) struct riscv_info *R = riscv_info(target); |
| #define | RISCV_MAX_DMS 100 |
| #define | RISCV_MAX_TRIGGERS 32 |
| #define | RISCV_PGBASE(addr) ((addr) & ~(RISCV_PGSIZE - 1)) |
| #define | RISCV_PGOFFSET(addr) ((addr) & (RISCV_PGSIZE - 1)) |
| #define | RISCV_PGSHIFT 12 |
| #define | RISCV_PGSIZE BIT(RISCV_PGSHIFT) |
| #define | RISCV_SAMPLE_BUF_TIMESTAMP_AFTER 0x81 |
| #define | RISCV_SAMPLE_BUF_TIMESTAMP_BEFORE 0x80 |
| #define | RISCV_SATP_MODE(xlen) ((xlen) == 32 ? SATP32_MODE : SATP64_MODE) |
| #define | RISCV_SATP_PPN(xlen) ((xlen) == 32 ? SATP32_PPN : SATP64_PPN) |
| #define | RISCV_TINFO_VERSION_UNKNOWN (-1) |
Typedefs | |
| typedef uint64_t | riscv_addr_t |
| typedef uint32_t | riscv_insn_t |
| typedef uint64_t | riscv_reg_t |
Functions | |
| COMMAND_HELPER (riscv_print_info_line, const char *section, const char *key, unsigned int value) | |
| int | dtmcs_scan (struct jtag_tap *tap, uint32_t out, uint32_t *in_ptr) |
| static bool | is_riscv (const struct riscv_info *riscv_info) |
| void | riscv_add_bscan_tunneled_scan (struct jtag_tap *tap, const struct scan_field *field, riscv_bscan_tunneled_scan_context_t *ctxt) |
| int | riscv_add_watchpoint (struct target *target, struct watchpoint *watchpoint) |
| int | riscv_enumerate_triggers (struct target *target) |
| Count triggers, and initialize trigger_count for each hart. More... | |
| int | riscv_execute_progbuf (struct target *target, uint32_t *cmderr) |
| void | riscv_fill_dm_nop (const struct target *target, uint8_t *buf) |
| void | riscv_fill_dmi_read (const struct target *target, uint8_t *buf, uint32_t a) |
| void | riscv_fill_dmi_write (const struct target *target, uint8_t *buf, uint32_t a, uint32_t d) |
| int | riscv_get_command_timeout_sec (void) |
| uint32_t | riscv_get_dmi_address (const struct target *target, uint32_t dm_address) |
| unsigned int | riscv_get_dmi_address_bits (const struct target *target) |
| int | riscv_get_hart_state (struct target *target, enum riscv_hart_state *state) |
| int | riscv_halt (struct target *target) |
| static struct riscv_info * | riscv_info (const struct target *target) __attribute__((unused)) |
| static bool | riscv_mem_access_is_read (const struct riscv_mem_access_args args) |
| static bool | riscv_mem_access_is_valid (const struct riscv_mem_access_args args) |
| static bool | riscv_mem_access_is_write (const struct riscv_mem_access_args args) |
| int | riscv_openocd_poll (struct target *target) |
| int | riscv_openocd_step (struct target *target, bool current, target_addr_t address, bool handle_breakpoints) |
| static riscv_reg_t | riscv_priv_mode_to_prv (enum riscv_priv_mode mode) |
| static struct riscv_private_config * | riscv_private_config (const struct target *target) |
| unsigned int | riscv_progbuf_size (struct target *target) |
| 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. More... | |
| riscv_insn_t | riscv_read_progbuf (struct target *target, int index) |
| int | riscv_remove_watchpoint (struct target *target, struct watchpoint *watchpoint) |
| enum semihosting_result | riscv_semihosting (struct target *target, int *retval) |
| Check for and process a semihosting request using the ARM protocol). More... | |
| void | riscv_semihosting_init (struct target *target) |
| Initialize RISC-V semihosting. More... | |
| bool | riscv_supports_extension (const struct target *target, char letter) |
| const char * | riscv_virt2phys_mode_to_str (enum riscv_virt2phys_mode mode) |
| unsigned int | riscv_vlenb (const struct target *target) |
| 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. More... | |
| int | riscv_write_progbuf (struct target *target, unsigned int index, riscv_insn_t insn) |
| unsigned int | riscv_xlen (const struct target *target) |
| void | select_dmi_via_bscan (struct jtag_tap *tap) |
Variables | |
| uint8_t | bscan_tunnel_ir_width |
| struct scan_field * | bscan_tunneled_select_dmi |
| uint32_t | bscan_tunneled_select_dmi_num_fields |
| struct target_type | riscv011_target |
| struct target_type | riscv013_target |
| struct scan_field | select_dbus |
| struct scan_field | select_dtmcontrol |
| struct scan_field | select_idcode |
| #define RISCV_HGATP_MODE | ( | xlen | ) | ((xlen) == 32 ? HGATP32_MODE : HGATP64_MODE) |
| #define RISCV_HGATP_PPN | ( | xlen | ) | ((xlen) == 32 ? HGATP32_PPN : HGATP64_PPN) |
| #define RISCV_INFO | ( | R | ) | struct riscv_info *R = riscv_info(target); |
| #define RISCV_PGBASE | ( | addr | ) | ((addr) & ~(RISCV_PGSIZE - 1)) |
| #define RISCV_PGOFFSET | ( | addr | ) | ((addr) & (RISCV_PGSIZE - 1)) |
| #define RISCV_PGSIZE BIT(RISCV_PGSHIFT) |
| #define RISCV_SATP_MODE | ( | xlen | ) | ((xlen) == 32 ? SATP32_MODE : SATP64_MODE) |
| #define RISCV_SATP_PPN | ( | xlen | ) | ((xlen) == 32 ? SATP32_PPN : SATP64_PPN) |
| typedef uint64_t riscv_addr_t |
| typedef uint32_t riscv_insn_t |
| typedef uint64_t riscv_reg_t |
| enum bscan_tunnel_type_t |
| enum riscv_halt_reason |
| enum riscv_hart_state |
| enum riscv_priv_mode |
| enum riscv_virt2phys_mode |
| enum yes_no_maybe |
| COMMAND_HELPER | ( | riscv_print_info_line | , |
| const char * | section, | ||
| const char * | key, | ||
| unsigned int | value | ||
| ) |
Definition at line 5562 of file riscv.c.
References CALL_COMMAND_HANDLER.
| int dtmcs_scan | ( | struct jtag_tap * | tap, |
| uint32_t | out, | ||
| uint32_t * | in_ptr | ||
| ) |
Definition at line 423 of file riscv.c.
References bscan_tunnel_ir_width, buf_get_u32(), buf_set_u32(), dtmcs_scan_via_bscan(), ERROR_OK, scan_field::in_value, jtag_add_dr_scan(), jtag_add_ir_scan(), jtag_execute_queue(), jtag_tap_name(), LOG_DEBUG, LOG_ERROR, NULL, scan_field::num_bits, select_dbus, select_dtmcontrol, and TAP_IDLE.
Referenced by examine(), increase_dbus_busy_delay(), increase_dmi_busy_delay(), and riscv_examine().
|
inlinestatic |
Definition at line 443 of file riscv.h.
References riscv_info::common_magic, and RISCV_COMMON_MAGIC.
Referenced by fespi_write().
| void riscv_add_bscan_tunneled_scan | ( | struct jtag_tap * | tap, |
| const struct scan_field * | field, | ||
| riscv_bscan_tunneled_scan_context_t * | ctxt | ||
| ) |
Definition at line 6529 of file riscv.c.
References ARRAY_SIZE, bscan_one, BSCAN_TUNNEL_DATA_REGISTER, bscan_tunnel_type, bscan_zero, scan_field::in_value, jtag_add_dr_scan(), jtag_add_ir_scan(), scan_field::num_bits, scan_field::out_value, select_user4, TAP_IDLE, riscv_bscan_tunneled_scan_context_t::tunneled_dr, and riscv_bscan_tunneled_scan_context_t::tunneled_dr_width.
Referenced by riscv_batch_run_from().
| int riscv_add_watchpoint | ( | struct target * | target, |
| struct watchpoint * | watchpoint | ||
| ) |
Definition at line 1764 of file riscv.c.
References add_trigger(), ERROR_OK, ERROR_TARGET_RESOURCE_NOT_AVAILABLE, find_first_trigger_by_id(), LOG_TARGET_ERROR, watchpoint::mask, trigger_from_watchpoint(), watchpoint::unique_id, WATCHPOINT_IGNORE_DATA_VALUE_MASK, and watchpoint_set().
Referenced by enable_watchpoints(), and strict_step().
| int riscv_enumerate_triggers | ( | struct target * | target | ) |
Count triggers, and initialize trigger_count for each hart.
trigger_count is initialized even if this function fails to discover something. Disable any hardware triggers that have dmode set. We can't have set them ourselves. Maybe they're left over from some killed debug session.
Definition at line 6444 of file riscv.c.
References ARRAY_SIZE, check_if_trigger_exists(), create_wp_trigger_cache(), CSR_TINFO_VERSION, disable_trigger_if_dmode(), ERROR_FAIL, ERROR_OK, ERROR_TARGET_NOT_HALTED, ERROR_TARGET_RESOURCE_NOT_AVAILABLE, GDB_REGNO_TDATA1, GDB_REGNO_TINFO, GDB_REGNO_TSELECT, get_field(), get_trigger_types(), LOG_TARGET_DEBUG, LOG_TARGET_ERROR, LOG_TARGET_INFO, LOG_TARGET_WARNING, NULL, RISCV_INFO, riscv_reg_get(), riscv_reg_set(), RISCV_TINFO_VERSION_UNKNOWN, target::state, and TARGET_HALTED.
Referenced by add_trigger(), COMMAND_HANDLER(), COMMAND_HELPER(), handle_halt(), remove_trigger(), and riscv_openocd_step_impl().
| int riscv_execute_progbuf | ( | struct target * | target, |
| uint32_t * | cmderr | ||
| ) |
| void riscv_fill_dm_nop | ( | const struct target * | target, |
| uint8_t * | buf | ||
| ) |
Definition at line 6353 of file riscv.c.
References RISCV_INFO.
Referenced by riscv_batch_add_dmi_read(), riscv_batch_add_dmi_write(), and riscv_batch_add_nop().
| void riscv_fill_dmi_read | ( | const struct target * | target, |
| uint8_t * | buf, | ||
| uint32_t | a | ||
| ) |
Definition at line 6347 of file riscv.c.
References RISCV_INFO.
Referenced by riscv_batch_add_dmi_read().
| void riscv_fill_dmi_write | ( | const struct target * | target, |
| uint8_t * | buf, | ||
| uint32_t | a, | ||
| uint32_t | d | ||
| ) |
Definition at line 6341 of file riscv.c.
References RISCV_INFO.
Referenced by riscv_batch_add_dmi_write().
| int riscv_get_command_timeout_sec | ( | void | ) |
Definition at line 186 of file riscv.c.
References MAX, riscv_command_timeout_sec_value, and riscv_reset_timeout_sec.
Referenced by activate_dm(), batch_run_timeout(), deassert_reset(), full_step(), read_sbcs_nonbusy(), reset_dm(), wait_for_authbusy(), wait_for_debugint_clear(), wait_for_idle(), and wait_for_state().
| uint32_t riscv_get_dmi_address | ( | const struct target * | target, |
| uint32_t | dm_address | ||
| ) |
Definition at line 4812 of file riscv.c.
References RISCV_INFO.
Referenced by COMMAND_HANDLER(), decode_dmi(), riscv_batch_add_dm_read(), riscv_batch_add_dm_write(), and riscv_dmi_write().
| unsigned int riscv_get_dmi_address_bits | ( | const struct target * | target | ) |
Definition at line 6359 of file riscv.c.
References RISCV_INFO.
Referenced by get_dmi_scan_length(), and log_batch().
| int riscv_get_hart_state | ( | struct target * | target, |
| enum riscv_hart_state * | state | ||
| ) |
Definition at line 6300 of file riscv.c.
References RISCV_INFO, and state.
Referenced by examine(), riscv_halt_go_all_harts(), and riscv_poll_hart().
| int riscv_halt | ( | struct target * | target | ) |
Definition at line 2748 of file riscv.c.
References ERROR_FAIL, ERROR_OK, foreach_smp_target, get_target_type(), target_type::halt, halt_finish(), halt_go(), halt_prep(), LOG_TARGET_DEBUG, riscv_info::prepped, riscv_info(), RISCV_INFO, target::smp, target::smp_targets, and target_list::target.
Referenced by riscv013_step_or_resume_current_hart(), riscv_openocd_poll(), and riscv_run_algorithm().
|
inlinestatic |
Definition at line 436 of file riscv.h.
References target::arch_info.
Referenced by COMMAND_HANDLER(), examine(), fespi_write(), riscv_halt(), riscv_openocd_poll(), riscv_resume(), riscv_rw_memory(), riscv_virt2phys_mode_is_off(), and select_prepped_harts().
|
inlinestatic |
Definition at line 163 of file riscv.h.
References riscv_mem_access_args::read_buffer, riscv_mem_access_is_valid(), and riscv_mem_access_args::write_buffer.
Referenced by read_memory(), read_memory_bus_v0(), read_memory_bus_v1(), read_memory_progbuf_inner_ensure_forward_progress(), read_memory_progbuf_inner_extract_batch_data(), read_memory_progbuf_inner_on_ac_busy(), read_memory_progbuf_inner_on_dmi_busy(), read_memory_progbuf_inner_run_and_process_batch(), read_memory_progbuf_inner_try_to_read(), riscv013_access_memory(), and set_buffer_and_log_read().
|
inlinestatic |
Definition at line 157 of file riscv.h.
References riscv_mem_access_args::read_buffer, and riscv_mem_access_args::write_buffer.
Referenced by access_memory(), riscv013_access_memory(), riscv_mem_access_is_read(), riscv_mem_access_is_write(), and riscv_rw_memory().
|
inlinestatic |
Definition at line 170 of file riscv.h.
References riscv_mem_access_args::read_buffer, riscv_mem_access_is_valid(), and riscv_mem_access_args::write_buffer.
Referenced by access_memory(), riscv_rw_memory(), write_memory(), write_memory_bus_v0(), and write_memory_bus_v1().
| int riscv_openocd_poll | ( | struct target * | target | ) |
Definition at line 4149 of file riscv.c.
References alive_sleep(), CSR_DCSR_CAUSE, CSR_DCSR_CAUSE_GROUP, ERROR_FAIL, ERROR_OK, foreach_smp_target, GDB_REGNO_DCSR, get_field(), riscv_info::halt_group_repoll_count, halted(), info, target_list::lh, list_add(), LOG_TARGET_DEBUG, LOG_TARGET_DEBUG_IO, LOG_TARGET_WARNING, NULL, OOCD_LIST_HEAD, riscv_halt(), RISCV_HALT_GROUP_REPOLL_LIMIT, riscv_info(), riscv_poll_hart(), riscv_reg_get(), riscv_resume(), RPH_NONE, RPH_REMAIN_HALTED, RPH_RESUME, sample_memory(), target::smp, target::smp_targets, target::state, target_list::target, target_call_event_callbacks(), TARGET_DEBUG_RUNNING, TARGET_HALTED, TARGET_RUNNING, and target_was_examined().
Referenced by derive_debug_reason_without_hitbit().
| int riscv_openocd_step | ( | struct target * | target, |
| bool | current, | ||
| target_addr_t | address, | ||
| bool | handle_breakpoints | ||
| ) |
Definition at line 4420 of file riscv.c.
References address, and riscv_openocd_step_impl().
|
inlinestatic |
Definition at line 379 of file riscv.h.
References mode, PRV_M, PRV_S, PRV_U, RISCV_MODE_M, RISCV_MODE_S, RISCV_MODE_U, RISCV_MODE_VS, and RISCV_MODE_VU.
Referenced by set_mpp_mpv().
|
inlinestatic |
Definition at line 402 of file riscv.h.
References target::private_config.
Referenced by COMMAND_HELPER(), dcsr_config_equals_reset_value(), set_dcsr_config(), and set_ebreakx_fields().
| unsigned int riscv_progbuf_size | ( | struct target * | target | ) |
Definition at line 6317 of file riscv.c.
References RISCV_INFO.
Referenced by COMMAND_HANDLER(), riscv_program_ebreak(), riscv_program_exec(), and riscv_program_insert().
| 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.
Read larger section of memory and pick out the required portion, if needed.
Definition at line 1608 of file riscv.c.
References address, buffer, ERROR_FAIL, ERROR_OK, read_by_given_size(), and size.
Referenced by riscv_add_breakpoint(), and riscv_semihosting_detect_magic_sequence().
| riscv_insn_t riscv_read_progbuf | ( | struct target * | target, |
| int | index | ||
| ) |
Definition at line 6329 of file riscv.c.
References RISCV_INFO.
| int riscv_remove_watchpoint | ( | struct target * | target, |
| struct watchpoint * | watchpoint | ||
| ) |
Definition at line 1784 of file riscv.c.
Referenced by disable_watchpoints(), and strict_step().
| enum semihosting_result riscv_semihosting | ( | struct target * | target, |
| int * | retval | ||
| ) |
Check for and process a semihosting request using the ARM protocol).
This is meant to be called when the target is stopped due to a debug mode entry.
| target | Pointer to the target to process. |
| retval | Pointer to a location where the return code will be stored |
Definition at line 94 of file riscv_semihosting.c.
References riscv_semihosting_post_result(), riscv_semihosting_setup(), and semihosting_common_init().
Referenced by handle_halt(), and riscv_poll_hart().
| void riscv_semihosting_init | ( | struct target * | target | ) |
Initialize RISC-V semihosting.
Use common ARM code.
Definition at line 94 of file riscv_semihosting.c.
Referenced by riscv_init_target().
| bool riscv_supports_extension | ( | const struct target * | target, |
| char | letter | ||
| ) |
Definition at line 6275 of file riscv.c.
References BIT, and RISCV_INFO.
Referenced by examine_vlenb(), fpr_read_progbuf(), fpr_write_progbuf(), gdb_regno_reg_data_type(), gdb_regno_size(), riscv013_reg_get(), riscv013_reg_set(), riscv_effective_privilege_mode(), riscv_reg_impl_gdb_regno_exist(), set_mpp_mpv(), and verify_loadstore().
| const char* riscv_virt2phys_mode_to_str | ( | enum riscv_virt2phys_mode | mode | ) |
Definition at line 165 of file riscv.c.
References mode, RISCV_VIRT2PHYS_MODE_HW, RISCV_VIRT2PHYS_MODE_OFF, and RISCV_VIRT2PHYS_MODE_SW.
Referenced by COMMAND_HANDLER().
| unsigned int riscv_vlenb | ( | const struct target * | target | ) |
Definition at line 6294 of file riscv.c.
References RISCV_INFO.
Referenced by gdb_regno_size(), riscv_reg_impl_init_vector_reg_type(), and vlenb_exists().
| 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.
Utilize read-modify-write, if needed.
Definition at line 1576 of file riscv.c.
References address, buffer, ERROR_FAIL, ERROR_OK, size, and write_by_given_size().
Referenced by riscv_add_breakpoint(), and riscv_remove_breakpoint().
| int riscv_write_progbuf | ( | struct target * | target, |
| unsigned int | index, | ||
| riscv_insn_t | insn | ||
| ) |
Definition at line 6323 of file riscv.c.
References RISCV_INFO.
Referenced by riscv_program_write().
| unsigned int riscv_xlen | ( | const struct target * | target | ) |
Definition at line 6288 of file riscv.c.
References RISCV_INFO.
Referenced by cache_get(), cache_set(), check_if_trigger_exists(), check_misa_mxl(), COMMAND_HANDLER(), disable_trigger_if_dmode(), examine(), execute_resume(), fespi_write(), fill_match_triggers_tdata1_fields_t2(), fpr_read_progbuf(), fpr_write_progbuf(), gdb_regno_size(), get_loadstore_memoffset(), get_trigger_types(), handle_halt_routine(), hpm_xpi_erase(), hpm_xpi_erase_chip(), hpm_xpi_probe(), hpm_xpi_run_algo_flash_init(), hpm_xpi_write(), load(), maybe_add_trigger_t3(), maybe_add_trigger_t4(), maybe_add_trigger_t5(), read_memory_progbuf_inner_extract_batch_data(), read_memory_progbuf_inner_startup(), register_size(), register_write(), riscv011_get_register(), riscv013_data_bits(), riscv_address_translate(), riscv_checksum_memory(), riscv_data_bits(), riscv_effective_privilege_mode(), riscv_get_gdb_arch(), riscv_insn_set(), riscv_mmu_impl(), riscv_reg_impl_gdb_regno_exist(), riscv_trigger_detect_hit_bits(), riscv_virt2phys(), riscv_virt2phys_v(), riscv_xlen_nonconst(), scans_add_read(), scans_new(), scratch_reserve(), set_mpp_mpv(), set_trigger(), slot_offset(), step(), store(), try_set_vsew(), try_setup_single_match_trigger(), verify_loadstore(), and write_memory_progbuf_startup().
| void select_dmi_via_bscan | ( | struct jtag_tap * | tap | ) |
Definition at line 326 of file riscv.c.
References BSCAN_TUNNEL_DATA_REGISTER, bscan_tunnel_data_register_select_dmi, bscan_tunnel_data_register_select_dmi_num_fields, bscan_tunnel_nested_tap_select_dmi, bscan_tunnel_nested_tap_select_dmi_num_fields, bscan_tunnel_type, jtag_add_dr_scan(), jtag_add_ir_scan(), select_user4, and TAP_IDLE.
Referenced by dtmcs_scan_via_bscan(), and select_dmi().
|
extern |
Definition at line 61 of file riscv.c.
Referenced by COMMAND_HANDLER(), dtmcs_scan(), dtmcs_scan_via_bscan(), riscv_batch_alloc(), riscv_batch_run_from(), riscv_init_target(), and select_dmi().
|
extern |
|
extern |
|
extern |
Definition at line 2437 of file riscv-011.c.
Referenced by get_target_type().
|
extern |
Definition at line 5184 of file riscv-013.c.
Referenced by get_target_type().
|
extern |
Definition at line 48 of file riscv.c.
Referenced by assert_reset(), deassert_reset(), dtmcs_scan(), halt(), idcode_scan(), poll_target(), read_memory(), riscv011_resume(), riscv_init_target(), select_dmi(), step(), and write_memory().
|
extern |
Definition at line 43 of file riscv.c.
Referenced by dtmcs_scan(), and riscv_init_target().
|
extern |
Definition at line 53 of file riscv.c.
Referenced by idcode_scan(), and riscv_init_target().