OpenOCD
arm.h File Reference

Holds the interface to ARM cores. More...

Include dependency graph for arm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arm
 Represents a generic ARM core, with standard application registers. More...
 
struct  arm_algorithm
 
struct  arm_reg
 

Macros

#define ARM_COMMON_MAGIC   0x0A450A45U
 

Enumerations

enum  {
  ARM_VFP_V3_D0 = 51 , ARM_VFP_V3_D1 , ARM_VFP_V3_D2 , ARM_VFP_V3_D3 ,
  ARM_VFP_V3_D4 , ARM_VFP_V3_D5 , ARM_VFP_V3_D6 , ARM_VFP_V3_D7 ,
  ARM_VFP_V3_D8 , ARM_VFP_V3_D9 , ARM_VFP_V3_D10 , ARM_VFP_V3_D11 ,
  ARM_VFP_V3_D12 , ARM_VFP_V3_D13 , ARM_VFP_V3_D14 , ARM_VFP_V3_D15 ,
  ARM_VFP_V3_D16 , ARM_VFP_V3_D17 , ARM_VFP_V3_D18 , ARM_VFP_V3_D19 ,
  ARM_VFP_V3_D20 , ARM_VFP_V3_D21 , ARM_VFP_V3_D22 , ARM_VFP_V3_D23 ,
  ARM_VFP_V3_D24 , ARM_VFP_V3_D25 , ARM_VFP_V3_D26 , ARM_VFP_V3_D27 ,
  ARM_VFP_V3_D28 , ARM_VFP_V3_D29 , ARM_VFP_V3_D30 , ARM_VFP_V3_D31 ,
  ARM_VFP_V3_FPSCR
}
 
enum  arm_arch {
  ARM_ARCH_UNKNOWN , ARM_ARCH_V4 , ARM_ARCH_V6M , ARM_ARCH_V7M ,
  ARM_ARCH_V8M
}
 ARM Architecture specifying the version and the profile. More...
 
enum  arm_core_type { ARM_CORE_TYPE_STD = -1 , ARM_CORE_TYPE_SEC_EXT = 1 , ARM_CORE_TYPE_VIRT_EXT , ARM_CORE_TYPE_M_PROFILE }
 Indicates what registers are in the ARM state core register set. More...
 
enum  arm_implementer { ARM_IMPLEMENTER_ARM = 0x41 , ARM_IMPLEMENTER_INFINEON = 0x49 , ARM_IMPLEMENTER_ARM_CHINA = 0x63 , ARM_IMPLEMENTER_REALTEK = 0x72 }
 Known ARM implementer IDs. More...
 
enum  arm_mode {
  ARM_MODE_USR = 16 , ARM_MODE_FIQ = 17 , ARM_MODE_IRQ = 18 , ARM_MODE_SVC = 19 ,
  ARM_MODE_MON = 22 , ARM_MODE_ABT = 23 , ARM_MODE_HYP = 26 , ARM_MODE_UND = 27 ,
  ARM_MODE_1176_MON = 28 , ARM_MODE_SYS = 31 , ARM_MODE_THREAD = 0 , ARM_MODE_USER_THREAD = 1 ,
  ARM_MODE_HANDLER = 2 , ARMV8_64_EL0T = 0x0 , ARMV8_64_EL1T = 0x4 , ARMV8_64_EL1H = 0x5 ,
  ARMV8_64_EL2T = 0x8 , ARMV8_64_EL2H = 0x9 , ARMV8_64_EL3T = 0xC , ARMV8_64_EL3H = 0xD ,
  ARM_MODE_ANY = -1
}
 Represent state of an ARM core. More...
 
enum  arm_state {
  ARM_STATE_ARM , ARM_STATE_THUMB , ARM_STATE_JAZELLE , ARM_STATE_THUMB_EE ,
  ARM_STATE_AARCH64
}
 The PSR "T" and "J" bits define the mode of "classic ARM" cores. More...
 
enum  arm_vfp_version { ARM_VFP_DISABLED , ARM_VFP_V1 , ARM_VFP_V2 , ARM_VFP_V3 }
 ARM vector floating point enabled, if yes which version. More...
 

Functions

int arm_arch_state (struct target *target)
 
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. More...
 
struct reg_cachearm_build_reg_cache (struct target *target, struct arm *arm)
 
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. More...
 
void arm_free_reg_cache (struct arm *arm)
 
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)
 
int arm_init_arch_info (struct target *target, struct arm *arm)
 
const char * arm_mode_name (unsigned int psr_mode)
 Map PSR mode bits to the name of an ARM processor operating mode. More...
 
struct regarm_reg_current (struct arm *arm, unsigned int regnum)
 Returns handle to the register currently mapped to a given number. More...
 
