OpenOCD
mips32.c File Reference
Include dependency graph for mips32.c:

Go to the source code of this file.

Macros

#define a0   4
 
#define a1   5
 
#define a2   6
 
#define a3   7
 
#define AT   1
 
#define fp   30
 
#define gp   28
 
#define k0   26
 
#define k1   27
 
#define MIPS32_GDB_FP_REG   1
 
#define MIPS32_NUM_REGS   ARRAY_SIZE(mips32_regs)
 
#define ra   31
 
#define s0   16
 
#define s1   17
 
#define s2   18
 
#define s3   19
 
#define s4   20
 
#define s5   21
 
#define s6   22
 
#define s7   23
 
#define s8   30 /* == fp */
 
#define sp   29
 
#define t0   8
 
#define t1   9
 
#define t2   10
 
#define t3   11
 
#define t4   12
 
#define t5   13
 
#define t6   14
 
#define t7   15
 
#define t8   24
 
#define t9   25
 
#define ta0   12 /* alias for $t4 */
 
#define ta1   13 /* alias for $t5 */
 
#define ta2   14 /* alias for $t6 */
 
#define ta3   15 /* alias for $t7 */
 
#define v0   2
 
#define v1   3
 
#define zero   0
 

Functions

 COMMAND_HANDLER (mips32_handle_cp0_command)
 mips32_handle_cp0_command - Handle commands related to CP0 registers. More...
 
 COMMAND_HANDLER (mips32_handle_cpuinfo_command)
 mips32_handle_cpuinfo_command - Handles the 'cpuinfo' command. More...
 
 COMMAND_HANDLER (mips32_handle_dsp_command)
 mips32_handle_dsp_command - Handles mips dsp related command More...
 
 COMMAND_HANDLER (mips32_handle_ejtag_reg_command)
 mips32_handle_ejtag_reg_command - Handler commands related to EJTAG More...
 
 COMMAND_HANDLER (mips32_handle_scan_delay_command)
 mips32_handle_scan_delay_command - Handler command for changing scan delay More...
 
int mips32_arch_state (struct target *target)
 
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. More...
 
struct reg_cachemips32_build_reg_cache (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)
 
static int mips32_configure_dbs (struct target *target)
 
static int mips32_configure_ibs (struct target *target)
 
static const struct mips32_cp0mips32_cp0_find_register_by_name (uint32_t cp0_mask, const char *reg_name)
 mips32_cp0_find_register_by_name - Find CP0 register by its name. More...
 
static int mips32_cp0_get_all_regs (struct command_invocation *cmd, struct mips_ejtag *ejtag_info, uint32_t cp0_mask)
 mips32_cp0_get_all_regs - Print all CP0 registers and their values. More...
 
static int mips32_cp0_get_reg_by_name (struct command_invocation *cmd, struct mips_ejtag *ejtag_info, uint32_t cp0_mask)
 mips32_cp0_get_reg_by_name - Read and print a CP0 register's value by name. More...
 
static int mips32_cp0_get_reg_by_number (struct command_invocation *cmd, struct mips_ejtag *ejtag_info)
 mips32_cp0_get_reg_by_number - Read and print a CP0 register's value by number. More...
 
static int mips32_cp0_set_reg_by_name (struct command_invocation *cmd, struct mips32_common *mips32, struct mips_ejtag *ejtag_info)
 mips32_cp0_set_reg_by_name - Write to a CP0 register identified by name. More...
 
static int mips32_cp0_set_reg_by_number (struct command_invocation *cmd, struct mips32_common *mips32, struct mips_ejtag *ejtag_info)
 mips32_cp0_set_reg_by_number - Write to a CP0 register identified by number. More...
 
static int mips32_cpu_get_release (struct mips_ejtag *ejtag_info)
 
static bool mips32_cpu_is_lexra (struct mips_ejtag *ejtag_info)
 
int mips32_cpu_probe (struct target *target)
 mips32_cpu_probe - Detects processor type and applies necessary quirks. More...
 
bool mips32_cpu_support_hazard_barrier (struct mips_ejtag *ejtag_info)
 mips32_cpu_support_hazard_barrier - Checks CPU supports hazard barrier More...
 
bool mips32_cpu_support_sync (struct mips_ejtag *ejtag_info)
 mips32_cpu_support_sync - Checks CPU supports ordering More...
 
static void mips32_detect_fpr_mode_change (struct mips32_common *mips32, uint32_t cp0_status)
 mips32_detect_fpr_mode_change - Detect changes in floating-point register mode More...
 
static void mips32_dsp_enable (struct pracc_queue_info *ctx, int isa)
 mips32_dsp_enable - Enable access to DSP registers More...
 
static int mips32_dsp_find_register_by_name (const char *reg_name)
 mips32_dsp_find_register_by_name - Find DSP register index by name More...
 
static int mips32_dsp_get_all_regs (struct command_invocation *cmd, struct mips_ejtag *ejtag_info)
 mips32_dsp_get_all_regs - Get values of all MIPS32 DSP registers More...
 
