Skip to content

Commit 8e89a8a

Browse files
committed
target: cortex_m: add support of ARMv8.1-M register 'vpr'
The register 'vpr' is present when MVFR1.MVE is not zero. For the moment, reuse the existing flag 'fp_feature'. To be reviewed for the case of MVE supported without floating point. The documentation of GDB [1] reports that the register 'vpr' should be represented as 3 fields. Tested on Cortex-M55 based STM32N6570. Change-Id: I8737a24d01a13eeb09a0f2075b96be400f9f91c6 Signed-off-by: Antonio Borneo <[email protected]> Link: [1] https://sourceware.org/gdb/download/onlinedocs/gdb.html/ARM-Features.html#M_002dprofile-Vector-Extension-_0028MVE_0029 Reviewed-on: https://review.openocd.org/c/openocd/+/8681 Tested-by: jenkins
1 parent 41f7d18 commit 8e89a8a

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/target/armv7m.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ const int armv7m_msp_reg_map[ARMV7M_NUM_CORE_REGS] = {
6565
ARMV7M_XPSR,
6666
};
6767

68+
static struct reg_data_type_bitfield armv8m_vpr_bits[] = {
69+
{ 0, 15, REG_TYPE_UINT },
70+
{ 16, 19, REG_TYPE_UINT },
71+
{ 20, 23, REG_TYPE_UINT },
72+
};
73+
74+
static struct reg_data_type_flags_field armv8m_vpr_fields[] = {
75+
{ "P0", armv8m_vpr_bits + 0, armv8m_vpr_fields + 1, },
76+
{ "MASK01", armv8m_vpr_bits + 1, armv8m_vpr_fields + 2, },
77+
{ "MASK23", armv8m_vpr_bits + 2, NULL },
78+
};
79+
80+
static struct reg_data_type_flags armv8m_vpr_flags[] = {
81+
{ 4, armv8m_vpr_fields },
82+
};
83+
84+
static struct reg_data_type armv8m_flags_vpr[] = {
85+
{ REG_TYPE_ARCH_DEFINED, "vpr_reg", REG_TYPE_CLASS_FLAGS,
86+
{ .reg_type_flags = armv8m_vpr_flags },
87+
},
88+
};
89+
6890
/*
6991
* These registers are not memory-mapped. The ARMv7-M profile includes
7092
* memory mapped registers too, such as for the NVIC (interrupt controller)
@@ -158,6 +180,8 @@ static const struct {
158180
{ ARMV7M_D15, "d15", 64, REG_TYPE_IEEE_DOUBLE, "float", "org.gnu.gdb.arm.vfp", NULL, },
159181

160182
{ ARMV7M_FPSCR, "fpscr", 32, REG_TYPE_INT, "float", "org.gnu.gdb.arm.vfp", NULL, },
183+
184+
{ ARMV8M_VPR, "vpr", 32, REG_TYPE_INT, "float", "org.gnu.gdb.arm.m-profile-mve", armv8m_flags_vpr, },
161185
};
162186

163187
#define ARMV7M_NUM_REGS ARRAY_SIZE(armv7m_regs)
@@ -273,6 +297,9 @@ uint32_t armv7m_map_id_to_regsel(unsigned int arm_reg_id)
273297
case ARMV7M_FPSCR:
274298
return ARMV7M_REGSEL_FPSCR;
275299

300+
case ARMV8M_VPR:
301+
return ARMV8M_REGSEL_VPR;
302+
276303
case ARMV7M_D0 ... ARMV7M_D15:
277304
return ARMV7M_REGSEL_S0 + 2 * (arm_reg_id - ARMV7M_D0);
278305

src/target/armv7m.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum {
6262
ARMV7M_REGSEL_PMSK_BPRI_FLTMSK_CTRL = 0x14,
6363
ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_S = 0x22,
6464
ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_NS = 0x23,
65+
ARMV8M_REGSEL_VPR = 0x24,
6566
ARMV7M_REGSEL_FPSCR = 0x21,
6667

6768
/* 32bit Floating-point registers */
@@ -196,12 +197,15 @@ enum {
196197
/* Floating-point status register */
197198
ARMV7M_FPSCR,
198199

200+
/* Vector Predication Status and Control Register */
201+
ARMV8M_VPR,
202+
199203
/* for convenience add registers' block delimiters */
200204
ARMV7M_LAST_REG,
201205
ARMV7M_CORE_FIRST_REG = ARMV7M_R0,
202206
ARMV7M_CORE_LAST_REG = ARMV7M_XPSR,
203207
ARMV7M_FPU_FIRST_REG = ARMV7M_D0,
204-
ARMV7M_FPU_LAST_REG = ARMV7M_FPSCR,
208+
ARMV7M_FPU_LAST_REG = ARMV8M_VPR,
205209
ARMV8M_FIRST_REG = ARMV8M_MSP_NS,
206210
ARMV8M_LAST_REG = ARMV8M_CONTROL_NS,
207211
};

src/target/cortex_m.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,10 @@ int cortex_m_examine(struct target *target)
27082708
for (size_t idx = ARMV7M_FPU_FIRST_REG; idx <= ARMV7M_FPU_LAST_REG; idx++)
27092709
armv7m->arm.core_cache->reg_list[idx].exist = false;
27102710

2711+
/* TODO: MVE can be present without floating points. Revisit this test */
2712+
if (armv7m->fp_feature != FPV5_MVE_F && armv7m->fp_feature != FPV5_MVE_I)
2713+
armv7m->arm.core_cache->reg_list[ARMV8M_VPR].exist = false;
2714+
27112715
if (!cortex_m_has_tz(target))
27122716
for (size_t idx = ARMV8M_FIRST_REG; idx <= ARMV8M_LAST_REG; idx++)
27132717
armv7m->arm.core_cache->reg_list[idx].exist = false;

0 commit comments

Comments
 (0)