46 uint32_t break_status;
57 if (break_status & 0x1f) {
73 if (break_status & 0x1f) {
114 LOG_DEBUG(
"entered debug state at PC 0x%" PRIx32
", target->state: %s",
211 LOG_DEBUG(
"EJTAG_CTRL_BRKST already set during server startup.");
268 LOG_WARNING(
"target was in unknown state when halt was requested");
272 LOG_ERROR(
"can't request a halt while in reset if nSRST pulls nTRST");
299 LOG_WARNING(
"Reset is not asserted because the target is not examined.");
300 LOG_WARNING(
"Use a reset button or power cycle the target.");
340 LOG_DEBUG(
"Using MTAP reset to reset processor...");
352 LOG_DEBUG(
"Using EJTAG reset (PRRST) to reset processor...");
412 handle_breakpoints, 0);
425 target_addr_t address,
int handle_breakpoints,
int debug_execution)
437 if (!debug_execution) {
451 if ((mips32->
isa_imp > 1) && debug_execution)
462 if (handle_breakpoints) {
484 if (!debug_execution) {
487 LOG_DEBUG(
"target resumed at 0x%" PRIx32
"", resume_pc);
491 LOG_DEBUG(
"target debug resumed at 0x%" PRIx32
"", resume_pc);
546 if (handle_breakpoints) {
611 while (comparator_list[bp_num].
used && (bp_num < mips32->num_inst_bpoints))
614 LOG_ERROR(
"Can not find free FP Comparator(bpid: %" PRIu32
")",
619 comparator_list[bp_num].
used = 1;
623 comparator_list[bp_num].
bp_value |= 1;
625 comparator_list[bp_num].
bp_value &= ~1;
631 comparator_list[bp_num].
bp_value &= 0xFFFFFFFC;
639 LOG_DEBUG(
"bpid: %" PRIu32
", bp_num %i bp_value 0x%" PRIx32
"",
641 bp_num, comparator_list[bp_num].
bp_value);
650 uint32_t verify = 0xffffffff;
653 sdbbp32_instr =
SWAP16(sdbbp32_instr);
669 if (verify != sdbbp32_instr)
677 uint8_t sdbbp_buf[4];
699 uint16_t verify = 0xffff;
743 LOG_DEBUG(
"Invalid FP Comparator number in breakpoint (bpid: %" PRIu32
")",
747 LOG_DEBUG(
"bpid: %" PRIu32
" - releasing hw: %d",
750 comparator_list[bp_num].
used = 0;
751 comparator_list[bp_num].
bp_value = 0;
759 uint8_t current_instr[4];
764 sdbbp32_instr =
SWAP16(sdbbp32_instr);
826 LOG_INFO(
"no hardware breakpoint available");
876 while (comparator_list[wp_num].
used && (wp_num < mips32->num_data_bpoints))
879 LOG_ERROR(
"Can not find free FP Comparator");
884 LOG_ERROR(
"Only watchpoints of length 4 are supported");
889 LOG_ERROR(
"Watchpoints address should be word aligned");
904 LOG_ERROR(
"BUG: watchpoint->rw neither read, write nor access");
908 comparator_list[wp_num].
used = 1;
914 comparator_list[wp_num].
bp_value &= 0xFFFFFFF8;
929 LOG_DEBUG(
"wp_num %i bp_value 0x%" PRIx32
"", wp_num, comparator_list[wp_num].
bp_value);
949 LOG_DEBUG(
"Invalid FP Comparator number in watchpoint");
952 comparator_list[wp_num].
used = 0;
953 comparator_list[wp_num].
bp_value = 0;
966 LOG_INFO(
"no hardware watchpoints available");
1025 if (((
size == 4) && (address & 0x3u)) || ((
size == 2) && (address & 0x1u)))
1038 t = malloc(
count *
size *
sizeof(uint8_t));
1097 if (((
size == 4) && (address & 0x3u)) || ((
size == 2) && (address & 0x1u)))
1105 t = malloc(
count *
size *
sizeof(uint8_t));
1179 if (((ejtag_info->
idcode >> 1) & 0x7FF) == 0x29) {
1183 LOG_DEBUG(
"PIC32 Detected - using EJTAG Interface");
1236 LOG_ERROR(
"Change work-area-phys or load_image address!");
1243 t = malloc(
count *
sizeof(uint32_t));
1302 LOG_ERROR(
"Change work-area-phys or load_image address!");
1308 uint32_t *t = malloc(
count *
sizeof(uint32_t));
1357 uint32_t cp0_reg, cp0_sel;
1366 "couldn't access reg %" PRIu32,
1371 cp0_reg, cp0_sel, value);
1379 "couldn't access cp0 reg %" PRIu32
", select %" PRIu32,
1384 cp0_reg, cp0_sel, value);
1404 ejtag_info->
mode = 0;
1407 ejtag_info->
mode = 1;
1417 .handler = mips_m4k_handle_cp0_command,
1419 .usage =
"regnum [value]",
1420 .help =
"display/modify cp0 register",
1423 .name =
"scan_delay",
1424 .handler = mips_m4k_handle_scan_delay_command,
1426 .help =
"display/set scan delay in nano seconds",
1442 .help =
"mips_m4k command group",
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)
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_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
#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 COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#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 jtag_add_reset(int req_tlr_or_trst, int req_srst)
A reset of the TAP state machine can be requested.
static enum reset_types jtag_reset_config
void jtag_add_sleep(uint32_t us)
enum reset_types jtag_get_reset_config(void)
#define LOG_WARNING(expr ...)
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
struct reg_cache * mips32_build_reg_cache(struct target *target)
const struct command_registration mips32_command_handlers[]
int mips32_read_config_regs(struct target *target)
int mips32_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
int mips32_configure_break_unit(struct target *target)
int mips32_arch_state(struct target *target)
int mips32_cpu_probe(struct target *target)
mips32_cpu_probe - Detects processor type and applies necessary quirks.
int mips32_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)
int mips32_examine(struct target *target)
int mips32_init_arch_info(struct target *target, struct mips32_common *mips32, struct jtag_tap *tap)
int mips32_save_context(struct target *target)
int mips32_enable_interrupts(struct target *target, int enable)
int mips32_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
Checks whether a memory region is erased.
int mips32_restore_context(struct target *target)
int mips32_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
#define MIPS32_SCAN_DELAY_LEGACY_MODE
static struct mips32_common * target_to_mips32(struct target *target)
#define MIPS32_SDBBP(isa)
#define MIPS32_REGLIST_C0_PC_INDEX
#define MIPS16_SDBBP(isa)
int mips32_dmaacc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source, int write_t, uint32_t addr, int count, uint32_t *buf)
int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
int mips32_cp0_read(struct mips_ejtag *ejtag_info, uint32_t *val, uint32_t cp0_reg, uint32_t cp0_sel)
mips32_cp0_read
int mips32_cp0_write(struct mips_ejtag *ejtag_info, uint32_t val, uint32_t cp0_reg, uint32_t cp0_sel)
mips32_cp0_write
#define MIPS32_FASTDATA_HANDLER_SIZE
int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info)
void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data)
void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr)
int mips_ejtag_drscan_32(struct mips_ejtag *ejtag_info, uint32_t *data)
void mips_ejtag_drscan_8_out(struct mips_ejtag *ejtag_info, uint8_t data)
int mips_ejtag_exit_debug(struct mips_ejtag *ejtag_info)
int mips_ejtag_enter_debug(struct mips_ejtag *ejtag_info)
int mips_ejtag_config_step(struct mips_ejtag *ejtag_info, int enable_step)
int mips_ejtag_init(struct mips_ejtag *ejtag_info)
#define EJTAG_INST_CONTROL
#define EJTAG_CTRL_DBGISA
#define EJTAG_INST_NORMALBOOT
#define EJTAG_CTRL_PERRST
#define MCHP_DE_ASSERT_RST
#define EJTAG_DBCN_BLM_SHIFT
#define EJTAG_INST_EJTAGBOOT
static int mips_m4k_deassert_reset(struct target *target)
static int mips_m4k_internal_restore(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
static int mips_m4k_assert_reset(struct target *target)
static int mips_m4k_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
static int mips_m4k_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
static int mips_m4k_bulk_read_memory(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
static int mips_m4k_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
static int mips_m4k_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
static int mips_m4k_examine_debug_reason(struct target *target)
static int mips_m4k_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
static int mips_m4k_single_step_core(struct target *target)
static int mips_m4k_verify_pointer(struct command_invocation *cmd, struct mips_m4k_common *mips_m4k)
static int update_halt_gdb(struct target *target)
static int mips_m4k_halt_smp(struct target *target)
static int mips_m4k_examine(struct target *target)
static int mips_m4k_init_arch_info(struct target *target, struct mips_m4k_common *mips_m4k, struct jtag_tap *tap)
static int mips_m4k_unset_breakpoint(struct target *target, struct breakpoint *breakpoint)
static int mips_m4k_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
static struct target * get_mips_m4k(struct target *target, int32_t coreid)
static int mips_m4k_set_breakpoint(struct target *target, struct breakpoint *breakpoint)
static int mips_m4k_debug_entry(struct target *target)
static const struct command_registration mips_m4k_exec_command_handlers[]
static const struct command_registration mips_m4k_command_handlers[]
static int mips_m4k_restore_smp(struct target *target, uint32_t address, int handle_breakpoints)
static int mips_m4k_unset_watchpoint(struct target *target, struct watchpoint *watchpoint)
static int mips_m4k_set_watchpoint(struct target *target, struct watchpoint *watchpoint)
static int mips_m4k_init_target(struct command_context *cmd_ctx, struct target *target)
static int mips_m4k_target_create(struct target *target, Jim_Interp *interp)
static int mips_m4k_halt(struct target *target)
COMMAND_HANDLER(mips_m4k_handle_cp0_command)
static int mips_m4k_poll(struct target *target)
struct target_type mips_m4k_target
static int mips_m4k_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
static void mips_m4k_enable_breakpoints(struct target *target)
static int mips_m4k_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
static void mips_m4k_enable_watchpoints(struct target *target)
static struct mips_m4k_common * target_to_m4k(struct target *target)
#define MIPSM4K_COMMON_MAGIC
static void mips_m4k_isa_filter(enum mips32_isa_imp isa_imp, target_addr_t *addr)
void register_cache_invalidate(struct reg_cache *cache)
Marks the contents of the register cache as invalid (and clean).
size_t size
Size of the control block search area.
const struct command_registration smp_command_handlers[]
#define foreach_smp_target(pos, head)
enum breakpoint_type type
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...
struct mips32_comparator * data_break_list
struct mips32_comparator * inst_break_list
struct mips_ejtag ejtag_info
struct working_area * fast_data_area
int num_data_bpoints_avail
enum mips32_isa_imp isa_imp
enum mips32_isa_mode isa_mode
struct reg_cache * core_cache
int num_inst_bpoints_avail
uint32_t ejtag_dbasid_offs
unsigned int ejtag_version
struct mips32_common mips32
unsigned int common_magic
This holds methods shared between all instances of a given target type.
const char * name
Name of this type of target.
struct gdb_service * gdb_service
enum target_debug_reason debug_reason
struct list_head * smp_targets
struct breakpoint * breakpoints
struct watchpoint * watchpoints
void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, uint32_t count, uint16_t *dstbuf)
int target_call_event_callbacks(struct target *target, enum target_event event)
void target_free_all_working_areas(struct target *target)
int target_halt(struct target *target)
void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t value)
int target_write_u16(struct target *target, target_addr_t address, uint16_t value)
int target_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Write count items of size bytes to the memory of target at the address given.
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
const char * target_state_name(const struct target *t)
Return the name of this targets current state.
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.
bool target_has_event_action(const struct target *target, enum target_event event)
Returns true only if the target has a handler for the specified event.
void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf)
void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, uint32_t count, uint32_t *dstbuf)
struct target * get_current_target(struct command_context *cmd_ctx)
void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
void target_handle_event(struct target *target, enum target_event e)
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
#define ERROR_TARGET_NOT_HALTED
static bool target_was_examined(const struct target *target)
#define ERROR_TARGET_UNALIGNED_ACCESS
#define ERROR_TARGET_INVALID
@ TARGET_EVENT_DEBUG_RESUMED
@ TARGET_EVENT_DEBUG_HALTED
@ TARGET_EVENT_RESET_ASSERT
#define ERROR_TARGET_NOT_EXAMINED
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define ERROR_TARGET_FAILURE