OpenOCD
armv7m.h File Reference
Include dependency graph for armv7m.h:

Go to the source code of this file.

Data Structures

struct  armv7m_algorithm
 
struct  armv7m_common
 

Macros

#define ARMV7M_COMMON_MAGIC   0x2A452A45U
 
#define ARMV7M_NUM_CORE_REGS   (ARMV7M_CORE_LAST_REG - ARMV7M_CORE_FIRST_REG + 1)
 

Enumerations

enum  {
  ARMV7M_REGSEL_R0 , ARMV7M_REGSEL_R1 , ARMV7M_REGSEL_R2 , ARMV7M_REGSEL_R3 ,
  ARMV7M_REGSEL_R4 , ARMV7M_REGSEL_R5 , ARMV7M_REGSEL_R6 , ARMV7M_REGSEL_R7 ,
  ARMV7M_REGSEL_R8 , ARMV7M_REGSEL_R9 , ARMV7M_REGSEL_R10 , ARMV7M_REGSEL_R11 ,
  ARMV7M_REGSEL_R12 , ARMV7M_REGSEL_R13 , ARMV7M_REGSEL_R14 , ARMV7M_REGSEL_PC = 15 ,
  ARMV7M_REGSEL_XPSR = 16 , ARMV7M_REGSEL_MSP , ARMV7M_REGSEL_PSP , ARMV8M_REGSEL_MSP_NS = 0x18 ,
  ARMV8M_REGSEL_PSP_NS , ARMV8M_REGSEL_MSP_S , ARMV8M_REGSEL_PSP_S , ARMV8M_REGSEL_MSPLIM_S ,
  ARMV8M_REGSEL_PSPLIM_S , ARMV8M_REGSEL_MSPLIM_NS , ARMV8M_REGSEL_PSPLIM_NS , ARMV7M_REGSEL_PMSK_BPRI_FLTMSK_CTRL = 0x14 ,
  ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_S = 0x22 , ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_NS = 0x23 , ARMV7M_REGSEL_FPSCR = 0x21 , ARMV7M_REGSEL_S0 = 0x40 ,
  ARMV7M_REGSEL_S1 , ARMV7M_REGSEL_S2 , ARMV7M_REGSEL_S3 , ARMV7M_REGSEL_S4 ,
  ARMV7M_REGSEL_S5 , ARMV7M_REGSEL_S6 , ARMV7M_REGSEL_S7 , ARMV7M_REGSEL_S8 ,
  ARMV7M_REGSEL_S9 , ARMV7M_REGSEL_S10 , ARMV7M_REGSEL_S11 , ARMV7M_REGSEL_S12 ,
  ARMV7M_REGSEL_S13 , ARMV7M_REGSEL_S14 , ARMV7M_REGSEL_S15 , ARMV7M_REGSEL_S16 ,
  ARMV7M_REGSEL_S17 , ARMV7M_REGSEL_S18 , ARMV7M_REGSEL_S19 , ARMV7M_REGSEL_S20 ,
  ARMV7M_REGSEL_S21 , ARMV7M_REGSEL_S22 , ARMV7M_REGSEL_S23 , ARMV7M_REGSEL_S24 ,
  ARMV7M_REGSEL_S25 , ARMV7M_REGSEL_S26 , ARMV7M_REGSEL_S27 , ARMV7M_REGSEL_S28 ,
  ARMV7M_REGSEL_S29 , ARMV7M_REGSEL_S30 , ARMV7M_REGSEL_S31
}
 
