34 #define SAVED_DCRDR dbgbase
36 #define ARMV7M_SCS_DCRSR DCB_DCRSR
37 #define ARMV7M_SCS_DCRDR DCB_DCRDR
45 uint32_t regsel, uint32_t *value)
48 return adapter->layout->api->read_reg(
adapter->handle, regsel, value);
52 uint32_t regsel, uint32_t value)
55 return adapter->layout->api->write_reg(
adapter->handle, regsel, value);
72 DCB_DCRDR, 1,
sizeof(dcrdr), (uint8_t *)&dcrdr);
74 *
ctrl = (uint8_t)dcrdr;
75 *value = (uint8_t)(dcrdr >> 8);
83 static const uint8_t
zero;
98 for (i = 0; i < (
size * 4); i++) {
130 if (
ctrl & (1 << 0)) {
139 request |= (data << 8);
144 request |= (data << 16);
149 request |= (data << 24);
165 armv7m = &cortex_m->
armv7m;
196 LOG_ERROR(
"hla_target: invalid parameter -ap-num (> 0)");
218 for (
int i = 0; i < num_regs; i++) {
278 LOG_DEBUG(
"entered debug state in core mode: %s at PC 0x%08" PRIx32
", target->state: %s",
296 LOG_ERROR(
"jtag status contains invalid mode value - communication failure");
300 if (prev_target_state ==
state)
334 bool use_srst_fallback =
true;
368 LOG_ERROR(
"Hardware srst not supported, falling back to software reset");
371 use_srst_fallback =
false;
375 if (use_srst_fallback) {
425 LOG_WARNING(
"target was in unknown state when halt was requested");
449 address, handle_breakpoints, debug_execution);
456 if (!debug_execution) {
470 && !debug_execution) {
492 if (handle_breakpoints) {
517 if (!debug_execution) {
536 bool bkpt_inst_found =
false;
554 if (handle_breakpoints) {
641 .
name =
"hla_target",
const char * arm_get_gdb_arch(const struct target *target)
const struct command_registration arm_command_handlers[]
const char * arm_mode_name(unsigned int psr_mode)
Map PSR mode bits to the name of an ARM processor operating mode.
int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
This defines formats and data structures used to talk to ADIv5 entities.
int arm_semihosting(struct target *target, int *retval)
Checks for and processes an ARM semihosting request.
int arm_semihosting_init(struct target *target)
Initialize ARM semihosting support.
const struct command_registration arm_tpiu_deprecated_command_handlers[]
int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Returns generic ARM userspace registers to GDB.
int armv7m_maybe_skip_bkpt_inst(struct target *target, bool *inst_found)
const int armv7m_psp_reg_map[ARMV7M_NUM_CORE_REGS]
struct reg_cache * armv7m_build_reg_cache(struct target *target)
Builds cache of architecturally defined registers.
const int armv7m_msp_reg_map[ARMV7M_NUM_CORE_REGS]
int armv7m_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Runs a Thumb algorithm in the target.
int armv7m_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
Generates a CRC32 checksum of a memory region.
int armv7m_wait_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Waits for an algorithm in the target.
int armv7m_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
Checks an array of memory regions whether they are erased.
int armv7m_arch_state(struct target *target)
Logs summary of ARMv7-M state for a halted target.
int armv7m_restore_context(struct target *target)
Restores target context using the cache of core registers set up by armv7m_build_reg_cache(),...
int armv7m_start_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, void *arch_info)
Starts a Thumb algorithm in the target.
int armv7m_init_arch_info(struct target *target, struct armv7m_common *armv7m)
Sets up target as a generic ARMv7-M core.
static struct armv7m_common * target_to_armv7m(struct target *target)
const struct command_registration armv7m_trace_command_handlers[]
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)
#define ERROR_COMMAND_SYNTAX_ERROR
#define ERROR_COMMAND_NOTFOUND
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
void cortex_m_enable_watchpoints(struct target *target)
int cortex_m_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
void cortex_m_enable_breakpoints(struct target *target)
int cortex_m_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
int cortex_m_examine(struct target *target)
int cortex_m_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
int cortex_m_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
int cortex_m_set_breakpoint(struct target *target, struct breakpoint *breakpoint)
void cortex_m_deinit_target(struct target *target)
int cortex_m_unset_breakpoint(struct target *target, struct breakpoint *breakpoint)
int cortex_m_profiling(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
#define CORTEX_M_COMMON_MAGIC
#define AIRCR_SYSRESETREQ
static struct esp_usb_jtag * priv
static struct libusb_device_handle * adapter
static struct hl_interface hl_if
static int hl_target_request_data(struct target *target, uint32_t size, uint8_t *buffer)
static int adapter_poll(struct target *target)
static int adapter_init_target(struct command_context *cmd_ctx, struct target *target)
static struct hl_interface * target_to_adapter(struct target *target)
static int adapter_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
static int adapter_examine_debug_reason(struct target *target)
static int adapter_init_arch_info(struct target *target, struct cortex_m_common *cortex_m, struct jtag_tap *tap)
static int adapter_halt(struct target *target)
static int hl_dcc_read(struct hl_interface *hl_if, uint8_t *value, uint8_t *ctrl)
static int adapter_store_core_reg_u32(struct target *target, uint32_t regsel, uint32_t value)
static int hl_assert_reset(struct target *target)
static const struct command_registration hla_command_handlers[]
static int hl_deassert_reset(struct target *target)
static int adapter_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
static int adapter_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
static int adapter_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
static int adapter_target_create(struct target *target, Jim_Interp *interp)
static int adapter_load_core_reg_u32(struct target *target, uint32_t regsel, uint32_t *value)
struct target_type hla_target
static int hl_handle_target_request(void *priv)
static int adapter_load_context(struct target *target)
static int adapter_debug_entry(struct target *target)
static enum reset_types jtag_reset_config
int adapter_deassert_reset(void)
enum reset_types jtag_get_reset_config(void)
int adapter_assert_reset(void)
The JTAG interface can be implemented with a software or hardware fifo.
#define LOG_WARNING(expr ...)
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_TARGET_DEBUG(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
void register_cache_invalidate(struct reg_cache *cache)
Marks the contents of the register cache as invalid (and clean).
struct rtt_control ctrl
Control block.
size_t size
Size of the control block search area.
const struct command_registration rtt_target_command_handlers[]
Represents a generic ARM core, with standard application registers.
enum arm_mode core_mode
Record the current core mode: SVC, USR, or some other mode.
struct reg * cpsr
Handle to the CPSR/xPSR; valid in all core modes.
struct reg * pc
Handle to the PC; valid in all core modes.
const int * map
Support for arm_reg_current()
int(* read_core_reg)(struct target *target, struct reg *reg, int num, enum arm_mode mode)
Retrieve a single core register.
struct reg_cache * core_cache
int(* store_core_reg_u32)(struct target *target, uint32_t regsel, uint32_t value)
int(* load_core_reg_u32)(struct target *target, uint32_t regsel, uint32_t *value)
int(* examine_debug_reason)(struct target *target)
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 armv7m_common armv7m
unsigned int common_magic
const struct hl_layout * layout
int(* write_mem)(void *handle, uint32_t addr, uint32_t size, uint32_t count, const uint8_t *buffer)
int(* read_mem)(void *handle, uint32_t addr, uint32_t size, uint32_t count, uint8_t *buffer)
struct hl_layout_api * api
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
bool defer_examine
Should we defer examine to later.
int target_call_event_callbacks(struct target *target, enum target_event event)
void target_free_all_working_areas(struct target *target)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_examine_one(struct target *target)
Examine the specified target, letting it perform any Initialisation that requires JTAG access.
const char * target_state_name(const struct target *t)
Return the name of this targets current state.
int target_register_timer_callback(int(*callback)(void *priv), unsigned int time_ms, enum target_timer_type type, void *priv)
The period is very approximate, the callback can happen much more often or much more rarely than spec...
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
int target_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
Make the target (re)start executing using its saved execution context (possibly with some modificatio...
#define ERROR_TARGET_NOT_HALTED
static bool target_was_examined(const struct target *target)
@ TARGET_TIMER_TYPE_PERIODIC
@ TARGET_EVENT_DEBUG_RESUMED
@ TARGET_EVENT_DEBUG_HALTED
#define ERROR_TARGET_FAILURE
int target_request(struct target *target, uint32_t request)