Skip to content

Commit 52ee66a

Browse files
committed
Fix GCC's __FPU_Enable for Cortex-A for no optimisation
At -O0 the pseudo instruction LDR R2,=0x00086060 caused the literal pool to be created out of range.
1 parent 4145a00 commit 52ee66a

3 files changed

Lines changed: 16 additions & 24 deletions

File tree

CMSIS/CoreValidation/Layer/App/Validation_Cortex-A/App.clayer.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ layer:
2323
- for-compiler: GCC
2424
C-CPP:
2525
- -Wno-declaration-after-statement
26-
- -Wno-covered-switch-default
2726

2827
groups:
2928
- group: Documentation

CMSIS/CoreValidation/Layer/App/Validation_Cortex-M/App.clayer.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ layer:
2323
- for-compiler: GCC
2424
C-CPP:
2525
- -Wno-declaration-after-statement
26-
- -Wno-covered-switch-default
2726

2827
groups:
2928
- group: Documentation

CMSIS/Core_A/Include/cmsis_gcc.h

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -895,24 +895,20 @@ __STATIC_FORCEINLINE void __set_FPEXC(uint32_t fpexc)
895895
*/
896896
__STATIC_INLINE void __FPU_Enable(void)
897897
{
898-
__ASM volatile(
899-
//Permit access to VFP/NEON, registers by modifying CPACR
900-
" MRC p15,0,R1,c1,c0,2 \n"
901-
" ORR R1,R1,#0x00F00000 \n"
902-
" MCR p15,0,R1,c1,c0,2 \n"
903-
904-
//Ensure that subsequent instructions occur in the context of VFP/NEON access permitted
905-
" ISB \n"
898+
// Permit access to VFP/NEON, registers by modifying CPACR
899+
const uint32_t cpacr = __get_CPACR();
900+
__set_CPACR(cpacr | 0x00F00000ul);
901+
__ISB();
906902

907-
//Enable VFP/NEON
908-
" VMRS R1,FPEXC \n"
909-
" ORR R1,R1,#0x40000000 \n"
910-
" VMSR FPEXC,R1 \n"
903+
// Enable VFP/NEON
904+
const uint32_t fpexc = __get_FPEXC();
905+
__set_FPEXC(fpexc | 0x40000000ul);
911906

912-
//Initialise VFP/NEON registers to 0
907+
__ASM volatile(
908+
// Initialise VFP/NEON registers to 0
913909
" MOV R2,#0 \n"
914910

915-
//Initialise D16 registers to 0
911+
// Initialise D16 registers to 0
916912
" VMOV D0, R2,R2 \n"
917913
" VMOV D1, R2,R2 \n"
918914
" VMOV D2, R2,R2 \n"
@@ -931,7 +927,7 @@ __STATIC_INLINE void __FPU_Enable(void)
931927
" VMOV D15,R2,R2 \n"
932928

933929
#if (defined(__ARM_NEON) && (__ARM_NEON == 1))
934-
//Initialise D32 registers to 0
930+
// Initialise D32 registers to 0
935931
" VMOV D16,R2,R2 \n"
936932
" VMOV D17,R2,R2 \n"
937933
" VMOV D18,R2,R2 \n"
@@ -949,14 +945,12 @@ __STATIC_INLINE void __FPU_Enable(void)
949945
" VMOV D30,R2,R2 \n"
950946
" VMOV D31,R2,R2 \n"
951947
#endif
952-
953-
//Initialise FPSCR to a known state
954-
" VMRS R1,FPSCR \n"
955-
" LDR R2,=0x00086060 \n" //Mask off all bits that do not have to be preserved. Non-preserved bits can/should be zero.
956-
" AND R1,R1,R2 \n"
957-
" VMSR FPSCR,R1 "
958-
: : : "cc", "r1", "r2"
948+
: : : "cc", "r2"
959949
);
950+
951+
// Initialise FPSCR to a known state
952+
const uint32_t fpscr = __get_FPSCR();
953+
__set_FPSCR(fpscr & 0x00086060ul);
960954
}
961955

962956
/*@} end of group CMSIS_Core_intrinsics */

0 commit comments

Comments
 (0)