enum  {
  ARMV7M_R0 = ARMV7M_REGSEL_R0 , ARMV7M_R1 = ARMV7M_REGSEL_R1 , ARMV7M_R2 = ARMV7M_REGSEL_R2 , ARMV7M_R3 = ARMV7M_REGSEL_R3 ,
  ARMV7M_R4 = ARMV7M_REGSEL_R4 , ARMV7M_R5 = ARMV7M_REGSEL_R5 , ARMV7M_R6 = ARMV7M_REGSEL_R6 , ARMV7M_R7 = ARMV7M_REGSEL_R7 ,
  ARMV7M_R8 = ARMV7M_REGSEL_R8 , ARMV7M_R9 = ARMV7M_REGSEL_R9 , ARMV7M_R10 = ARMV7M_REGSEL_R10 , ARMV7M_R11 = ARMV7M_REGSEL_R11 ,
  ARMV7M_R12 = ARMV7M_REGSEL_R12 , ARMV7M_R13 = ARMV7M_REGSEL_R13 , ARMV7M_R14 = ARMV7M_REGSEL_R14 , ARMV7M_PC = ARMV7M_REGSEL_PC ,
  ARMV7M_XPSR = ARMV7M_REGSEL_XPSR , ARMV7M_MSP = ARMV7M_REGSEL_MSP , ARMV7M_PSP = ARMV7M_REGSEL_PSP , ARMV7M_PMSK_BPRI_FLTMSK_CTRL ,
  ARMV7M_PRIMASK , ARMV7M_BASEPRI , ARMV7M_FAULTMASK , ARMV7M_CONTROL ,
  ARMV8M_MSP_NS , ARMV8M_PSP_NS , ARMV8M_MSP_S , ARMV8M_PSP_S ,
  ARMV8M_MSPLIM_S , ARMV8M_PSPLIM_S , ARMV8M_MSPLIM_NS , ARMV8M_PSPLIM_NS ,
  ARMV8M_PMSK_BPRI_FLTMSK_CTRL_S , ARMV8M_PRIMASK_S , ARMV8M_BASEPRI_S , ARMV8M_FAULTMASK_S ,
  ARMV8M_CONTROL_S , ARMV8M_PMSK_BPRI_FLTMSK_CTRL_NS , ARMV8M_PRIMASK_NS , ARMV8M_BASEPRI_NS ,
  ARMV8M_FAULTMASK_NS , ARMV8M_CONTROL_NS , ARMV7M_D0 , ARMV7M_D1 ,
  ARMV7M_D2 , ARMV7M_D3 , ARMV7M_D4 , ARMV7M_D5 ,
  ARMV7M_D6 , ARMV7M_D7 , ARMV7M_D8 , ARMV7M_D9 ,
  ARMV7M_D10 , ARMV7M_D11 , ARMV7M_D12 , ARMV7M_D13 ,
  ARMV7M_D14 , ARMV7M_D15 , ARMV7M_FPSCR , ARMV7M_LAST_REG ,
  ARMV7M_CORE_FIRST_REG = ARMV7M_R0 , ARMV7M_CORE_LAST_REG = ARMV7M_XPSR , ARMV7M_FPU_FIRST_REG = ARMV7M_D0 , ARMV7M_FPU_LAST_REG = ARMV7M_FPSCR ,
  ARMV8M_FIRST_REG = ARMV8M_MSP_NS , ARMV8M_LAST_REG = ARMV8M_CONTROL_NS
}
 
enum  {
  FP_NONE = 0 , FPV4_SP , FPV5_SP , FPV5_DP ,
  FPV5_MVE_I , FPV5_MVE_F
}
 

Functions

int armv7m_arch_state (struct target *target)
 Logs summary of ARMv7-M state for a halted target. More...
 
