File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
libc/startup/baremetal/arm Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,28 @@ namespace LIBC_NAMESPACE_DECL {
131131 __arm_wsr (" CPSR_c" , 0x13 ); // SVC
132132#endif
133133
134+ #ifdef __ARM_FP
135+ // Enable FPU
136+ #if __ARM_ARCH_PROFILE == 'M'
137+ // Set CPACR cp10 and cp11
138+ auto cpacr = (volatile uint32_t *const )0xE000ED88 ;
139+ *cpacr |= (0xF << 20 );
140+ __dsb (0xF );
141+ __isb (0xF );
142+ #elif __ARM_ARCH_PROFILE == 'A' || __ARM_ARCH_PROFILE == 'R'
143+ // Set CPACR cp10 and cp11
144+ uint32_t cpacr = __arm_rsr (" p15:0:c1:c0:2" );
145+ cpacr |= (0xF << 20 );
146+ __arm_wsr (" p15:0:c1:c0:2" , cpacr);
147+ // Set FPEXC.EN
148+ uint32_t fpexc;
149+ __asm__ __volatile__ (" vmrs %0, FPEXC" : " =r" (fpexc) : :);
150+ fpexc |= (1 << 30 );
151+ __asm__ __volatile__ (" vmsr FPEXC, %0" : : " r" (fpexc) :);
152+ __isb (0xF );
153+ #endif
154+ #endif
155+
134156 // Perform the equivalent of scatterloading
135157 LIBC_NAMESPACE::memcpy (__data_start, __data_source,
136158 reinterpret_cast <uintptr_t >(__data_size));
You can’t perform that action at this time.
0 commit comments