void arm_set_cpsr (struct arm *arm, uint32_t cpsr)
 Configures host-side ARM records to reflect the specified CPSR. More...
 
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)
 
int armv4_5_run_algorithm_inner (struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t entry_point, uint32_t exit_point, unsigned int timeout_ms, void *arch_info, int(*run_it)(struct target *target, uint32_t exit_point, unsigned int timeout_ms, void *arch_info))
 
struct reg_cachearmv8_build_reg_cache (struct target *target)
 Builds cache of architecturally defined registers. More...
 
const char * armv8_get_gdb_arch (const struct target *target)
 
int armv8_get_gdb_reg_list (struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
 
struct regarmv8_reg_current (struct arm *arm, unsigned int regnum)
 
static bool is_arm (struct arm *arm)
 
bool is_arm_mode (unsigned int psr_mode)
 Return true iff the parameter denotes a valid ARM processor mode. More...
 
static struct armtarget_to_arm (const struct target *target)
 Convert target handle to generic ARM target state handle. More...
 

Variables

const struct command_registration arm_all_profiles_command_handlers []
 
const struct command_registration arm_command_handlers []
 

Detailed Description

Holds the interface to ARM cores.

At this writing, only "classic ARM" cores built on the ARMv4 register and mode model are supported. The Thumb2-only microcontroller profile support has not yet been integrated, affecting Cortex-M parts.

Definition in file arm.h.

Macro Definition Documentation

◆ ARM_COMMON_MAGIC

#define ARM_COMMON_MAGIC   0x0A450A45U

Definition at line 166 of file arm.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ARM_VFP_V3_D0 
ARM_VFP_V3_D1 
ARM_VFP_V3_D2 
ARM_VFP_V3_D3 
ARM_VFP_V3_D4 
ARM_VFP_V3_D5 
ARM_VFP_V3_D6 
ARM_VFP_V3_D7 
ARM_VFP_V3_D8 
ARM_VFP_V3_D9 
ARM_VFP_V3_D10 
ARM_VFP_V3_D11 
ARM_VFP_V3_D12 
ARM_VFP_V3_D13 
ARM_VFP_V3_D14 
ARM_VFP_V3_D15 
ARM_VFP_V3_D16 
ARM_VFP_V3_D17 
ARM_VFP_V3_D18 
ARM_VFP_V3_D19 
ARM_VFP_V3_D20 
ARM_VFP_V3_D21 
ARM_VFP_V3_D22 
ARM_VFP_V3_D23 
ARM_VFP_V3_D24 
ARM_VFP_V3_D25 
ARM_VFP_V3_D26 
ARM_VFP_V3_D27 
ARM_VFP_V3_D28 
ARM_VFP_V3_D29 
ARM_VFP_V3_D30 
ARM_VFP_V3_D31 
ARM_VFP_V3_FPSCR 

Definition at line 110 of file arm.h.

◆ arm_arch

enum arm_arch

ARM Architecture specifying the version and the profile.

Enumerator
ARM_ARCH_UNKNOWN 
ARM_ARCH_V4 
ARM_ARCH_V6M 
ARM_ARCH_V7M 
ARM_ARCH_V8M 

Definition at line 53 of file arm.h.

◆ arm_core_type

Indicates what registers are in the ARM state core register set.

  • ARM_CORE_TYPE_STD indicates the standard set of 37 registers, seen on for example ARM7TDMI cores.
  • ARM_CORE_TYPE_SEC_EXT indicates core has security extensions, thus three more registers are shadowed for "Secure Monitor" mode.
  • ARM_CORE_TYPE_VIRT_EXT indicates core has virtualization extensions and also security extensions. Additional shadowed registers for "Secure Monitor" and "Hypervisor" modes.
  • ARM_CORE_TYPE_M_PROFILE indicates a microcontroller profile core, which only shadows SP.
Enumerator
ARM_CORE_TYPE_STD 
ARM_CORE_TYPE_SEC_EXT 
ARM_CORE_TYPE_VIRT_EXT 
ARM_CORE_TYPE_M_PROFILE 

Definition at line 45 of file arm.h.

◆ arm_implementer

Known ARM implementer IDs.

Enumerator
ARM_IMPLEMENTER_ARM 
ARM_IMPLEMENTER_INFINEON 
ARM_IMPLEMENTER_ARM_CHINA 
ARM_IMPLEMENTER_REALTEK 

Definition at line 62 of file arm.h.

◆ arm_mode

enum arm_mode

Represent state of an ARM core.

Most numbers match the five low bits of the *PSR registers on "classic ARM" processors, which build on the ARMv4 processor modes and register set.

ARM_MODE_ANY is a magic value, often used as a wildcard.

Only the microcontroller cores (ARMv6-M, ARMv7-M) support ARM_MODE_THREAD, ARM_MODE_USER_THREAD, and ARM_MODE_HANDLER. Those are the only modes they support.

Enumerator
ARM_MODE_USR 
ARM_MODE_FIQ 
ARM_MODE_IRQ 
ARM_MODE_SVC 
ARM_MODE_MON 
ARM_MODE_ABT 
ARM_MODE_HYP 
ARM_MODE_UND 
ARM_MODE_1176_MON 
ARM_MODE_SYS 
ARM_MODE_THREAD 
ARM_MODE_USER_THREAD 
ARM_MODE_HANDLER 
ARMV8_64_EL0T 
ARMV8_64_EL1T 
ARMV8_64_EL1H 
ARMV8_64_EL2T 
ARMV8_64_EL2H 
ARMV8_64_EL3T 
ARMV8_64_EL3H 
ARM_MODE_ANY 

Definition at line 82 of file arm.h.

◆ arm_state

enum arm_state

The PSR "T" and "J" bits define the mode of "classic ARM" cores.

Enumerator
ARM_STATE_ARM 
ARM_STATE_THUMB 
ARM_STATE_JAZELLE 
ARM_STATE_THUMB_EE 
ARM_STATE_AARCH64 

Definition at line 150 of file arm.h.

◆ arm_vfp_version

ARM vector floating point enabled, if yes which version.

Enumerator
ARM_VFP_DISABLED 
ARM_VFP_V1 
ARM_VFP_V2 
ARM_VFP_V3 

Definition at line 159 of file arm.h.

Function Documentation

◆ arm_arch_state()

◆ arm_blank_check_memory()

int arm_blank_check_memory ( struct target target,
struct target_memory_check_block blocks,
int  num_blocks,
uint8_t  erased_value 
)

◆ arm_build_reg_cache()

◆ arm_checksum_memory()

◆ arm_free_reg_cache()

◆ arm_get_gdb_arch()

const char* arm_get_gdb_arch ( const struct target target)

Definition at line 1267 of file armv4_5.c.

◆ arm_get_gdb_reg_list()

◆ arm_init_arch_info()

◆ arm_mode_name()

const char* arm_mode_name ( unsigned int  psr_mode)

Map PSR mode bits to the name of an ARM processor operating mode.

Definition at line 171 of file armv4_5.c.

References arm_mode_data, ARRAY_SIZE, LOG_ERROR, and psr.

Referenced by adapter_debug_entry(), arm7_9_debug_entry(), arm7_9_restore_context(), arm_arch_state(), arm_set_cpsr(), armv7m_arch_state(), cortex_m_debug_entry(), and xscale_debug_entry().

◆ arm_reg_current()

struct reg* arm_reg_current ( struct arm arm,
unsigned int  regnum 
)

Returns handle to the register currently mapped to a given number.

Someone must have called arm_set_cpsr() before.

Parameters
armThis core's state and registers are used.
regnumFrom 0..15 corresponding to R0..R14 and PC. Note that R0..R7 don't require mapping; you may access those as the first eight entries in the register cache. Likewise R15 (PC) doesn't need mapping; you may also access it directly. However, R8..R14, and SPSR (arm->spsr) must be mapped. CPSR (arm->cpsr) is also not mapped.

Definition at line 502 of file armv4_5.c.

References arm::core_cache, LOG_ERROR, arm::map, NULL, and reg_cache::reg_list.

Referenced by arm7_9_debug_entry(), arm7_9_read_memory(), arm7_9_soft_reset_halt(), arm7_9_write_memory(), arm_dpm_read_current_registers(), arm_get_gdb_reg_list(), arm_semihosting(), COMMAND_HANDLER(), cortex_a_read_cpu_memory(), cortex_a_read_cpu_memory_slow(), cortex_a_write_cpu_memory(), cortex_a_write_cpu_memory_slow(), post_result(), and xscale_debug_entry().

◆ arm_set_cpsr()

◆ armv4_5_run_algorithm()

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 
)

◆ armv4_5_run_algorithm_inner()

◆ armv8_build_reg_cache()

◆ armv8_get_gdb_arch()

const char* armv8_get_gdb_arch ( const struct target target)

Definition at line 1946 of file armv8.c.

References ARM_STATE_AARCH64, arm::core_state, and target_to_arm().

◆ armv8_get_gdb_reg_list()

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

◆ armv8_reg_current()

◆ is_arm()

static bool is_arm ( struct arm arm)
inlinestatic

◆ is_arm_mode()

◆ target_to_arm()

static struct arm* target_to_arm ( const struct target target)
inlinestatic

Variable Documentation

◆ arm_all_profiles_command_handlers

const struct command_registration arm_all_profiles_command_handlers[]
extern

Definition at line 1096 of file armv4_5.c.

◆ arm_command_handlers

const struct command_registration arm_command_handlers[]
extern

Definition at line 1096 of file armv4_5.c.