cortex_m: mark FPU register as non-existent instead of playing with num_regs
[fw/openocd] / src / target / cortex_m.c
index e7a2fadda744ce30d6c6207eb4fcb0091da695ff..46b0e3c2a717a60bbb54fa3c4799df34f487cfd0 100644 (file)
@@ -2038,19 +2038,11 @@ int cortex_m_examine(struct target *target)
                        armv7m->arm.is_armv6m = true;
                }
 
-               if (armv7m->fp_feature == FP_NONE &&
-                   armv7m->arm.core_cache->num_regs > ARMV7M_NUM_CORE_REGS_NOFP) {
-                       /* free unavailable FPU registers */
-                       size_t idx;
-
-                       for (idx = ARMV7M_NUM_CORE_REGS_NOFP;
-                            idx < armv7m->arm.core_cache->num_regs;
-                            idx++) {
-                               free(armv7m->arm.core_cache->reg_list[idx].feature);
-                               free(armv7m->arm.core_cache->reg_list[idx].reg_data_type);
-                       }
-                       armv7m->arm.core_cache->num_regs = ARMV7M_NUM_CORE_REGS_NOFP;
-               }
+               /* 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->stlink) {
                        if (i == 3 || i == 4)