35 #define _DEBUG_INSTRUCTION_EXECUTION_
38 #define ARM926EJS_CP15_ADDR(opcode_1, opcode_2, crn, crm) ((opcode_1 << 11) | (opcode_2 << 8) | (crn << 4) | (crm << 0))
41 uint32_t crn, uint32_t crm, uint32_t *value)
48 uint8_t address_buf[2] = {0, 0};
63 fields[0].
in_value = (uint8_t *)value;
98 LOG_ERROR(
"cp15 read operation timed out");
103 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
104 LOG_DEBUG(
"addr: 0x%x value: %8.8x", address, *value);
115 uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
125 uint32_t crn, uint32_t crm, uint32_t value)
132 uint8_t value_buf[4];
133 uint8_t address_buf[2] = {0, 0};
134 uint8_t nr_w_buf = 1;
135 uint8_t access_t = 1;
181 LOG_ERROR(
"cp15 write operation timed out");
186 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
187 LOG_DEBUG(
"addr: 0x%x value: %8.8x", address, value);
198 uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
222 switch (debug_reason) {
224 LOG_DEBUG(
"no *NEW* debug entry (?missed one?)");
229 LOG_DEBUG(
"breakpoint from EICE unit 0");
233 LOG_DEBUG(
"breakpoint from EICE unit 1");
237 LOG_DEBUG(
"soft breakpoint (BKPT instruction)");
249 LOG_DEBUG(
"watchpoint from EICE unit 0");
253 LOG_DEBUG(
"watchpoint from EICE unit 1");
269 LOG_DEBUG(
"debug re-entry from system speed access");
278 LOG_ERROR(
"unexpected -- debug re-entry");
293 LOG_WARNING(
"WARNING: mystery debug reason MOE = 0xc. Try issuing a resume + halt.");
297 LOG_WARNING(
"WARNING: unknown debug reason: 0x%x", debug_reason);
326 int d_u_cache,
int i_cache)
329 uint32_t cp15_control;
346 cp15_control &= ~0x1U;
350 uint32_t debug_override;
356 debug_override |= 0x80000;
368 debug_override &= ~0x80000;
373 cp15_control &= ~0x4U;
382 cp15_control &= ~0x1000U;
390 int d_u_cache,
int i_cache)
393 uint32_t cp15_control;
405 cp15_control |= 0x1U;
408 cp15_control |= 0x4U;
411 cp15_control |= 0x1000U;
432 uint32_t cache_type_reg;
458 LOG_DEBUG(
"D FSR: 0x%8.8" PRIx32
", D FAR: 0x%8.8" PRIx32
", I FSR: 0x%8.8" PRIx32
"",
461 uint32_t cache_dbg_ctrl;
468 cache_dbg_ctrl |= 0x7;
482 uint32_t cache_dbg_ctrl;
487 cache_dbg_ctrl &= ~0x7;
506 static const char *
state[] = {
507 "disabled",
"enabled"
518 LOG_USER(
"MMU: %s, D-Cache: %s, I-Cache: %s",
555 LOG_ERROR(
"Failed to halt CPU after 1 sec");
766 .
name =
"cache_info",
767 .handler = arm926ejs_handle_cache_info_command,
770 .help =
"display information about target caches",
782 .help =
"arm926ejs command group",
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_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_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)
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_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
static struct arm7_9_common * target_to_arm7_9(struct target *target)
static int arm926ejs_cp15_write(struct target *target, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
static int arm926ejs_target_create(struct target *target, Jim_Interp *interp)
static const char arm926_not[]
static int arm926ejs_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
static int arm926ejs_disable_mmu_caches(struct target *target, int mmu, int d_u_cache, int i_cache)
int arm926ejs_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Writes a buffer, in the specified word size, with current MMU settings.
struct target_type arm926ejs_target
Holds methods for ARM926 targets.
static int arm926ejs_post_debug_entry(struct target *target)
static int arm926ejs_mcr(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
#define ARM926EJS_CP15_ADDR(opcode_1, opcode_2, crn, crm)
static int arm926ejs_verify_pointer(struct command_invocation *cmd, struct arm926ejs_common *arm926)
static const struct command_registration arm926ejs_exec_command_handlers[]
static int arm926ejs_read_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
const struct command_registration arm926ejs_command_handlers[]
int arm926ejs_init_arch_info(struct target *target, struct arm926ejs_common *arm926ejs, struct jtag_tap *tap)
static int arm926ejs_mmu(struct target *target, int *enabled)
static int arm926ejs_get_ttb(struct target *target, uint32_t *result)
static int arm926ejs_examine_debug_reason(struct target *target)
static void arm926ejs_pre_restore_context(struct target *target)
static int arm926ejs_cp15_read(struct target *target, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
static void arm926ejs_deinit_target(struct target *target)
int arm926ejs_arch_state(struct target *target)
Logs summary of ARM926 state for a halted target.
static int arm926ejs_write_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
static int arm926ejs_mrc(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
static int arm926ejs_enable_mmu_caches(struct target *target, int mmu, int d_u_cache, int i_cache)
int arm926ejs_soft_reset_halt(struct target *target)
COMMAND_HANDLER(arm926ejs_handle_cache_info_command)
#define ARM926EJS_COMMON_MAGIC
static struct arm926ejs_common * target_to_arm926(struct target *target)
int arm9tdmi_init_arch_info(struct target *target, struct arm7_9_common *arm7_9, struct jtag_tap *tap)
int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target)
const struct command_registration arm9tdmi_command_handlers[]
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.
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.
void arm_set_cpsr(struct arm *arm, uint32_t cpsr)
Configures host-side ARM records to reflect the specified CPSR.
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.
int armv4_5_identify_cache(uint32_t cache_type_reg, struct armv4_5_cache_common *cache)
int armv4_5_handle_cache_info_command(struct command_invocation *cmd, struct armv4_5_cache_common *armv4_5_cache)
int armv4_5_mmu_read_physical(struct target *target, struct armv4_5_mmu_common *armv4_5_mmu, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
int armv4_5_mmu_write_physical(struct target *target, struct armv4_5_mmu_common *armv4_5_mmu, uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int armv4_5_mmu_translate_va(struct target *target, struct armv4_5_mmu_common *armv4_5_mmu, uint32_t va, uint32_t *cb, uint32_t *val)
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_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.
int embeddedice_read_reg(struct reg *reg)
Queue a read for an EmbeddedICE register into the register cache, not checking the value read.
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_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.
void alive_sleep(uint64_t ms)
#define LOG_USER(expr ...)
#define LOG_WARNING(expr ...)
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
size_t size
Size of the control block search area.
Structure for items that are common between both ARM7 and ARM9 targets.
uint32_t arm_bkpt
ARM breakpoint instruction.
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.
struct reg_cache * eice_cache
Embedded ICE register cache.
int(* post_debug_entry)(struct target *target)
Callback function called after entering debug mode.
uint16_t thumb_bkpt
Thumb breakpoint instruction.
void(* pre_restore_context)(struct target *target)
Callback function called before restoring the processor context.
int(* examine_debug_reason)(struct target *target)
Function for determining why debug state was entered.
uint32_t cp15_control_reg
int(* write_cp15)(struct target *target, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
int(* read_cp15)(struct target *target, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
struct arm7_9_common arm7_9_common
struct armv4_5_mmu_common armv4_5_mmu
unsigned int common_magic
Represents a generic ARM core, with standard application registers.
int(* mrc)(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
Read coprocessor register.
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(* mcr)(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
Write coprocessor register.
int(* write_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int(* read_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
int(* get_ttb)(struct target *target, uint32_t *result)
int(* enable_mmu_caches)(struct target *target, int mmu, int d_u_cache, int i_cache)
int(* disable_mmu_caches)(struct target *target, int mmu, int d_u_cache, int i_cache)
struct armv4_5_cache_common armv4_5_cache
When run_command is called, a new instance will be created on the stack, filled with the proper value...
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.
int(* virt2phys)(struct target *target, target_addr_t address, target_addr_t *physical)
enum target_debug_reason debug_reason
struct target_type * type
int target_call_event_callbacks(struct target *target, enum target_event event)
int target_halt(struct target *target)
struct target * get_current_target(struct command_context *cmd_ctx)
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_INVALID
#define ERROR_TARGET_TIMEOUT