int armv7m_blank_check_memory (struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
 Checks an array of memory regions whether they are erased. More...
 
struct reg_cachearmv7m_build_reg_cache (struct target *target)
 Builds cache of architecturally defined registers. More...
 
int armv7m_checksum_memory (struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
 Generates a CRC32 checksum of a memory region. More...
 
const char * armv7m_exception_string (int number)
 Maps ISR number (from xPSR) to name. More...
 
void armv7m_free_reg_cache (struct target *target)
 
int armv7m_get_gdb_reg_list (struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
 Returns generic ARM userspace registers to GDB. More...
 
int armv7m_init_arch_info (struct target *target, struct armv7m_common *armv7m)
 Sets up target as a generic ARMv7-M core. More...
 
int armv7m_invalidate_core_regs (struct target *target)
 
uint32_t armv7m_map_id_to_regsel (unsigned int arm_reg_id)
 
bool armv7m_map_reg_packing (unsigned int arm_reg_id, unsigned int *reg32_id, uint32_t *offset)
 
int armv7m_maybe_skip_bkpt_inst (struct target *target, bool *inst_found)
 
int armv7m_mode_to_number (enum armv7m_mode mode)
 
enum armv7m_mode armv7m_number_to_mode (int number)
 
int armv7m_restore_context (struct target *target)
 Restores target context using the cache of core registers set up by armv7m_build_reg_cache(), calling optional core-specific hooks. More...
 
int armv7m_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)
 Runs a Thumb algorithm in the target. More...
 
int armv7m_start_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, void *arch_info)
 Starts a Thumb algorithm in the target. More...
 
int armv7m_wait_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 exit_point, unsigned int timeout_ms, void *arch_info)
 Waits for an algorithm in the target. More...
 
static bool is_armv7m (const struct armv7m_common *armv7m)
 
static struct armv7m_commontarget_to_armv7m (struct target *target)
 
static struct armv7m_commontarget_to_armv7m_safe (struct target *target)
 

Variables

const struct command_registration armv7m_command_handlers []
 
const int armv7m_msp_reg_map []
 
const int armv7m_psp_reg_map []
 

Macro Definition Documentation

◆ ARMV7M_COMMON_MAGIC

#define ARMV7M_COMMON_MAGIC   0x2A452A45U

Definition at line 220 of file armv7m.h.

◆ ARMV7M_NUM_CORE_REGS

#define ARMV7M_NUM_CORE_REGS   (ARMV7M_CORE_LAST_REG - ARMV7M_CORE_FIRST_REG + 1)

Definition at line 218 of file armv7m.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ARMV7M_REGSEL_R0 
ARMV7M_REGSEL_R1 
ARMV7M_REGSEL_R2 
ARMV7M_REGSEL_R3 
ARMV7M_REGSEL_R4 
ARMV7M_REGSEL_R5 
ARMV7M_REGSEL_R6 
ARMV7M_REGSEL_R7 
ARMV7M_REGSEL_R8 
ARMV7M_REGSEL_R9 
ARMV7M_REGSEL_R10 
ARMV7M_REGSEL_R11 
ARMV7M_REGSEL_R12 
ARMV7M_REGSEL_R13 
ARMV7M_REGSEL_R14 
ARMV7M_REGSEL_PC 
ARMV7M_REGSEL_XPSR 
ARMV7M_REGSEL_MSP 
ARMV7M_REGSEL_PSP 
ARMV8M_REGSEL_MSP_NS 
ARMV8M_REGSEL_PSP_NS 
ARMV8M_REGSEL_MSP_S 
ARMV8M_REGSEL_PSP_S 
ARMV8M_REGSEL_MSPLIM_S 
ARMV8M_REGSEL_PSPLIM_S 
ARMV8M_REGSEL_MSPLIM_NS 
ARMV8M_REGSEL_PSPLIM_NS 
ARMV7M_REGSEL_PMSK_BPRI_FLTMSK_CTRL 
ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_S 
ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_NS 
ARMV7M_REGSEL_FPSCR 
ARMV7M_REGSEL_S0 
ARMV7M_REGSEL_S1 
ARMV7M_REGSEL_S2 
ARMV7M_REGSEL_S3 
ARMV7M_REGSEL_S4 
ARMV7M_REGSEL_S5 
ARMV7M_REGSEL_S6 
ARMV7M_REGSEL_S7 
ARMV7M_REGSEL_S8 
ARMV7M_REGSEL_S9 
ARMV7M_REGSEL_S10 
ARMV7M_REGSEL_S11 
ARMV7M_REGSEL_S12 
ARMV7M_REGSEL_S13 
ARMV7M_REGSEL_S14 
ARMV7M_REGSEL_S15 
ARMV7M_REGSEL_S16 
ARMV7M_REGSEL_S17 
ARMV7M_REGSEL_S18 
ARMV7M_REGSEL_S19 
ARMV7M_REGSEL_S20 
ARMV7M_REGSEL_S21 
ARMV7M_REGSEL_S22 
ARMV7M_REGSEL_S23 
ARMV7M_REGSEL_S24 
ARMV7M_REGSEL_S25 
ARMV7M_REGSEL_S26 
ARMV7M_REGSEL_S27 
ARMV7M_REGSEL_S28 
ARMV7M_REGSEL_S29 
ARMV7M_REGSEL_S30 
ARMV7M_REGSEL_S31 