static int mips32_dsp_get_register (struct command_invocation *cmd, struct mips_ejtag *ejtag_info)
 mips32_dsp_get_register - Get the value of a MIPS32 DSP register More...
 
static void mips32_dsp_restore (struct pracc_queue_info *ctx, int isa)
 mips32_dsp_restore - Restore DSP status registers to the previous setting More...
 
static int mips32_dsp_set_register (struct command_invocation *cmd, struct mips_ejtag *ejtag_info)
 mips32_dsp_set_register - Set the value of a MIPS32 DSP register More...
 
int mips32_enable_interrupts (struct target *target, int enable)
 
int mips32_examine (struct target *target)
 
static const struct cpu_entrymips32_find_cpu_by_prid (uint32_t prid)
 mips32_find_cpu_by_prid - Find CPU information by processor ID. More...
 
static int mips32_get_core_reg (struct reg *reg)
 
int mips32_get_gdb_reg_list (struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
 
int mips32_init_arch_info (struct target *target, struct mips32_common *mips32, struct jtag_tap *tap)
 
static int mips32_pracc_read_dsp_reg (struct mips_ejtag *ejtag_info, uint32_t *val, uint32_t reg)
 mips32_pracc_read_dsp_reg - Read a value from a MIPS32 DSP register More...
 
static int mips32_pracc_write_dsp_reg (struct mips_ejtag *ejtag_info, uint32_t val, uint32_t reg)
 mips32_pracc_write_dsp_reg - Write a value to a MIPS32 DSP register More...
 
static int mips32_read_c0_prid (struct target *target)
 
static void mips32_read_config_dsp (struct mips32_common *mips32, struct mips_ejtag *ejtag_info)
 
static void mips32_read_config_fdc (struct mips32_common *mips32, struct mips_ejtag *ejtag_info, uint32_t dcr)
 mips32_read_config_fdc - Read Fast Debug Channel configuration More...
 
static int mips32_read_config_fpu (struct mips32_common *mips32, struct mips_ejtag *ejtag_info)
 
static int mips32_read_config_mmu (struct mips_ejtag *ejtag_info)
 mips32_read_config_mmu - Reads MMU configuration and logs relevant information. More...
 
int mips32_read_config_regs (struct target *target)
 
static int mips32_read_core_reg (struct target *target, unsigned int num)
 
int mips32_restore_context (struct target *target)
 
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)
 
static int mips32_run_and_wait (struct target *target, target_addr_t entry_point, unsigned int timeout_ms, target_addr_t exit_point, struct mips32_common *mips32)
 
int mips32_save_context (struct target *target)
 
static void mips32_set_all_fpr_width (struct mips32_common *mips32, bool fp64)
 mips32_set_all_fpr_width - Set the width of all floating-point registers More...
 
static int mips32_set_core_reg (struct reg *reg, uint8_t *buf)
 
static int mips32_verify_pointer (struct command_invocation *cmd, struct mips32_common *mips32)
 
static int mips32_write_core_reg (struct target *target, unsigned int num)
 

Variables

const struct command_registration mips32_command_handlers []
 
struct {
   const char *   name
 
mips32_dsp_regs [MIPS32NUMDSPREGS]
 
static const struct command_registration mips32_exec_command_handlers []
 
static const struct reg_arch_type mips32_reg_type
 
struct {
   const char *   feature
 
   const char *   group
 
   unsigned   id
 
   const char *   name
 
   int   size
 
