[ion/device] Make sure start()'s prologue doesn't use VFP registers

This commit is contained in:
Romain Goyet
2018-10-10 15:20:15 +02:00
committed by LeaNumworks
parent 14d84af28e
commit 308ab85173

View File

@@ -28,6 +28,19 @@ void abort() {
#endif
}
/* By default, the compiler is free to inline any function call he wants. If the
* compiler decides to inline some functions that make use of VFP registers, it
* will need to push VFP them onto the stack in calling function's prologue.
* Problem: in start()'s prologue, we would never had a chance to enable the FPU
* since this function is the first thing called after reset.
* We can safely assume that neither memcpy, memset, nor any Ion::Device::init*
* method will use floating-point numbers, but ion_main very well can.
* To make sure ion_main's potential usage of VFP registers doesn't bubble-up to
* start(), we isolate it in its very own non-inlined function call. */
static void __attribute__((noinline)) non_inlined_ion_main() {
return ion_main(0, nullptr);
}
void start() {
// This is where execution starts after reset.
// Many things are not initialized yet so the code here has to pay attention.
@@ -75,7 +88,7 @@ void start() {
Ion::Device::init();
ion_main(0, nullptr);
non_inlined_ion_main();
abort();
}