Definition at line 28 of file armv7m.h.

◆ anonymous enum

anonymous enum
Enumerator
ARMV7M_R0 
ARMV7M_R1 
ARMV7M_R2 
ARMV7M_R3 
ARMV7M_R4 
ARMV7M_R5 
ARMV7M_R6 
ARMV7M_R7 
ARMV7M_R8 
ARMV7M_R9 
ARMV7M_R10 
ARMV7M_R11 
ARMV7M_R12 
ARMV7M_R13 
ARMV7M_R14 
ARMV7M_PC 
ARMV7M_XPSR 
ARMV7M_MSP 
ARMV7M_PSP 
ARMV7M_PMSK_BPRI_FLTMSK_CTRL 
ARMV7M_PRIMASK 
ARMV7M_BASEPRI 
ARMV7M_FAULTMASK 
ARMV7M_CONTROL 
ARMV8M_MSP_NS 
ARMV8M_PSP_NS 
ARMV8M_MSP_S 
ARMV8M_PSP_S 
ARMV8M_MSPLIM_S 
ARMV8M_PSPLIM_S 
ARMV8M_MSPLIM_NS 
ARMV8M_PSPLIM_NS 
ARMV8M_PMSK_BPRI_FLTMSK_CTRL_S 
ARMV8M_PRIMASK_S 
ARMV8M_BASEPRI_S 
ARMV8M_FAULTMASK_S 
ARMV8M_CONTROL_S 
ARMV8M_PMSK_BPRI_FLTMSK_CTRL_NS 
ARMV8M_PRIMASK_NS 
ARMV8M_BASEPRI_NS 
ARMV8M_FAULTMASK_NS 
ARMV8M_CONTROL_NS 
ARMV7M_D0 
ARMV7M_D1 
ARMV7M_D2 
ARMV7M_D3 
ARMV7M_D4 
ARMV7M_D5 
ARMV7M_D6 
ARMV7M_D7 
ARMV7M_D8 
ARMV7M_D9 
ARMV7M_D10 
ARMV7M_D11 
ARMV7M_D12 
ARMV7M_D13 
ARMV7M_D14 
ARMV7M_D15 
ARMV7M_FPSCR 
ARMV7M_LAST_REG 
ARMV7M_CORE_FIRST_REG 
ARMV7M_CORE_LAST_REG 
ARMV7M_FPU_FIRST_REG 
ARMV7M_FPU_LAST_REG 
ARMV8M_FIRST_REG 
ARMV8M_LAST_REG 

Definition at line 103 of file armv7m.h.

◆ anonymous enum

anonymous enum
Enumerator
FP_NONE 
FPV4_SP 
FPV5_SP 
FPV5_DP 
FPV5_MVE_I 
FPV5_MVE_F 

Definition at line 209 of file armv7m.h.

Function Documentation

◆ armv7m_arch_state()

◆ armv7m_blank_check_memory()

◆ armv7m_build_reg_cache()

◆ armv7m_checksum_memory()

◆ armv7m_exception_string()

const char* armv7m_exception_string ( int  number)

Maps ISR number (from xPSR) to name.