   enum reg_type   type
 
mips32_regs []
 
static const char * mips_isa_strings []
 

Macro Definition Documentation

◆ a0

#define a0   4

Definition at line 172 of file mips32.c.

◆ a1

#define a1   5

Definition at line 173 of file mips32.c.

◆ a2

#define a2   6

Definition at line 174 of file mips32.c.

◆ a3

#define a3   7

Definition at line 175 of file mips32.c.

◆ AT

#define AT   1

Definition at line 167 of file mips32.c.

◆ fp

#define fp   30

Definition at line 207 of file mips32.c.

◆ gp

#define gp   28

Definition at line 204 of file mips32.c.

◆ k0

#define k0   26

Definition at line 201 of file mips32.c.

◆ k1

#define k1   27

Definition at line 202 of file mips32.c.

◆ MIPS32_GDB_FP_REG

#define MIPS32_GDB_FP_REG   1

Definition at line 30 of file mips32.c.

◆ MIPS32_NUM_REGS

#define MIPS32_NUM_REGS   ARRAY_SIZE(mips32_regs)

Definition at line 161 of file mips32.c.

◆ ra

#define ra   31

Definition at line 208 of file mips32.c.

◆ s0

#define s0   16

Definition at line 189 of file mips32.c.

◆ s1

#define s1   17

Definition at line 190 of file mips32.c.

◆ s2

#define s2   18

Definition at line 191 of file mips32.c.

◆ s3

#define s3   19

Definition at line 192 of file mips32.c.

◆ s4

#define s4   20

Definition at line 193 of file mips32.c.

◆ s5

#define s5   21

Definition at line 194 of file mips32.c.

◆ s6

#define s6   22

Definition at line 195 of file mips32.c.

◆ s7

#define s7   23

Definition at line 196 of file mips32.c.

◆ s8

#define s8   30 /* == fp */

Definition at line 197 of file mips32.c.

◆ sp

#define sp   29

Definition at line 206 of file mips32.c.

◆ t0

#define t0   8

Definition at line 176 of file mips32.c.

◆ t1

#define t1   9

Definition at line 177 of file mips32.c.

◆ t2

#define t2   10

Definition at line 178 of file mips32.c.

◆ t3

#define t3   11

Definition at line 179 of file mips32.c.

◆ t4

#define t4   12

Definition at line 180 of file mips32.c.

◆ t5

#define t5   13

Definition at line 181 of file mips32.c.

◆ t6

#define t6   14

Definition at line 182 of file mips32.c.

◆ t7

#define t7   15

Definition at line 183 of file mips32.c.

◆ t8

#define t8   24

Definition at line 199 of file mips32.c.

◆ t9

#define t9   25

Definition at line 200 of file mips32.c.

◆ ta0

#define ta0   12 /* alias for $t4 */

Definition at line 184 of file mips32.c.

◆ ta1

#define ta1   13 /* alias for $t5 */

Definition at line 185 of file mips32.c.

◆ ta2

#define ta2   14 /* alias for $t6 */

Definition at line 186 of file mips32.c.

◆ ta3

#define ta3   15 /* alias for $t7 */

Definition at line 187 of file mips32.c.

◆ v0

#define v0   2

Definition at line 169 of file mips32.c.

◆ v1

#define v1   3

Definition at line 170 of file mips32.c.

◆ zero

#define zero   0

Definition at line 165 of file mips32.c.

Function Documentation

◆ COMMAND_HANDLER() [1/5]

COMMAND_HANDLER ( mips32_handle_cp0_command  )

mips32_handle_cp0_command - Handle commands related to CP0 registers.

@cmd: Command invocation context.

Orchestrates different operations on CP0 registers based on the command arguments. Supports operations like reading all registers, reading/writing a specific register by name or number.

Return: ERROR_OK on success; error code on failure.

Definition at line 1638 of file mips32.c.

References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, CMD_NAME, command_print(), mips32_common::cp0_mask, mips32_common::ejtag_info, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, get_current_target(), mips32_cp0_get_all_regs(), mips32_cp0_get_reg_by_name(), mips32_cp0_get_reg_by_number(), mips32_cp0_set_reg_by_name(), mips32_cp0_set_reg_by_number(), mips32_verify_pointer(), target::state, TARGET_HALTED, and target_to_mips32().

◆ COMMAND_HANDLER() [2/5]

◆ COMMAND_HANDLER() [3/5]

COMMAND_HANDLER ( mips32_handle_dsp_command  )

mips32_handle_dsp_command - Handles mips dsp related command

Parameters
[in]cmdCommand invocation context

Reads or sets the content of each dsp register.

Returns
ERROR_OK on success; error code on failure.

Definition at line 2191 of file mips32.c.

References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, CMD_NAME, command_print(), mips32_common::dsp_imp, mips32_common::ejtag_info, ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, get_current_target(), mips32_dsp_get_all_regs(), mips32_dsp_get_register(), mips32_dsp_set_register(), mips32_verify_pointer(), target::state, TARGET_HALTED, and target_to_mips32().

◆ COMMAND_HANDLER() [4/5]

COMMAND_HANDLER ( mips32_handle_ejtag_reg_command  )

mips32_handle_ejtag_reg_command - Handler commands related to EJTAG

Parameters
[in]cmdCommand invocation context

Prints all EJTAG Registers including DCR features.

Returns
ERROR_OK on success; error code on failure.

Definition at line 2250 of file mips32.c.

References BIT, bit(), CMD, CMD_CTX, command_print(), dcr_features, mips_ejtag::ejtag_ctrl, EJTAG_DCR, EJTAG_DCR_ENTRIES, mips32_common::ejtag_info, EJTAG_INST_CONTROL, ejtag_main_print_imp(), ERROR_OK, get_current_target(), mips_ejtag::idcode, mips_ejtag::impcode, mips_ejtag_drscan_32(), mips_ejtag_get_idcode(), mips_ejtag_get_impcode(), mips_ejtag_set_instr(), name, target_read_u32(), and target_to_mips32().

◆ COMMAND_HANDLER() [5/5]

COMMAND_HANDLER ( mips32_handle_scan_delay_command  )

mips32_handle_scan_delay_command - Handler command for changing scan delay

Parameters
[in]cmdCommand invocation context

Changes current scan mode between legacy and fast queued mode.

Returns
ERROR_OK on success; error code on failure.

Definition at line 2305 of file mips32.c.

References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, COMMAND_PARSE_NUMBER, command_print(), mips32_common::ejtag_info, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, get_current_target(), MIPS32_SCAN_DELAY_LEGACY_MODE, mips_ejtag::mode, mips_ejtag::scan_delay, and target_to_mips32().

◆ mips32_arch_state()

◆ mips32_blank_check_memory()

◆ mips32_build_reg_cache()

◆ mips32_checksum_memory()

◆ mips32_configure_break_unit()

◆ mips32_configure_dbs()

◆ mips32_configure_ibs()

◆ mips32_cp0_find_register_by_name()

static const struct mips32_cp0* mips32_cp0_find_register_by_name ( uint32_t  cp0_mask,
const char *  reg_name 
)
static

mips32_cp0_find_register_by_name - Find CP0 register by its name.

Parameters
[in]cp0_maskMask to filter out irrelevant registers.
[in]reg_nameName of the register to find.

This function iterates through mips32_cp0_regs to find a register matching reg_name, considering cp0_mask to filter out registers not relevant for the current core.

Returns
Pointer to the found register, or NULL if not found.

Definition at line 1418 of file mips32.c.

References mips32_cp0::core, mips32_cp0_regs, MIPS32NUMCP0REGS, name, and NULL.

Referenced by mips32_cp0_get_reg_by_name(), and mips32_cp0_set_reg_by_name().

◆ mips32_cp0_get_all_regs()

static int mips32_cp0_get_all_regs ( struct command_invocation cmd,
struct mips_ejtag ejtag_info,
uint32_t  cp0_mask 
)
static

mips32_cp0_get_all_regs - Print all CP0 registers and their values.

Parameters
[in]cmdCommand invocation context.
[in]ejtag_infoEJTAG interface information.
[in]cp0_maskMask to identify relevant registers.

Iterates over all CP0 registers, reads their values, and prints them. Only considers registers relevant to the current core, as defined by cp0_mask.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1442 of file mips32.c.

References CMD, command_print(), mips32_cp0::core, ERROR_OK, mips32_cp0_read(), mips32_cp0_regs, MIPS32NUMCP0REGS, name, and mips32_cp0::sel.

Referenced by COMMAND_HANDLER().

◆ mips32_cp0_get_reg_by_name()

static int mips32_cp0_get_reg_by_name ( struct command_invocation cmd,
struct mips_ejtag ejtag_info,
uint32_t  cp0_mask 
)
static

mips32_cp0_get_reg_by_name - Read and print a CP0 register's value by name.

Parameters
[in]cmdCommand invocation context.
[in]ejtag_infoEJTAG interface information.
[in]cp0_maskMask to identify relevant registers.

Finds a CP0 register by name, reads its value, and prints it. Handles error scenarios like register not found or read failure.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1473 of file mips32.c.

References CMD, CMD_ARGV, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_OK, mips32_cp0_find_register_by_name(), mips32_cp0_read(), mips32_cp0::reg, and mips32_cp0::sel.

Referenced by COMMAND_HANDLER().

◆ mips32_cp0_get_reg_by_number()

static int mips32_cp0_get_reg_by_number ( struct command_invocation cmd,
struct mips_ejtag ejtag_info 
)
static

mips32_cp0_get_reg_by_number - Read and print a CP0 register's value by number.

Parameters
[in]cmdCommand invocation context.
[in]ejtag_infoEJTAG interface information.

Reads a specific CP0 register (identified by number and selection) and prints its value. The register number and selection are parsed from the command arguments.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1503 of file mips32.c.

References CMD, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and mips32_cp0_read().

Referenced by COMMAND_HANDLER().

◆ mips32_cp0_set_reg_by_name()

static int mips32_cp0_set_reg_by_name ( struct command_invocation cmd,
struct mips32_common mips32,
struct mips_ejtag ejtag_info 
)
static

mips32_cp0_set_reg_by_name - Write to a CP0 register identified by name.

Parameters
[in]cmdCommand invocation context.
[in]mips32Common MIPS32 data structure.
[in]ejtag_infoEJTAG interface information.

Writes a value to a CP0 register specified by name. Updates internal cache if specific registers (STATUS, CAUSE, DEPC, GUESTCTL1) are modified.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1533 of file mips32.c.

References CMD, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), mips32_common::core_cache, mips32_common::core_regs, mips32_core_regs::cp0, mips32_common::cp0_mask, reg::dirty, ERROR_COMMAND_ARGUMENT_INVALID, ERROR_OK, MIPS32_C0_CAUSE, MIPS32_C0_DEPC, MIPS32_C0_GUESTCTL1, MIPS32_C0_STATUS, mips32_cp0_find_register_by_name(), mips32_cp0_write(), MIPS32_REG_C0_CAUSE_INDEX, MIPS32_REG_C0_GUESTCTL1_INDEX, MIPS32_REG_C0_PC_INDEX, MIPS32_REG_C0_STATUS_INDEX, MIPS32_REGLIST_C0_CAUSE_INDEX, MIPS32_REGLIST_C0_GUESTCTL1_INDEX, MIPS32_REGLIST_C0_PC_INDEX, MIPS32_REGLIST_C0_STATUS_INDEX, mips32_cp0::reg, reg_cache::reg_list, and mips32_cp0::sel.

Referenced by COMMAND_HANDLER().

◆ mips32_cp0_set_reg_by_number()

static int mips32_cp0_set_reg_by_number ( struct command_invocation cmd,
struct mips32_common mips32,
struct mips_ejtag ejtag_info 
)
static

mips32_cp0_set_reg_by_number - Write to a CP0 register identified by number.

Parameters
[in]cmdCommand invocation context.
[in]mips32Common MIPS32 data structure.
[in]ejtag_infoEJTAG interface information.

Writes a value to a CP0 register specified by number and selection. Handles special cases like updating the internal cache for certain registers.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1589 of file mips32.c.

References CMD, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), mips32_common::core_cache, mips32_common::core_regs, mips32_core_regs::cp0, reg::dirty, ERROR_OK, MIPS32_C0_CAUSE, MIPS32_C0_DEPC, MIPS32_C0_GUESTCTL1, MIPS32_C0_STATUS, mips32_cp0_write(), MIPS32_REG_C0_CAUSE_INDEX, MIPS32_REG_C0_GUESTCTL1_INDEX, MIPS32_REG_C0_PC_INDEX, MIPS32_REG_C0_STATUS_INDEX, MIPS32_REGLIST_C0_CAUSE_INDEX, MIPS32_REGLIST_C0_GUESTCTL1_INDEX, MIPS32_REGLIST_C0_PC_INDEX, MIPS32_REGLIST_C0_STATUS_INDEX, and reg_cache::reg_list.

