aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/src/__support/CPP/type_traits/is_destructible.h1
-rw-r--r--libc/startup/baremetal/arm/start.cpp26
2 files changed, 27 insertions, 0 deletions
diff --git a/libc/src/__support/CPP/type_traits/is_destructible.h b/libc/src/__support/CPP/type_traits/is_destructible.h
index 7ada223..dc5e62b 100644
--- a/libc/src/__support/CPP/type_traits/is_destructible.h
+++ b/libc/src/__support/CPP/type_traits/is_destructible.h
@@ -15,6 +15,7 @@
#include "src/__support/CPP/type_traits/remove_all_extents.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/CPP/type_traits/type_identity.h"
+#include "src/__support/CPP/utility/declval.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
diff --git a/libc/startup/baremetal/arm/start.cpp b/libc/startup/baremetal/arm/start.cpp
index c089a14..4740067 100644
--- a/libc/startup/baremetal/arm/start.cpp
+++ b/libc/startup/baremetal/arm/start.cpp
@@ -131,6 +131,32 @@ namespace LIBC_NAMESPACE_DECL {
__arm_wsr("CPSR_c", 0x13); // SVC
#endif
+#ifdef __ARM_FP
+// Enable FPU
+#if __ARM_ARCH_PROFILE == 'M'
+ // Based on
+ // https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Floating-Point-Unit/Enabling-the-FPU
+ // Set CPACR cp10 and cp11
+ auto cpacr = (volatile uint32_t *const)0xE000ED88;
+ *cpacr |= (0xF << 20);
+ __dsb(0xF);
+ __isb(0xF);
+#elif __ARM_ARCH_PROFILE == 'A' || __ARM_ARCH_PROFILE == 'R'
+ // Based on
+ // https://developer.arm.com/documentation/dui0472/m/Compiler-Coding-Practices/Enabling-NEON-and-FPU-for-bare-metal
+ // Set CPACR cp10 and cp11
+ uint32_t cpacr = __arm_rsr("p15:0:c1:c0:2");
+ cpacr |= (0xF << 20);
+ __arm_wsr("p15:0:c1:c0:2", cpacr);
+ __isb(0xF);
+ // Set FPEXC.EN
+ uint32_t fpexc;
+ __asm__ __volatile__("vmrs %0, FPEXC" : "=r"(fpexc) : :);
+ fpexc |= (1 << 30);
+ __asm__ __volatile__("vmsr FPEXC, %0" : : "r"(fpexc) :);
+#endif
+#endif
+
// Perform the equivalent of scatterloading
LIBC_NAMESPACE::memcpy(__data_start, __data_source,
reinterpret_cast<uintptr_t>(__data_size));