26 #define RESET_TIMEOUT 5000
27 #define STEP_TIMEOUT 1000
133 static const struct {
183 static int esirisc_enable_interrupts(
struct target *
target)
362 int num_bits = 8 *
size;
363 for (uint32_t i = 0; i <
count; ++i) {
368 case sizeof(value.
word):
369 value_p = &value.
word;
373 case sizeof(value.
hword):
374 value_p = &value.
hword;
378 case sizeof(value.
byte):
379 value_p = &value.
byte;
411 int num_bits = 8 *
size;
412 for (uint32_t i = 0; i <
count; ++i) {
416 case sizeof(value.
word):
421 case sizeof(value.
hword):
426 case sizeof(value.
byte):
450 uint32_t
count, uint32_t *checksum)
463 for (
int bp_index = 0; breakpoints_p < breakpoints_e; ++breakpoints_p, ++bp_index)
514 ibc |= (1 << bp_index);
558 ibc &= ~(1 << bp_index);
599 for (
int wp_index = 0; watchpoints_p < watchpoints_e; ++watchpoints_p, ++wp_index)
642 case sizeof(uint64_t):
645 case sizeof(uint32_t):
649 case sizeof(uint16_t):
653 case sizeof(uint8_t):
663 dbs |= (sn << (2 * wp_index));
698 dbc |= (dn << (2 * wp_index));
742 dbc &= ~(0x3 << (2 * wp_index));
849 int handle_breakpoints,
int debug_execution,
bool step)
861 if (!debug_execution) {
880 if (handle_breakpoints) {
906 if (!debug_execution) {
918 int handle_breakpoints,
int debug_execution)
923 handle_breakpoints, debug_execution,
false);
927 int handle_breakpoints)
932 handle_breakpoints, 0,
true);
1240 LOG_USER(
"target halted due to %s, exception: %s\n"
1241 "EPC: 0x%" PRIx32
", ECAS: 0x%" PRIx32
", EID: 0x%" PRIx32
", ED: 0x%" PRIx32,
1275 *reg_list = calloc(*reg_list_size,
sizeof(
struct reg *));
1280 for (
int i = 0; i < *reg_list_size; ++i)
1283 for (
int i = 0; i < esirisc->
num_regs; ++i)
1430 cache->
name =
"eSi-RISC registers";
1442 for (
int i = 0; i < esirisc->
num_regs; ++i) {
1662 if (strcmp(*
CMD_ARGV,
"harvard") == 0)
1664 else if (strcmp(*
CMD_ARGV,
"von_neumann") == 0)
1684 LOG_ERROR(
"target does not support caching");
1691 (retval ==
ERROR_OK) ?
"successful" :
"failed");
1696 static const struct {
1722 if (strcmp(
CMD_ARGV[0],
"all") == 0)
1726 if (strcmp(
CMD_ARGV[0],
"none") != 0) {
1748 .
name =
"flush_caches",
1749 .handler = handle_esirisc_flush_caches_command,
1751 .help =
"flush instruction and data caches",
1759 .
name =
"cache_arch",
1760 .handler = handle_esirisc_cache_arch_command,
1762 .help =
"configure cache architecture",
1763 .usage =
"['harvard'|'von_neumann']",
1767 .handler = handle_esirisc_hwdc_command,
1769 .help =
"configure hardware debug control",
1770 .usage =
"['all'|'none'|mask ...]",
1785 .help =
"eSi-RISC command group",
void * buf_cpy(const void *from, void *_to, unsigned 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 first, unsigned 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 first, unsigned 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 const struct @91 esirisc_hwdc_masks[]
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 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 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)
enum esirisc_reg_num number
static int esirisc_next_breakpoint(struct target *target)
static int esirisc_write_reg(struct reg *reg)
static const char * esirisc_get_gdb_arch(struct target *target)
static int esirisc_flush_caches(struct target *target)
static const struct @89 esirisc_regs[]
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 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 int esirisc_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
static const struct @90 esirisc_csrs[]
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
#define EID_DATA_BREAKPOINT
#define EID_INST_BREAKPOINT
static struct esirisc_common * target_to_esirisc(struct target *target)
#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_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
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)
struct target * get_current_target(struct command_context *cmd_ctx)
const char * debug_reason_name(struct target *t)
#define ERROR_TARGET_NOT_HALTED
@ TARGET_EVENT_DEBUG_RESUMED
static const char * target_name(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.
static bool target_was_examined(struct target *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.