35 #define _DEBUG_INSTRUCTION_EXECUTION_
73 uint8_t instructionbus[4];
109 if (debug_reason & 0x4)
110 if (debug_reason & 0x2)
125 uint32_t out, uint32_t *in,
int sysspeed)
130 uint8_t instr_buf[4];
131 uint8_t sysspeed_buf = 0x0;
171 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
178 LOG_DEBUG(
"instr: 0x%8.8x, out: 0x%8.8x, in: 0x%8.8x", instr, out, *in);
180 LOG_DEBUG(
"instr: 0x%8.8x, out: 0x%8.8x", instr, out);
219 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
228 LOG_ERROR(
"BUG: called with in == NULL");
240 void *in,
int size,
int be)
283 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
290 LOG_DEBUG(
"in: 0x%8.8x", *(uint32_t *)in);
292 LOG_ERROR(
"BUG: called with in == NULL");
300 uint32_t *r0, uint32_t *pc)
353 uint32_t
mask, uint32_t *core_regs[16])
369 for (i = 0; i <= 15; i++) {
383 uint32_t *buf_u32 =
buffer;
384 uint16_t *buf_u16 =
buffer;
397 for (i = 0; i <= 15; i++) {
441 LOG_DEBUG(
"xpsr: %8.8" PRIx32
", spsr: %i", xpsr, spsr);
471 uint8_t xpsr_im,
int rot,
int spsr)
476 LOG_DEBUG(
"xpsr_im: %2.2x, rot: %i, spsr: %i", xpsr_im, rot, spsr);
495 uint32_t
mask, uint32_t core_regs[16])
511 for (i = 0; i <= 15; i++) {
792 struct reg *vector_catch;
793 uint32_t vector_catch_value;
804 "with vector_catch");
811 if (!vector_catch->
valid)
818 vector_catch_value = 0x0;
819 if (strcmp(
CMD_ARGV[0],
"all") == 0)
820 vector_catch_value = 0xdf;
821 else if (strcmp(
CMD_ARGV[0],
"none") == 0) {
824 for (
unsigned int i = 0; i <
CMD_ARGC; i++) {
856 ?
"catch" :
"don't catch");
864 .
name =
"vector_catch",
865 .handler = handle_arm9tdmi_catch_vectors_command,
867 .help =
"Display, after optionally updating, configuration "
868 "of vector catch unit.",
869 .usage =
"[all|none|(reset|undef|swi|pabt|dabt|irq|fiq)*]",
880 .help =
"arm9 command group",
int arm7_9_endianness_callback(jtag_callback_data_t pu8_in, jtag_callback_data_t i_size, jtag_callback_data_t i_be, jtag_callback_data_t i_flip)
int arm7_9_write_memory_opt(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int arm7_9_examine(struct target *target)
Perform per-target setup that requires JTAG access.
void arm7_9_disable_eice_step(struct target *target)
void arm7_9_deinit(struct target *target)
int arm7_9_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
int arm7_9_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add a breakpoint to an ARM7/9 target.
int arm7_9_soft_reset_halt(struct target *target)
Issue a software reset and halt to an ARM7/9 target.
const struct command_registration arm7_9_command_handlers[]
int arm7_9_assert_reset(struct target *target)
Asserts the reset (SRST) on an ARM7/9 target.
int arm7_9_poll(struct target *target)
Polls an ARM7/9 target for its current status.
int arm7_9_halt(struct target *target)
Halt an ARM7/9 target.
int arm7_9_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
Removes a breakpoint from an ARM7/9 target.
int arm7_9_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
Remove a watchpoint from an ARM7/9 target.
int arm7_9_deassert_reset(struct target *target)
Deassert the reset (SRST) signal on an ARM7/9 target.
int arm7_9_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
void arm7_9_enable_eice_step(struct target *target, uint32_t next_pc)
int arm7_9_bulk_write_memory(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
int arm7_9_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
int arm7_9_target_request_data(struct target *target, uint32_t size, uint8_t *buffer)
Get some data from the ARM7/9 target.
int arm7_9_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
Add a watchpoint to an ARM7/9 target.
int arm7_9_check_reset(struct target *target)
int arm7_9_init_arch_info(struct target *target, struct arm7_9_common *arm7_9)
int arm7_9_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
#define ARM7_9_COMMON_MAGIC
static struct arm7_9_common * target_to_arm7_9(struct target *target)
void arm9tdmi_deinit_target(struct target *target)
static void arm9tdmi_write_pc(struct target *target, uint32_t pc)
static void arm9tdmi_write_xpsr(struct target *target, uint32_t xpsr, int spsr)
void arm9tdmi_load_hword_reg(struct target *target, int num)
void arm9tdmi_load_byte_reg(struct target *target, int num)
int arm9tdmi_init_arch_info(struct target *target, struct arm7_9_common *arm7_9, struct jtag_tap *tap)
static void arm9tdmi_read_xpsr(struct target *target, uint32_t *xpsr, int spsr)
static const struct command_registration arm9tdmi_exec_command_handlers[]
void arm9tdmi_read_core_regs(struct target *target, uint32_t mask, uint32_t *core_regs[16])
void arm9tdmi_store_byte_reg(struct target *target, int num)
static void arm9tdmi_read_core_regs_target_buffer(struct target *target, uint32_t mask, void *buffer, int size)
void arm9tdmi_store_hword_reg(struct target *target, int num)
static void arm9tdmi_branch_resume_thumb(struct target *target)
struct target_type arm9tdmi_target
Holds methods for ARM9TDMI targets.
int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target)
int arm9tdmi_clock_data_in_endianness(struct arm_jtag *jtag_info, void *in, int size, int be)
void arm9tdmi_enable_single_step(struct target *target, uint32_t next_pc)
const struct command_registration arm9tdmi_command_handlers[]
int arm9tdmi_clock_data_in(struct arm_jtag *jtag_info, uint32_t *in)
int arm9tdmi_examine_debug_reason(struct target *target)
void arm9tdmi_load_word_regs(struct target *target, uint32_t mask)
void arm9tdmi_write_core_regs(struct target *target, uint32_t mask, uint32_t core_regs[16])
static void arm9tdmi_change_to_arm(struct target *target, uint32_t *r0, uint32_t *pc)
COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command)
void arm9tdmi_store_word_regs(struct target *target, uint32_t mask)
void arm9tdmi_branch_resume(struct target *target)
void arm9tdmi_disable_single_step(struct target *target)
static int arm9tdmi_target_create(struct target *target, Jim_Interp *interp)
static void arm9tdmi_build_reg_cache(struct target *target)
static const struct arm9tdmi_vector arm9tdmi_vectors[]
int arm9tdmi_clock_out(struct arm_jtag *jtag_info, uint32_t instr, uint32_t out, uint32_t *in, int sysspeed)
static void arm9tdmi_write_xpsr_im8(struct target *target, uint8_t xpsr_im, int rot, int spsr)
int arm_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
Runs ARM code in the target to check whether a memory block holds all ones.
int arm_arch_state(struct target *target)
int arm_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
Runs ARM code in the target to calculate a CRC32 checksum.
struct reg_cache * arm_build_reg_cache(struct target *target, struct arm *arm)
const char * arm_get_gdb_arch(const struct target *target)
int arm_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
void arm_free_reg_cache(struct arm *arm)
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
int armv4_5_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)
static int arm_jtag_scann(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state)
static int arm_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
static void arm_le_to_h_u32(jtag_callback_data_t arg)
Macros used to generate various ARM or Thumb opcodes.
#define ARMV4_5_LDMIA(rn, list, s, w)
#define ARMV4_5_MRS(rn, r)
#define ARMV4_5_STRH_IP(rd, rn)
#define ARMV4_5_T_MOV(rd, rm)
#define ARMV4_5_LDRH_IP(rd, rn)
#define ARMV4_5_LDRB_IP(rd, rn)
#define ARMV4_5_T_LDR_PCREL(rd)
#define ARMV4_5_STR(rd, rn)
#define ARMV4_5_STMIA(rn, list, s, w)
#define ARMV4_5_MSR_IM(im, rotate, field, r)
#define ARMV4_5_STRB_IP(rd, rn)
#define ARMV4_5_T_STR(rd, rn)
int arm_semihosting_init(struct target *target)
Initialize ARM semihosting support.
uint32_t flip_u32(uint32_t value, unsigned int num)
Inverts the ordering of bits inside a 32-bit word (e.g.
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.
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 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.
void embeddedice_store_reg(struct reg *reg)
Queue a write for an EmbeddedICE register, using cached value.
int embeddedice_read_reg(struct reg *reg)
Queue a read for an EmbeddedICE register into the register cache, not checking the value read.
void jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
Goes to TAP_IDLE (if we're not already there), cycle precisely num_cycles in the TAP_IDLE state,...
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
Generate a DR SCAN using the fields passed to the function.
void jtag_add_callback4(jtag_callback_t f, jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
void jtag_add_callback(jtag_callback1_t f, jtag_callback_data_t data0)
A simpler version of jtag_add_callback4().
intptr_t jtag_callback_data_t
Defines the type of data passed to the jtag_callback_t interface.
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
struct reg_cache ** register_get_last_cache_p(struct reg_cache **first)
size_t size
Size of the control block search area.
Structure for items that are common between both ARM7 and ARM9 targets.
void(* enable_single_step)(struct target *target, uint32_t next_pc)
bool has_vector_catch
Specifies if the target has a reset vector catch.
void(* read_xpsr)(struct target *target, uint32_t *xpsr, int spsr)
Function for reading CPSR or SPSR.
unsigned int common_magic
void(* store_hword_reg)(struct target *target, int num)
void(* write_xpsr_im8)(struct target *target, uint8_t xpsr_im, int rot, int spsr)
Function for writing an immediate value to CPSR or SPSR.
void(* write_core_regs)(struct target *target, uint32_t mask, uint32_t core_regs[16])
uint32_t arm_bkpt
ARM breakpoint instruction.
bool use_dbgrq
Specifies if DBGRQ should be used to halt the target.
int(* bulk_write_memory)(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
Write target memory in multiples of 4 bytes, optimized for writing large quantities of data.
void(* branch_resume)(struct target *target)
int(* write_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Variant specific memory write function that does not dispatch to bulk_write_memory.
struct arm_jtag jtag_info
JTAG information for target.
void(* read_core_regs_target_buffer)(struct target *target, uint32_t mask, void *buffer, int size)
void(* store_byte_reg)(struct target *target, int num)
struct reg_cache * eice_cache
Embedded ICE register cache.
int(* post_debug_entry)(struct target *target)
Callback function called after entering debug mode.
void(* load_word_regs)(struct target *target, uint32_t mask)
void(* load_byte_reg)(struct target *target, int num)
void(* read_core_regs)(struct target *target, uint32_t mask, uint32_t *core_regs[16])
Function for reading the core registers.
void(* load_hword_reg)(struct target *target, int num)
void(* disable_single_step)(struct target *target)
void(* write_pc)(struct target *target, uint32_t pc)
Function for writing to the program counter.
uint16_t thumb_bkpt
Thumb breakpoint instruction.
void(* store_word_regs)(struct target *target, uint32_t mask)
void(* pre_restore_context)(struct target *target)
Callback function called before restoring the processor context.
int dbgreq_adjust_pc
Amount of PC adjustment caused by a DBGREQ.
int(* examine_debug_reason)(struct target *target)
Function for determining why debug state was entered.
void(* branch_resume_thumb)(struct target *target)
void(* change_to_arm)(struct target *target, uint32_t *r0, uint32_t *pc)
Function for changing from Thumb to ARM mode.
void(* write_xpsr)(struct target *target, uint32_t xpsr, int spsr)
Function for writing to CPSR or SPSR.
Represents a generic ARM core, with standard application registers.
enum arm_arch arch
ARM architecture version.
struct reg * pc
Handle to the PC; valid in all core modes.
struct reg_cache * core_cache
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
This structure defines a single scan field in the scan.
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
const uint8_t * out_value
A pointer to value to be scanned into the device.
unsigned int num_bits
The number of bits this field specifies.
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 target * get_current_target(struct command_context *cmd_ctx)
static bool target_was_examined(const struct target *target)
#define ERROR_TARGET_INVALID