Referenced by COMMAND_HANDLER().

◆ mips32_cpu_get_release()

static int mips32_cpu_get_release ( struct mips_ejtag ejtag_info)
static

◆ mips32_cpu_is_lexra()

static bool mips32_cpu_is_lexra ( struct mips_ejtag ejtag_info)
static

Definition at line 919 of file mips32.c.

References mips_ejtag::prid, PRID_COMP_LEXRA, and PRID_COMP_MASK.

Referenced by mips32_cpu_support_sync().

◆ mips32_cpu_probe()

int mips32_cpu_probe ( struct target target)

mips32_cpu_probe - Detects processor type and applies necessary quirks.

Parameters
[in]targetThe target CPU to probe.

This function probes the CPU, reads its PRID (Processor ID), and determines the CPU type. It applies any quirks necessary for specific processor types.

NOTE: The proper detection of certain CPUs can become quite complicated. Please consult the following Linux kernel code when adding new CPUs: arch/mips/include/asm/cpu.h arch/mips/kernel/cpu-probe.c

Returns
ERROR_OK on success; error code on failure.

Definition at line 971 of file mips32.c.

References mips32_common::cp0_mask, mips32_common::cpu_info, cpu_entry::cpu_name, mips32_common::cpu_quirks, EJTAG_QUIRK_PAD_DRET, ERROR_OK, LOG_DEBUG, mips32_find_cpu_by_prid(), mips32_read_c0_prid(), MIPS_CP0_IAPTIV, MIPS_CP0_MAPTIV_UC, MIPS_CP0_MAPTIV_UP, MIPS_CP0_MK4, cpu_entry::prid, mips32_common::prid, PRID_COMP_INGENIC_E1, PRID_COMP_MASK, PRID_COMP_MTI, PRID_IMP_IAPTIV, PRID_IMP_IAPTIV_CM, PRID_IMP_M5150, PRID_IMP_MAPTIV_UC, PRID_IMP_MAPTIV_UP, PRID_IMP_MASK, PRID_IMP_XBURST_REV1, and target_to_mips32().

