26 "MIPS32",
"MIPS16",
"",
"MICRO MIPS32",
29 #define MIPS32_GDB_DUMMY_FP_REG 1
153 #define MIPS32_NUM_REGS ARRAY_SIZE(mips32_regs)
218 LOG_DEBUG(
"write core reg %i value 0x%" PRIx32
"", num, reg_value);
234 *reg_list = malloc(
sizeof(
struct reg *) * (*reg_list_size));
284 LOG_USER(
"target halted in %s mode due to %s, pc: 0x%8.8" PRIx32
"",
305 struct reg *reg_list = calloc(num_regs,
sizeof(
struct reg));
311 cache->
name =
"mips32 registers";
318 for (i = 0; i < num_regs; i++) {
324 reg_list[i].
size = 32;
328 reg_list[i].
valid =
true;
332 reg_list[i].
value = calloc(1, 4);
333 reg_list[i].
valid =
false;
341 LOG_ERROR(
"unable to allocate reg type list");
344 reg_list[i].
dirty =
false;
348 reg_list[i].
exist =
true;
356 LOG_ERROR(
"unable to allocate feature list");
410 if (exit_point && (pc != exit_point)) {
411 LOG_DEBUG(
"failed algorithm halted at 0x%" PRIx32
" ", pc);
419 struct mem_param *mem_params,
int num_reg_params,
436 LOG_ERROR(
"current target isn't a MIPS32 target");
452 for (
int i = 0; i < num_mem_params; i++) {
456 mem_params[i].
size, mem_params[i].value);
461 for (
int i = 0; i < num_reg_params; i++) {
468 LOG_ERROR(
"BUG: register '%s' not found", reg_params[i].reg_name);
473 LOG_ERROR(
"BUG: register '%s' size doesn't match reg_params[i].size",
474 reg_params[i].reg_name);
488 for (
int i = 0; i < num_mem_params; i++) {
491 mem_params[i].
value);
497 for (
int i = 0; i < num_reg_params; i++) {
501 LOG_ERROR(
"BUG: register '%s' not found", reg_params[i].reg_name);
506 LOG_ERROR(
"BUG: register '%s' size doesn't match reg_params[i].size",
507 reg_params[i].reg_name);
519 if (regvalue != context[i]) {
520 LOG_DEBUG(
"restoring register %s with value 0x%8.8" PRIx32,
652 LOG_WARNING(
"DCR endianness settings does not match target settings");
703 for (
int i = 0; i != 4; i++) {
706 LOG_ERROR(
"isa info not available, failed to read cp0 config register: %" PRId32, i);
711 if ((ejtag_info->
config[i] & (1 << 31)) == 0)
721 LOG_USER(
"MIPS32 with MIPS16 support implemented");
727 LOG_USER(
"MICRO MIPS32 only implemented");
729 }
else if (isa_imp != 0) {
731 LOG_USER(
"MIPS32 and MICRO MIPS32 implemented");
736 LOG_USER(
"MIPS32 only implemented");
741 uint32_t
count, uint32_t *checksum)
751 uint32_t
isa = ejtag_info->
isa ? 1 : 0;
753 uint32_t mips_crc_code[] = {
789 uint8_t mips_crc_code_8[
sizeof(mips_crc_code)];
809 crc_algorithm->
address + (
sizeof(mips_crc_code) - 4),
timeout, &mips32_info);
812 *checksum =
buf_get_u32(reg_params[0].value, 0, 32);
825 uint8_t erased_value)
834 if (erased_value != 0xff) {
835 LOG_ERROR(
"Erase value 0x%02" PRIx8
" not yet supported for MIPS32",
839 uint32_t
isa = ejtag_info->
isa ? 1 : 0;
840 uint32_t erase_check_code[] = {
857 uint8_t erase_check_code_8[
sizeof(erase_check_code)];
859 ARRAY_SIZE(erase_check_code), erase_check_code);
862 sizeof(erase_check_code), erase_check_code_8);
870 buf_set_u32(reg_params[0].value, 0, 32, blocks[0].address);
876 buf_set_u32(reg_params[2].value, 0, 32, erased_value);
879 erase_check_algorithm->
address + (
sizeof(erase_check_code) - 4), 10000, &mips32_info);
932 uint32_t cp0_reg, cp0_sel;
942 "couldn't access reg %" PRIu32,
947 cp0_reg, cp0_sel, value);
955 "couldn't access cp0 reg %" PRIu32
", select %" PRIu32,
960 cp0_reg, cp0_sel, value);
980 ejtag_info->
mode = 0;
983 ejtag_info->
mode = 1;
993 .handler = mips32_handle_cp0_command,
995 .usage =
"regnum select [value]",
996 .help =
"display/modify cp0 register",
999 .name =
"scan_delay",
1000 .handler = mips32_handle_scan_delay_command,
1002 .help =
"display/set scan delay in nano seconds",
1012 .help =
"mips32 command group",
void init_reg_param(struct reg_param *param, char *reg_name, uint32_t size, enum param_direction direction)
void destroy_reg_param(struct reg_param *param)
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned 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 first, unsigned 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_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.
static uint16_t direction
#define LOG_USER(expr ...)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
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, int timeout_ms, void *arch_info)
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)
static int mips32_set_core_reg(struct reg *reg, uint8_t *buf)
static uint8_t mips32_gdb_dummy_fp_value[]
#define MIPS32_GDB_DUMMY_FP_REG
int mips32_configure_break_unit(struct target *target)
static int mips32_get_core_reg(struct reg *reg)
int mips32_arch_state(struct target *target)
COMMAND_HANDLER(mips32_handle_cp0_command)
MIPS32 targets expose command interface to manipulate CP0 registers.
static int mips32_configure_ibs(struct target *target)
int mips32_examine(struct target *target)
int mips32_init_arch_info(struct target *target, struct mips32_common *mips32, struct jtag_tap *tap)
static const struct reg_arch_type mips32_reg_type
static int mips32_configure_dbs(struct target *target)
static int mips32_write_core_reg(struct target *target, unsigned int num)
static int mips32_run_and_wait(struct target *target, target_addr_t entry_point, int timeout_ms, target_addr_t exit_point, struct mips32_common *mips32)
static int mips32_read_core_reg(struct target *target, unsigned int num)
int mips32_save_context(struct target *target)
int mips32_enable_interrupts(struct target *target, int enable)
static const char * mips_isa_strings[]
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)
static int mips32_verify_pointer(struct command_invocation *cmd, struct mips32_common *mips32)
static const struct @103 mips32_regs[]
int mips32_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
static const struct command_registration mips32_exec_command_handlers[]
#define MIPS32_SCAN_DELAY_LEGACY_MODE
#define MIPS32_ADDI(isa, tar, src, val)
#define MIPS32_CONFIG3_ISA_MASK
static struct mips32_common * target_to_mips32(struct target *target)
#define MIPS32_XOR(isa, reg, val1, val2)
#define MIPS32_COMMON_MAGIC
#define MIPS32_SDBBP(isa)
#define MIPS32_LB(isa, reg, off, base)
#define MIPS32_BNE(isa, src, tar, off)
#define MIPS32_BEQ(isa, src, tar, off)
#define MIPS32_CONFIG3_ISA_SHIFT
#define MIPS32_MOVN(isa, dst, src, tar)
#define MIPS32_ADDU(isa, dst, src, tar)
#define MIPS32_ADDIU(isa, tar, src, val)
#define MIPS32_LUI(isa, reg, val)
#define MIPS32_AND(isa, dst, src, tar)
#define MIPS32_ORI(isa, tar, src, val)
#define MIPS32_SLL(isa, dst, src, sa)
#define MIPS32_SLTI(isa, tar, src, val)
int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
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
static void pracc_swap16_array(struct mips_ejtag *ejtag_info, uint32_t *buf, int count)
#define EJTAG_V20_IMP_NODB
#define EJTAG_V20_IMP_NOIB
void register_init_dummy(struct reg *reg)
struct reg * register_get_by_name(struct reg_cache *first, const char *name, bool search_all)
struct reg_cache ** register_get_last_cache_p(struct reg_cache **first)
size_t size
Size of the control block search area.
When run_command is called, a new instance will be created on the stack, filled with the proper value...
enum mips32_isa_mode isa_mode
unsigned int common_magic
int(* write_core_reg)(struct target *target, unsigned int num)
uint32_t core_regs[MIPS32NUMCOREREGS]
unsigned int common_magic
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
int(* read_core_reg)(struct target *target, unsigned int num)
enum mips32_isa_imp isa_imp
enum mips32_isa_mode isa_mode
struct reg_cache * core_cache
int num_inst_bpoints_avail
struct mips32_common * mips32_common
unsigned int ejtag_version
uint32_t ejtag_iba_step_size
uint32_t ejtag_dba_step_size
int(* get)(struct reg *reg)
struct reg_feature * feature
struct reg_data_type * reg_data_type
const struct reg_arch_type * type
enum target_endianness endianness
struct reg_cache * reg_cache
int target_halt(struct target *target)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
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)
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
int target_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, target_addr_t entry_point, target_addr_t exit_point, int timeout_ms, void *arch_info)
Downloads a target-specific native code algorithm to the target, and executes it.
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
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)
const char * debug_reason_name(struct target *t)
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...
int target_wait_state(struct target *target, enum target_state state, int ms)
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_INVALID
#define ERROR_TARGET_TIMEOUT
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static void target_set_examined(struct target *target)
Sets the examined flag for the given target.
static bool target_was_examined(struct target *target)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.