Skip to content

Commit 7f44e28

Browse files
Bradley Bolenstephanosio
authored andcommitted
arch: arm: aarch32: Create z_arm_floating_point_init() for Cortex-R
This will enable the VFP unit on boot to handle the case where FPU_SHARING is not enabled. Signed-off-by: Bradley Bolen <[email protected]>
1 parent 7c1e399 commit 7f44e28

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

arch/arm/core/aarch32/prep_c.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void __weak relocate_vector_table(void)
8484
#endif /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
8585

8686
#if defined(CONFIG_CPU_HAS_FPU)
87+
#if defined(CONFIG_CPU_CORTEX_M)
8788
static inline void z_arm_floating_point_init(void)
8889
{
8990
/*
@@ -180,6 +181,59 @@ static inline void z_arm_floating_point_init(void)
180181
__set_CONTROL(__get_CONTROL() & (~(CONTROL_FPCA_Msk)));
181182
#endif
182183
}
184+
185+
#else
186+
187+
static inline void z_arm_floating_point_init(void)
188+
{
189+
#if defined(CONFIG_FPU)
190+
uint32_t reg_val = 0;
191+
192+
/*
193+
* CPACR : Coprocessor Access Control Register -> CP15 1/0/2
194+
* comp. ARM Architecture Reference Manual, ARMv7-A and ARMv7-R edition,
195+
* chap. B4.1.40
196+
*
197+
* Must be accessed in >= PL1!
198+
* [23..22] = CP11 access control bits,
199+
* [21..20] = CP10 access control bits.
200+
* 11b = Full access as defined for the respective CP,
201+
* 10b = UNDEFINED,
202+
* 01b = Access at PL1 only,
203+
* 00b = No access.
204+
*/
205+
reg_val = __get_CPACR();
206+
/* Enable PL1 access to CP10, CP11 */
207+
reg_val |= (CPACR_CP10(CPACR_FA) | CPACR_CP11(CPACR_FA));
208+
__set_CPACR(reg_val);
209+
__ISB();
210+
211+
#if !defined(CONFIG_FPU_SHARING)
212+
/*
213+
* FPEXC: Floating-Point Exception Control register
214+
* comp. ARM Architecture Reference Manual, ARMv7-A and ARMv7-R edition,
215+
* chap. B6.1.38
216+
*
217+
* Must be accessed in >= PL1!
218+
* [31] EX bit = determines which registers comprise the current state
219+
* of the FPU. The effects of setting this bit to 1 are
220+
* subarchitecture defined. If EX=0, the following
221+
* registers contain the complete current state
222+
* information of the FPU and must therefore be saved
223+
* during a context switch:
224+
* * D0-D15
225+
* * D16-D31 if implemented
226+
* * FPSCR
227+
* * FPEXC.
228+
* [30] EN bit = Advanced SIMD/Floating Point Extensions enable bit.
229+
* [29..00] = Subarchitecture defined -> not relevant here.
230+
*/
231+
__set_FPEXC(FPEXC_EN);
232+
#endif
233+
#endif
234+
}
235+
236+
#endif /* CONFIG_CPU_CORTEX_M */
183237
#endif /* CONFIG_CPU_HAS_FPU */
184238

185239
extern FUNC_NORETURN void z_cstart(void);

0 commit comments

Comments
 (0)