Referenced by mips_m4k_debug_entry().

◆ mips32_cpu_support_hazard_barrier()

bool mips32_cpu_support_hazard_barrier ( struct mips_ejtag ejtag_info)

mips32_cpu_support_hazard_barrier - Checks CPU supports hazard barrier

Parameters
[in]ejtag_infoMIPS EJTAG information structure.

hazard barrier instructions EHB and *.HB was introduced to MIPS from release 2.

Returns
true if current CPU supports hazard barrier(release > 1)

Definition at line 952 of file mips32.c.

References mips32_cpu_get_release(), and MIPS32_RELEASE_1.

Referenced by mips32_cp0_read(), mips32_cp0_write(), mips32_pracc_fastdata_xfer(), mips32_pracc_write_mem(), and mips32_pracc_write_regs().

◆ mips32_cpu_support_sync()

bool mips32_cpu_support_sync ( struct mips_ejtag ejtag_info)

mips32_cpu_support_sync - Checks CPU supports ordering

Parameters
[in]ejtag_infoMIPS EJTAG information structure.

MIPS ISA implemented on Lexra CPUs is MIPS-I, similar to R3000, which does not have the SYNC instruction alone with unaligned load/store instructions.

Returns
true if current CPU supports sync instruction(CPU is not Lexra)

Definition at line 939 of file mips32.c.

References mips32_cpu_is_lexra().

Referenced by mips32_pracc_fastdata_xfer(), mips32_pracc_read_mem(), mips32_pracc_read_u32(), and mips32_pracc_write_mem().

◆ mips32_detect_fpr_mode_change()

static void mips32_detect_fpr_mode_change ( struct mips32_common mips32,
uint32_t  cp0_status 
)
static

mips32_detect_fpr_mode_change - Detect changes in floating-point register mode

Parameters
[in]mips32MIPS32 common structure
[in]cp0_statusValue of the CP0 status register

