176 uint32_t pc, lr, spsr;
188 uint32_t vbar = 0x00000000;
214 if (pc != (vbar + 0x00000008) && pc != 0xffff0008)
232 if (spsr & (1 << 5)) {
245 }
else if (spsr & (1 << 24)) {
259 if (insn != 0xEF123456)
303 if (insn != 0xD45E0000)
318 if (insn != 0xE10F0070)
337 LOG_ERROR(
"Unsupported semi-hosting Target");
364 LOG_ERROR(
"Failed semihosting operation (0x%02X)",
static struct arm7_9_common * target_to_arm7_9(struct target *target)
static bool is_arm7_9(struct arm7_9_common *arm7_9)
Holds the interface to ARM cores.
struct reg * arm_reg_current(struct arm *arm, unsigned int regnum)
Returns handle to the register currently mapped to a given number.
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
Macros used to generate various ARM or Thumb opcodes.
#define ARMV4_5_MRC(cp, op1, rd, crn, crm, op2)
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.
static int post_result(struct target *target)
static int arm_semihosting_resume(struct target *target, int *retval)
static struct armv7a_common * target_to_armv7a(struct target *target)
static bool is_armv7a(struct armv7a_common *armv7a)
static struct armv7m_common * target_to_armv7m(struct target *target)
static bool is_armv7m(const struct armv7m_common *armv7m)
static struct armv8_common * target_to_armv8(struct target *target)
@ ARMV8_RUNCONTROL_RESUME
static bool is_armv8(struct armv8_common *armv8)
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.
static uint64_t buf_get_u64(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 64-bit word.
static void buf_set_u64(uint8_t *_buffer, unsigned int first, unsigned int num, uint64_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
#define LOG_ERROR(expr ...)
int semihosting_common_init(struct target *target, void *setup, void *post_result)
Initialize common semihosting support.
int semihosting_common(struct target *target)
Portable implementation of ARM semihosting calls.
This wraps an implementation of DPM primitives.
int(* finish)(struct arm_dpm *dpm)
Invoke after a series of instruction operations.
int(* prepare)(struct arm_dpm *dpm)
Invoke before a series of instruction operations.
int(* instr_read_data_r0)(struct arm_dpm *dpm, uint32_t opcode, uint32_t *data)
Runs one instruction, reading data from r0 after execution.
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.
int(* setup_semihosting)(struct target *target, int enable)
struct reg_cache * core_cache
struct arm_dpm * dpm
Handle for the debug module, if one is present.
struct reg * spsr
Handle to the SPSR; valid only in core modes with an SPSR.
enum arm_state core_state
Record the current core state: ARM, Thumb, or otherwise.
enum run_control_op last_run_control_op
bool is_resumable
Most are resumable, except the two exit calls.
bool hit_fileio
A flag reporting whether semihosting fileio operation is active.
size_t word_size_bytes
The Target (hart) word size; 8 for 64-bits targets.
int64_t result
The current semihosting result to be returned to the application.
bool is_active
A flag reporting whether semihosting is active.
int op
The current semihosting operation (R0 on ARM).
uint64_t param
The current semihosting parameter (R1 or ARM).
struct semihosting * semihosting
enum target_debug_reason debug_reason
int target_read_u16(struct target *target, target_addr_t address, uint16_t *value)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer)
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
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...