buf_set_u32(reg_params[2].value, 0, 32, size);
/* armv4 must exit using a hardware breakpoint */
- if (arm->is_armv4)
+ if (arm->arch == ARM_ARCH_V4)
exit_var = nand->copy_area->address + target_code_size - 4;
/* use alg to write data from work area to NAND chip */
buf_set_u32(reg_params[2].value, 0, 32, size);
/* armv4 must exit using a hardware breakpoint */
- if (arm->is_armv4)
+ if (arm->arch == ARM_ARCH_V4)
exit_var = nand->copy_area->address + target_code_size - 4;
/* use alg to write data from NAND chip to work area */
{
struct armv7m_common *armv7m = target_to_armv7m(target);
int retval;
- if (armv7m->arm.is_armv6m == true)
+ if (armv7m->arm.arch == ARM_ARCH_V6M)
retval = target_read_u32(target, DBGMCU_IDCODE_L0, id);
else
/* read stm32 device id register */
/* Stacking is different depending on architecture */
struct armv7m_common *armv7m_target = target_to_armv7m(target);
- if (armv7m_target->arm.is_armv6m)
+ if (armv7m_target->arm.arch == ARM_ARCH_V6M)
stacking_info = &rtos_riot_cortex_m0_stacking;
else if (is_armv7m(armv7m_target))
stacking_info = &rtos_riot_cortex_m34_stacking;
ARM_CORE_TYPE_M_PROFILE,
};
+/** ARM Architecture specifying the version and the profile */
+enum arm_arch {
+ ARM_ARCH_UNKNOWN,
+ ARM_ARCH_V4,
+ ARM_ARCH_V6M,
+ ARM_ARCH_V7M,
+ ARM_ARCH_V8M,
+};
+
/**
* Represent state of an ARM core.
*
/** Record the current core state: ARM, Thumb, or otherwise. */
enum arm_state core_state;
- /** Flag reporting unavailability of the BKPT instruction. */
- bool is_armv4;
-
- /** Flag reporting armv6m based core. */
- bool is_armv6m;
-
- /** Flag reporting armv8m based core. */
- bool is_armv8m;
+ /** ARM architecture version */
+ enum arm_arch arch;
/** Floating point or VFP version, 0 if disabled. */
int arm_vfp_version;
{
struct arm720t_common *arm720t = calloc(1, sizeof(*arm720t));
- arm720t->arm7_9_common.arm.is_armv4 = true;
+ arm720t->arm7_9_common.arm.arch = ARM_ARCH_V4;
return arm720t_init_arch_info(target, arm720t, target->tap);
}
arm7_9 = calloc(1, sizeof(struct arm7_9_common));
arm7tdmi_init_arch_info(target, arm7_9, target->tap);
- arm7_9->arm.is_armv4 = true;
+ arm7_9->arm.arch = ARM_ARCH_V4;
return ERROR_OK;
}
struct arm7_9_common *arm7_9 = calloc(1, sizeof(struct arm7_9_common));
arm9tdmi_init_arch_info(target, arm7_9, target->tap);
- arm7_9->arm.is_armv4 = true;
+ arm7_9->arm.arch = ARM_ARCH_V4;
return ERROR_OK;
}
}
/* armv5 and later can terminate with BKPT instruction; less overhead */
- if (!exit_point && arm->is_armv4) {
+ if (!exit_point && arm->arch == ARM_ARCH_V4) {
LOG_ERROR("ARMv4 target needs HW breakpoint location");
return ERROR_FAIL;
}
int timeout = 20000 * (1 + (count / (1024 * 1024)));
/* armv4 must exit using a hardware breakpoint */
- if (arm->is_armv4)
+ if (arm->arch == ARM_ARCH_V4)
exit_var = crc_algorithm->address + sizeof(arm_crc_code_le) - 8;
retval = target_run_algorithm(target, 0, NULL, 2, reg_params,
buf_set_u32(reg_params[2].value, 0, 32, erased_value);
/* armv4 must exit using a hardware breakpoint */
- if (arm->is_armv4)
+ if (arm->arch == ARM_ARCH_V4)
exit_var = check_algorithm->address + sizeof(check_code_le) - 4;
retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
/* examine PE security state */
bool secure_state = false;
- if (armv7m->arm.is_armv8m) {
+ if (armv7m->arm.arch == ARM_ARCH_V8M) {
uint32_t dscsr;
retval = mem_ap_read_u32(armv7m->debug_ap, DCB_DSCSR, &dscsr);
{
struct armv7m_common *armv7m = target_to_armv7m(target);
- if (armv7m->arm.is_armv6m) {
+ if (armv7m->arm.arch == ARM_ARCH_V6M) {
/* armv6m does not handle unaligned memory access */
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
return ERROR_TARGET_UNALIGNED_ACCESS;
{
struct armv7m_common *armv7m = target_to_armv7m(target);
- if (armv7m->arm.is_armv6m) {
+ if (armv7m->arm.arch == ARM_ARCH_V6M) {
/* armv6m does not handle unaligned memory access */
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
return ERROR_TARGET_UNALIGNED_ACCESS;
unsigned int core = (cpuid >> 4) & 0xf;
/* Check if it is an ARMv8-M core */
- armv7m->arm.is_armv8m = true;
+ armv7m->arm.arch = ARM_ARCH_V8M;
switch (cpuid & ARM_CPUID_PARTNO_MASK) {
case CORTEX_M23_PARTNO:
core = 55;
break;
default:
- armv7m->arm.is_armv8m = false;
+ armv7m->arm.arch = ARM_ARCH_V7M;
break;
}
}
} else if (core == 0) {
/* Cortex-M0 does not support unaligned memory access */
- armv7m->arm.is_armv6m = true;
+ armv7m->arm.arch = ARM_ARCH_V6M;
}
/* VECTRESET is supported only on ARMv7-M cores */
- cortex_m->vectreset_supported = !armv7m->arm.is_armv8m && !armv7m->arm.is_armv6m;
+ cortex_m->vectreset_supported = armv7m->arm.arch == ARM_ARCH_V7M;
/* Check for FPU, otherwise mark FPU register as non-existent */
if (armv7m->fp_feature == FP_NONE)
for (size_t idx = ARMV7M_FPU_FIRST_REG; idx <= ARMV7M_FPU_LAST_REG; idx++)
armv7m->arm.core_cache->reg_list[idx].exist = false;
- if (!armv7m->arm.is_armv8m)
+ if (armv7m->arm.arch != ARM_ARCH_V8M)
for (size_t idx = ARMV8M_FIRST_REG; idx <= ARMV8M_LAST_REG; idx++)
armv7m->arm.core_cache->reg_list[idx].exist = false;