| |||
| Home > VFP System Initialization > Installation routine | |||
One important point to note about the preceding steps is that
they must all be carried out before the C library's floating-point
initialization takes place. This is done by the library routine _fp_init().
The easiest way to do this is to write a simple function that
calls the required routines from sections 3.1-3.5 which armlink
can automatically cause to be executed directly before _fp_init() is
executed. This is done using the $Sub$$ and $Super$$ functionality,
which is detailed in the RVDS Linker and Utilities Guide. The following
C code example shows how this can be done:
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#endif
#ifdef SETUP_UNDEF_STACK
EXTERN_C void Setup_Undef_Stack (void);
#endif
#ifdef PATCH_UNDEF_VECTOR
EXTERN_C void Install_VFPHandler (void);
#endif
#ifdef INIT_CM10rev0_VFP
EXTERN_C void CM_VFP_enable (void);
#endif
EXTERN_C void Enable_VFP (void);
EXTERN_C void $Super$$_fp_init(void);
// Call $Sub$$_fp_init() in place of original _fp_init()
EXTERN_C void $Sub$$_fp_init(void)
{
#ifdef PATCH_UNDEF_VECTOR
Install_VFPHandler();
#endif
#ifdef SETUP_UNDEF_STACK
Setup_Undef_Stack();
#endif
#ifdef INIT_CM10rev0_VFP
CM_VFP_enable();
#endif
Enable_VFP();
$Super$$_fp_init(); // Call original _fp_init()
}