Detects changes in the floating-point register mode based on the CP0 status register. If changes are detected, it updates the internal state and logs a warning message indicating the mode change.

Definition at line 293 of file mips32.c.

References BIT, mips32_common::fp_imp, mips32_common::fpu_enabled, mips32_common::fpu_in_64bit, LOG_WARNING, MIPS32_CP0_STATUS_CU1_SHIFT, MIPS32_CP0_STATUS_FR_SHIFT, and mips32_set_all_fpr_width().

Referenced by mips32_read_core_reg(), and mips32_write_core_reg().

◆ mips32_dsp_enable()

static void mips32_dsp_enable ( struct pracc_queue_info ctx,
int  isa 
)
static

mips32_dsp_enable - Enable access to DSP registers

Parameters
[in]ctxContext information for the pracc queue
[in]isaInstruction Set Architecture identifier

Enables access to DSP registers by modifying the status register.

This function adds instructions to the context queue for enabling access to DSP registers by modifying the status register.

Definition at line 1691 of file mips32.c.

References mips_ejtag::isa, LOWER16, MIPS32_DSP_ENABLE, MIPS32_ISA_OR, MIPS32_LUI, MIPS32_MFC0, MIPS32_MTC0, MIPS32_ORI, pracc_add(), and UPPER16.

Referenced by mips32_pracc_read_dsp_reg(), and mips32_pracc_write_dsp_reg().

◆ mips32_dsp_find_register_by_name()

static int mips32_dsp_find_register_by_name ( const char *  reg_name)
static

mips32_dsp_find_register_by_name - Find DSP register index by name

Parameters
[in]reg_nameName of the DSP register to find

Searches for a DSP register by name and returns its index. If no match is found, it returns MIPS32NUMDSPREGS.

Returns
Index of the found register or MIPS32NUMDSPREGS if not found.

Definition at line 2090 of file mips32.c.

References mips32_dsp_regs, MIPS32NUMDSPREGS, and name.

Referenced by mips32_dsp_get_register(), and mips32_dsp_set_register().

◆ mips32_dsp_get_all_regs()

static int mips32_dsp_get_all_regs ( struct command_invocation cmd,
struct mips_ejtag ejtag_info 
)
static

mips32_dsp_get_all_regs - Get values of all MIPS32 DSP registers

Parameters
[in]cmdCommand invocation context
[in]ejtag_infoEJTAG information structure

This function iterates through all DSP registers, reads their values, and prints each register name along with its corresponding value.

Returns
ERROR_OK on success; error code on failure.

Definition at line 2110 of file mips32.c.

References CMD, command_print(), ERROR_OK, mips32_dsp_regs, mips32_pracc_read_dsp_reg(), MIPS32NUMDSPREGS, and name.

Referenced by COMMAND_HANDLER().

◆ mips32_dsp_get_register()

static int mips32_dsp_get_register ( struct command_invocation cmd,
struct mips_ejtag ejtag_info 
)
static

mips32_dsp_get_register - Get the value of a MIPS32 DSP register

Parameters
[in]cmdCommand invocation context
[in]ejtag_infoEJTAG information structure

Retrieves the value of a specified MIPS32 DSP register. If the register is found, it reads the register value and prints the result. If the register is not found, it prints an error message.

Returns
ERROR_OK on success; error code on failure.

Definition at line 2135 of file mips32.c.

References CMD, CMD_ARGV, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, mips32_dsp_find_register_by_name(), mips32_pracc_read_dsp_reg(), and MIPS32NUMDSPREGS.

Referenced by COMMAND_HANDLER().

◆ mips32_dsp_restore()

static void mips32_dsp_restore ( struct pracc_queue_info ctx,
int  isa 
)
static

mips32_dsp_restore - Restore DSP status registers to the previous setting

Parameters
[in]ctxContext information pracc queue
[in]isaisa identifier

Restores the DSP status registers to their previous setting.

This function adds instructions to the context queue for restoring the DSP status registers to their values before the operation.

Definition at line 1720 of file mips32.c.

References mips_ejtag::isa, MIPS32_MTC0, MIPS32_NOP, and pracc_add().

Referenced by mips32_pracc_read_dsp_reg(), and mips32_pracc_write_dsp_reg().

◆ mips32_dsp_set_register()

static int mips32_dsp_set_register ( struct command_invocation cmd,
struct mips_ejtag ejtag_info 
)
static

mips32_dsp_set_register - Set the value of a MIPS32 DSP register

Parameters
[in]cmdCommand invocation context
[in]ejtag_infoEJTAG information structure

Sets the value of a specified MIPS32 DSP register. If the register is found, it writes provided value to the register. If the register is not found or there is an error in writing the value, it prints an error message.

Returns
ERROR_OK on success; error code on failure.

Definition at line 2165 of file mips32.c.

References CMD, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, mips32_dsp_find_register_by_name(), mips32_pracc_write_dsp_reg(), and MIPS32NUMDSPREGS.

Referenced by COMMAND_HANDLER().

◆ mips32_enable_interrupts()

int mips32_enable_interrupts ( struct target target,
int  enable 
)

◆ mips32_examine()

