26 #define RESET_TIMEOUT 5000
27 #define STEP_TIMEOUT 1000
133 static const struct {
183 static int esirisc_enable_interrupts(
struct target *
target)
364 int num_bits = 8 *
size;
365 for (uint32_t i = 0; i <
count; ++i) {
370 case sizeof(value.
word):
371 value_p = &value.
word;
375 case sizeof(value.
hword):
376 value_p = &value.
hword;
380 case sizeof(value.
byte):
381 value_p = &value.
byte;
413 int num_bits = 8 *
size;
414 for (uint32_t i = 0; i <
count; ++i) {
418 case sizeof(value.
word):
423 case sizeof(value.
hword):
428 case sizeof(value.
byte):
452 uint32_t
count, uint32_t *checksum)
465 for (
int bp_index = 0; breakpoints_p < breakpoints_e; ++breakpoints_p, ++bp_index)
516 ibc |= (1 << bp_index);
560 ibc &= ~(1 << bp_index);
601 for (
int wp_index = 0; watchpoints_p < watchpoints_e; ++watchpoints_p, ++wp_index)
644 case sizeof(uint64_t):
647 case sizeof(uint32_t):
651 case sizeof(uint16_t):
655 case sizeof(uint8_t):
665 dbs |= (sn << (2 * wp_index));
700 dbc |= (dn << (2 * wp_index));
744 dbc &= ~(0x3 << (2 * wp_index));
851 int handle_breakpoints,
int debug_execution,
bool step)
865 if (!debug_execution) {
884 if (handle_breakpoints) {
910 if (!debug_execution) {
922 int handle_breakpoints,
int debug_execution)
927 handle_breakpoints, debug_execution,
false);
931 int handle_breakpoints)
936 handle_breakpoints, 0,
true);
1244 LOG_USER(
"target halted due to %s, exception: %s\n"
1245 "EPC: 0x%" PRIx32
", ECAS: 0x%" PRIx32
", EID: 0x%" PRIx32
", ED: 0x%" PRIx32,
1279 *reg_list = calloc(*reg_list_size,
sizeof(
struct reg *));
1284 for (
int i = 0; i < *reg_list_size; ++i)
1287 for (
int i = 0; i < esirisc->
num_regs; ++i)
1434 cache->
name =
"eSi-RISC registers";
1446 for (
int i = 0; i < esirisc->
num_regs; ++i) {
1495 for (
int i = 0; i < esirisc->
num_regs; ++i) {
1705 if (strcmp(*
CMD_ARGV,
"harvard") == 0)
1707 else if (strcmp(*
CMD_ARGV,
"von_neumann") == 0)
1727 LOG_ERROR(
"target does not support caching");
1734 (retval ==
ERROR_OK) ?
"successful" :
"failed");
1739 static const struct {
1765 if (strcmp(
CMD_ARGV[0],
"all") == 0)
1769 if (strcmp(
CMD_ARGV[0],
"none") != 0) {
1791 .
name =
"flush_caches",
1792 .handler = handle_esirisc_flush_caches_command,
1794 .help =
"flush instruction and data caches",
1802 .
name =
"cache_arch",
1803 .handler = handle_esirisc_cache_arch_command,
1805 .help =
"configure cache architecture",
1806 .usage =
"['harvard'|'von_neumann']",
1810 .handler = handle_esirisc_hwdc_command,
1812 .help =
"configure hardware debug control",
1813 .usage =
"['all'|'none'|mask ...]",
1828 .help =
"eSi-RISC command group",
void * buf_cpy(const void *from, void *_to, unsigned int size)
Copies size bits out of from and into to.
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
struct breakpoint * breakpoint_find(struct target *target, target_addr_t address)
static void watchpoint_set(struct watchpoint *watchpoint, unsigned int number)
static void breakpoint_hw_set(struct breakpoint *breakpoint, unsigned int hw_number)
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static int esirisc_identify(struct target *target)
static int esirisc_set_reg(struct reg *reg, uint8_t *buf)
static int esirisc_disable_step(struct target *target)
static int esirisc_examine(struct target *target)
COMMAND_HANDLER(handle_esirisc_cache_arch_command)
static int esirisc_poll(struct target *target)
static const char *const esirisc_exception_strings[]
static int esirisc_enable_step(struct target *target)
static int esirisc_wait_debug_active(struct esirisc_common *esirisc, int ms)
struct target_type esirisc_target
static const char * esirisc_get_gdb_arch(const struct target *target)
static const struct reg_arch_type esirisc_reg_type
static int esirisc_disable_interrupts(struct target *target)
static int esirisc_restore_hwdc(struct target *target)
static int esirisc_find_hwdc_mask(const char *name)
static const struct command_registration esirisc_any_command_handlers[]
static int esirisc_read_csr(struct reg *reg)
static void esirisc_free_reg_cache(struct target *target)
static int esirisc_next_watchpoint(struct target *target)
static int esirisc_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
static int esirisc_init_target(struct command_context *cmd_ctx, struct target *target)
static void esirisc_deinit_target(struct target *target)
enum esirisc_reg_num number
static int esirisc_next_breakpoint(struct target *target)
static int esirisc_write_reg(struct reg *reg)
static int esirisc_flush_caches(struct target *target)
static int esirisc_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
static int esirisc_read_reg(struct reg *reg)
static int esirisc_save_interrupts(struct target *target)
static int esirisc_add_watchpoints(struct target *target)
static int esirisc_deassert_reset(struct target *target)
static int esirisc_get_reg(struct reg *reg)
static int esirisc_debug_reset(struct target *target)
static int esirisc_target_create(struct target *target, Jim_Interp *interp)
static int esirisc_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
static int esirisc_reset_entry(struct target *target)
static int esirisc_write_csr(struct reg *reg)
static int esirisc_save_context(struct target *target)
static int esirisc_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
static int esirisc_halt(struct target *target)
static const struct @95 esirisc_hwdc_masks[]
static const struct @94 esirisc_csrs[]
static int esirisc_add_breakpoints(struct target *target)
static int esirisc_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
static int esirisc_arch_state(struct target *target)
static int esirisc_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
static int esirisc_assert_reset(struct target *target)
static int esirisc_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
static const struct @93 esirisc_regs[]
static int esirisc_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
static const struct command_registration esirisc_exec_command_handlers[]
static int esirisc_restore_interrupts(struct target *target)
static const struct command_registration esirisc_command_handlers[]
static int esirisc_resume_or_step(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution, bool step)
static int esirisc_remove_watchpoints(struct target *target)
static int esirisc_debug_enable(struct target *target)
static int esirisc_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
static int esirisc_debug_step(struct target *target)
static int esirisc_restore_context(struct target *target)
static int esirisc_debug_entry(struct target *target)
static int esirisc_remove_breakpoints(struct target *target)
static struct reg_cache * esirisc_build_reg_cache(struct target *target)
static int esirisc_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
#define EID_INST_BUS_ERROR
#define EID_ARITHMETIC_ERROR
#define EID_UNRECOVERABLE
static struct esirisc_common * target_to_esirisc(const struct target *target)
#define EID_DATA_BREAKPOINT
#define EID_INST_BREAKPOINT
#define EID_HARDWARE_FAILURE
static char * esirisc_cache_arch_name(struct esirisc_common *esirisc)
#define EID_DATA_BUS_ERROR
#define EID_PRIVILEGE_VIOLATION
#define EID_ALIGNMENT_ERROR
@ ESIRISC_CACHE_VON_NEUMANN
#define EID_MEMORY_MANAGEMENT
static bool esirisc_has_cache(struct esirisc_common *esirisc)
int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t *data)
int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info)
int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t *data)
int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t *data)
int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t data)
int esirisc_jtag_continue(struct esirisc_jtag *jtag_info)
int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info)
bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info)
int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t data)
int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t *data)
bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info)
int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info)
int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t data)
int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t data)
int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info)
int esirisc_jtag_break(struct esirisc_jtag *jtag_info)
const struct command_registration esirisc_trace_command_handlers[]
void jtag_add_reset(int req_tlr_or_trst, int req_srst)
A reset of the TAP state machine can be requested.
enum reset_types jtag_get_reset_config(void)
void alive_sleep(uint64_t ms)
char * alloc_printf(const char *format,...)
#define LOG_USER(expr ...)
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
struct reg_cache ** register_get_last_cache_p(struct reg_cache **first)
void register_cache_invalidate(struct reg_cache *cache)
Marks the contents of the register cache as invalid (and clean).
static int step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
size_t size
Size of the control block search area.
enum breakpoint_type type
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
struct watchpoint * watchpoints_p[MAX_WATCHPOINTS]
struct breakpoint * breakpoints_p[MAX_BREAKPOINTS]
struct reg_cache * reg_cache
struct esirisc_jtag jtag_info
enum esirisc_cache cache_arch
int(* write)(struct reg *reg)
int(* read)(struct reg *reg)
struct esirisc_common * esirisc
unsigned int ir_length
size of instruction register
int(* get)(struct reg *reg)
struct reg_data_type * reg_data_type
const struct reg_arch_type * type
This holds methods shared between all instances of a given target type.
const char * name
Name of this type of target.
enum target_debug_reason debug_reason
enum target_endianness endianness
struct reg_cache * reg_cache
struct breakpoint * breakpoints
struct watchpoint * watchpoints
int target_call_event_callbacks(struct target *target, enum target_event event)
void target_free_all_working_areas(struct target *target)
const char * debug_reason_name(const struct target *t)
struct target * get_current_target(struct command_context *cmd_ctx)
#define ERROR_TARGET_NOT_HALTED
static bool target_was_examined(const struct target *target)
@ TARGET_EVENT_DEBUG_RESUMED
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
#define ERROR_TARGET_TIMEOUT
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static void target_set_examined(struct target *target)
Sets the examined flag for the given target.
#define ERROR_TARGET_FAILURE
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.