The ARM floating point functionality is implemented in software because
the majority of ARM processors don't have built-in floating point hardware.
The VFP functionality support is enabled when the startup program detects the presence
of VFP hardware and sets the system page CPU_FLAG_FPU
flag.
The QNX Neutrino procnto and procnto-v6 provides the
basic support for managing the VFP context on a
per-thread basis. This support uses a lazy mechanism to minimize
the cost of saving and restoring the VFP register context as follows:
- The VFP is disabled initially.
- Any VFP access causes an undefined instruction exception, allowing the kernel to initialize the VFP context for a thread.
- First access to the VFP by a thread causes an exception. The kernel exception handler:
- allocates storage for the VFP context
- initializes the VFP state
- records this thread as owning the VFP
- restarts the VFP instruction
- VFP is disabled on a context switch to allow the kernel to
trap subsequent VFP accesses for managing the per-thread VFP context:
- If the access is performed by the thread owning the VFP, the
VFP already contains the correct VFP state.
In this case, the VFP is simply re-enabled and the VFP instruction
is restarted.
- If the access is performed by a different thread, a VFP context
switch is required:
- The VFP state is saved in the owning thread's VFP storage.
- If this is the first access performed by the thread, storage is
allocated for the VFP context, and its VFP state is initialized.
- The VFP state is restored from the new thread's VFP storage.
- The new thread is recorded as owning the VFP.
- The VFP instruction is restarted.