◆ mips32_find_cpu_by_prid()

static const struct cpu_entry* mips32_find_cpu_by_prid ( uint32_t  prid)
static

mips32_find_cpu_by_prid - Find CPU information by processor ID.

Parameters
[in]pridProcessor ID of the CPU.

This function looks up the CPU entry in the mips32_cpu_entry array based on the provided processor ID. It also handles special cases like AMD/Alchemy CPUs that use Company Options instead of Processor IDs.

Returns
Pointer to the corresponding cpu_entry struct, or the 'unknown' entry if not found.

Definition at line 896 of file mips32.c.

References MIPS32_CORE_MASK, mips32_cpu_entry, MIPS32_NUM_CPU_ENTRIES, cpu_entry::prid, PRID_COMP_ALCHEMY, and PRID_COMP_MASK.

Referenced by mips32_cpu_probe().

◆ mips32_get_core_reg()

static int mips32_get_core_reg ( struct reg reg)
static

◆ mips32_get_gdb_reg_list()

int mips32_get_gdb_reg_list ( struct target target,
struct reg **  reg_list[],
int *  reg_list_size,
enum target_register_class  reg_class 
)

◆ mips32_init_arch_info()

◆ mips32_pracc_read_dsp_reg()

static int mips32_pracc_read_dsp_reg ( struct mips_ejtag ejtag_info,
uint32_t *  val,
uint32_t  reg 
)
static

mips32_pracc_read_dsp_reg - Read a value from a MIPS32 DSP register

Parameters
[in]ejtag_infoEJTAG information structure
[out]valPointer to store the read value
[in]regIndex of the DSP register to read

Reads the value from the specified MIPS32 DSP register using EJTAG access.

This function initiates a sequence of instructions to read the value from the specified DSP register. It will enable dsp module if its not enabled and restoring the status registers after the read operation.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1740 of file mips32.c.

References pracc_queue_info::code_count, pracc_queue_info::ejtag_info, ERROR_OK, pracc_queue_info::isa, mips_ejtag::isa, LOWER16, pracc_queue_info::max_code, MIPS32_B, mips32_dsp_enable(), MIPS32_DSP_MFHI, MIPS32_DSP_MFLO, MIPS32_DSP_RDDSP, mips32_dsp_restore(), MIPS32_LUI, MIPS32_MFC0, MIPS32_MFHI, MIPS32_MFLO, MIPS32_ORI, MIPS32_PRACC_PARAM_OUT, mips32_pracc_queue_exec(), MIPS32_SW, MIPS32_SYNC, NEG16, NULL, pracc_add(), pracc_queue_info::pracc_list, PRACC_OUT_OFFSET, pracc_queue_free(), pracc_queue_init(), PRACC_UPPER_BASE_ADDR, mips_ejtag::reg8, mips_ejtag::reg9, pracc_queue_info::retval, t0, and UPPER16.

Referenced by mips32_dsp_get_all_regs(), and mips32_dsp_get_register().

◆ mips32_pracc_write_dsp_reg()

static int mips32_pracc_write_dsp_reg ( struct mips_ejtag ejtag_info,
uint32_t  val,
uint32_t  reg 
)
static

mips32_pracc_write_dsp_reg - Write a value to a MIPS32 DSP register

Parameters
[in]ejtag_infoEJTAG information structure
[in]valValue to be written to the register
[in]regIndex of the DSP register to write

Writes the specified value to the specified MIPS32 DSP register.

This function initiates a sequence of instructions to write the given value to the specified DSP register.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1817 of file mips32.c.

References pracc_queue_info::code_count, pracc_queue_info::ejtag_info, ERROR_OK, pracc_queue_info::isa, LOWER16, pracc_queue_info::max_code, MIPS32_B, mips32_dsp_enable(), MIPS32_DSP_MTHI, MIPS32_DSP_MTLO, mips32_dsp_restore(), MIPS32_DSP_WRDSP, MIPS32_LUI, MIPS32_MFC0, MIPS32_MTHI, MIPS32_MTLO, MIPS32_NOP, MIPS32_ORI, mips32_pracc_queue_exec(), NEG16, NULL, pracc_add(), pracc_queue_free(), pracc_queue_init(), mips_ejtag::reg8, mips_ejtag::reg9, pracc_queue_info::retval, t0, and UPPER16.

Referenced by mips32_dsp_set_register().

◆ mips32_read_c0_prid()

static int mips32_read_c0_prid ( struct target target)
static

◆ mips32_read_config_dsp()

static void mips32_read_config_dsp ( struct mips32_common mips32,
struct mips_ejtag ejtag_info 
)
static

◆ mips32_read_config_fdc()

static void mips32_read_config_fdc ( struct mips32_common mips32,
struct mips_ejtag ejtag_info,
uint32_t  dcr 
)
static

mips32_read_config_fdc - Read Fast Debug Channel configuration

Parameters
[in,out]mips32MIPS32 common structure
[in]ejtag_infoEJTAG information structure
[in]dcrDevice Configuration Register value

Checks if the current target implements the Common Device Memory Map (CDMM) and Fast Debug Channel (FDC).