Note that while names and meanings for the first sixteen are standardized (with zero not a true exception), external interrupts are only numbered. They are assigned by vendors, which generally assign different numbers to peripherals (such as UART0 or a USB peripheral controller).

Definition at line 204 of file armv7m.c.

References armv7m_exception_strings, and number.

Referenced by armv7m_arch_state(), and cortex_m_examine_exception_reason().

◆ armv7m_free_reg_cache()

void armv7m_free_reg_cache ( struct target target)

◆ armv7m_get_gdb_reg_list()

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

Returns generic ARM userspace registers to GDB.

Definition at line 459 of file armv7m.c.

References armv7m_common::arm, ARMV7M_NUM_CORE_REGS, arm::core_cache, ERROR_FAIL, ERROR_OK, reg_cache::num_regs, REG_CLASS_ALL, reg_cache::reg_list, size, and target_to_armv7m().

◆ armv7m_init_arch_info()

◆ armv7m_invalidate_core_regs()

int armv7m_invalidate_core_regs ( struct target target)

◆ armv7m_map_id_to_regsel()

◆ armv7m_map_reg_packing()

bool armv7m_map_reg_packing ( unsigned int  arm_reg_id,
unsigned int *  reg32_id,
uint32_t *  offset 
)

◆ armv7m_maybe_skip_bkpt_inst()

int armv7m_maybe_skip_bkpt_inst ( struct target target,
bool *  inst_found 
)

Definition at line 1065 of file armv7m.c.

Referenced by adapter_resume(), adapter_step(), cortex_m_restore_one(), and cortex_m_step().

◆ armv7m_mode_to_number()

int armv7m_mode_to_number ( enum armv7m_mode  mode)

◆ armv7m_number_to_mode()

enum armv7m_mode armv7m_number_to_mode ( int  number)

◆ armv7m_restore_context()

int armv7m_restore_context ( struct target target)

Restores target context using the cache of core registers set up by armv7m_build_reg_cache(), calling optional core-specific hooks.

Definition at line 168 of file armv7m.c.

References armv7m_common::arm, ARM_MODE_ANY, arm::core_cache, reg::dirty, ERROR_OK, reg::exist, LOG_DEBUG, reg_cache::num_regs, armv7m_common::pre_restore_context, reg_cache::reg_list, target_to_armv7m(), reg::value, and arm::write_core_reg.

Referenced by adapter_resume(), adapter_step(), cortex_m_restore_one(), and cortex_m_step().

◆ armv7m_run_algorithm()

int armv7m_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 
)

Runs a Thumb algorithm in the target.

Definition at line 483 of file armv7m.c.

References armv7m_start_algorithm(), armv7m_wait_algorithm(), and ERROR_OK.

◆ armv7m_start_algorithm()

◆ armv7m_wait_algorithm()

◆ is_armv7m()

◆ target_to_armv7m()

static struct armv7m_common* target_to_armv7m ( struct target target)
inlinestatic

◆ target_to_armv7m_safe()

static struct armv7m_common* target_to_armv7m_safe ( struct target target)
inlinestatic
Returns
the pointer to the target specific struct or NULL if the magic number does not match. Use in a flash driver or any place where mismatch of the arch_info type can happen.

Definition at line 274 of file armv7m.h.

References target::arch_info, is_arm(), is_armv7m(), NULL, target_to_arm(), and target_to_armv7m().

Referenced by cortex_m_get_impl_part(), stm32l4_probe(), and stm32l4_read_idcode().

Variable Documentation

◆ armv7m_command_handlers

const struct command_registration armv7m_command_handlers[]
extern

Definition at line 1065 of file armv7m.c.

◆ armv7m_msp_reg_map

const int armv7m_msp_reg_map[]
extern

Definition at line 60 of file armv7m.c.

Referenced by adapter_debug_entry(), and cortex_m_debug_entry().

◆ armv7m_psp_reg_map

const int armv7m_psp_reg_map[]
extern

Definition at line 51 of file armv7m.c.

Referenced by adapter_debug_entry(), and cortex_m_debug_entry().