This function examines the configuration registers and the Device Configuration Register (DCR) to determine if the current MIPS32 target supports the Common Device Memory Map (CDMM) and the Fast Debug Channel (FDC). If supported, it sets the corresponding flags in the MIPS32 common structure.
NOTE:These are defined on MD00090, page 67 and MD00047F, page 82, respectively. MIPS Documents are pretty much all available online, it should pop up first when you search "MDxxxxx"

Definition at line 1109 of file mips32.c.

References mips_ejtag::config, EJTAG_DCR_FDC, mips32_common::fdc, MIPS32_CONFIG3_CDMM_MASK, and mips32_common::semihosting.

Referenced by mips32_read_config_regs().

◆ mips32_read_config_fpu()

◆ mips32_read_config_mmu()

static int mips32_read_config_mmu ( struct mips_ejtag ejtag_info)
static

mips32_read_config_mmu - Reads MMU configuration and logs relevant information.

Parameters
[in]ejtag_infoEJTAG interface information.

Reads the MMU configuration from the CP0 register and calculates the number of TLB entries, ways, and sets. Handles different MMU types like VTLB only, root RPU/Fixed, and VTLB and FTLB.

Returns
ERROR_OK on success; error code on failure.

Definition at line 1371 of file mips32.c.

References BIT, mips_ejtag::config, ERROR_OK, LOG_USER, and mips32_cp0_read().

Referenced by COMMAND_HANDLER().

◆ mips32_read_config_regs()

◆ mips32_read_core_reg()

◆ mips32_restore_context()

◆ mips32_run_algorithm()

◆ mips32_run_and_wait()

static int mips32_run_and_wait ( struct target target,
target_addr_t  entry_point,
unsigned int  timeout_ms,
target_addr_t  exit_point,
struct mips32_common mips32 
)
static

◆ mips32_save_context()

◆ mips32_set_all_fpr_width()

static void mips32_set_all_fpr_width ( struct mips32_common mips32,
bool  fp64 
)
static

mips32_set_all_fpr_width - Set the width of all floating-point registers

Parameters
[in]mips32MIPS32 common structure
[in]fp64Flag indicating whether to set the width to 64 bits (double precision)

Sets the width of all floating-point registers based on the specified flag.

Definition at line 272 of file mips32.c.

References mips32_common::core_cache, MIPS32_REG_FP_COUNT, MIPS32_REGLIST_FP_INDEX, reg::reg_data_type, reg_cache::reg_list, REG_TYPE_IEEE_DOUBLE, REG_TYPE_IEEE_SINGLE, reg::size, and reg_data_type::type.

Referenced by mips32_detect_fpr_mode_change(), and mips32_read_config_fpu().

◆ mips32_set_core_reg()

static int mips32_set_core_reg ( struct reg reg,
uint8_t *  buf 
)
static

◆ mips32_verify_pointer()

static int mips32_verify_pointer ( struct command_invocation cmd,
struct mips32_common mips32 
)
static

◆ mips32_write_core_reg()

Variable Documentation

◆ feature

const char* feature

Definition at line 41 of file mips32.c.

Referenced by mips32_build_reg_cache().

◆ group

const char* group

Definition at line 40 of file mips32.c.

◆ id

unsigned id

Definition at line 37 of file mips32.c.

◆ mips32_command_handlers

const struct command_registration mips32_command_handlers[]
Initial value:
= {
{
.name = "mips32",
.mode = COMMAND_ANY,
.help = "mips32 command group",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration mips32_exec_command_handlers[]
Definition: mips32.c:2328

Definition at line 2305 of file mips32.c.

◆ 

const { ... } mips32_dsp_regs[MIPS32NUMDSPREGS]
Initial value:
= {
{ "hi0"},
{ "hi1"},
{ "hi2"},
{ "hi3"},
{ "lo0"},
{ "lo1"},
{ "lo2"},
{ "lo3"},
{ "control"},
}

Referenced by mips32_dsp_find_register_by_name(), and mips32_dsp_get_all_regs().

◆ mips32_exec_command_handlers

const struct command_registration mips32_exec_command_handlers[]
static

Definition at line 2305 of file mips32.c.

◆ mips32_reg_type

const struct reg_arch_type mips32_reg_type
static
Initial value:
= {
}
static int mips32_set_core_reg(struct reg *reg, uint8_t *buf)
Definition: mips32.c:240
static int mips32_get_core_reg(struct reg *reg)
Definition: mips32.c:225

Definition at line 460 of file mips32.c.

Referenced by mips32_build_reg_cache().

◆ 

const { ... } mips32_regs[]

Referenced by mips32_build_reg_cache().

◆ mips_isa_strings

const char* mips_isa_strings[]
static
Initial value:
= {
"MIPS32", "MIPS16", "", "MICRO MIPS32",
}

Definition at line 26 of file mips32.c.

Referenced by mips32_arch_state().

◆ name

◆ size

int size

Definition at line 42 of file mips32.c.

Referenced by mips32_blank_check_memory(), and mips32_run_algorithm().

◆ type

enum reg_type type

Definition at line 38 of file mips32.c.