RTEMS Logo

RTEMS 4.6.6 On-Line Library


Task Context Management Initializing a Floating Point Context

PREV UP NEXT Bookshelf RTEMS Porting Guide

6.4.7: Initializing a Floating Point Context

The _CPU_Context_Initialize_fp routine initializes the floating point context area passed to it to. There are a few standard ways in which to initialize the floating point context. The simplest, and least deterministic behaviorally, is to do nothing. This leaves the FPU in a random state and is generally not a suitable way to implement this routine. The second common implementation is to place a "null FP status word" into some status/control register in the FPU. This mechanism is simple and works on many FPUs. Another common way is to initialize the FPU to a known state during _CPU_Initialize and save the context (using _CPU_Context_save_fp_context) into the special floating point context _CPU_Null_fp_context. Then all that is required to initialize a floating point context is to copy _CPU_Null_fp_context to the destination floating point context passed to it. The following example implementation shows how to accomplish this:

#define _CPU_Context_Initialize_fp( _destination ) \
  { \
   *((Context_Control_fp *) *((void **) _destination)) = \
       _CPU_Null_fp_context; \
  }

The _CPU_Null_fp_context is optional. A port need only include this variable when it uses the above mechanism to initialize a floating point context. This is typically done on CPUs where it is difficult to generate an "uninitialized" FP context. If the port requires this variable, then it is declared as follows:

Context_Control_fp  _CPU_Null_fp_context;


PREV UP NEXT Bookshelf RTEMS Porting Guide

Copyright © 1988-2004 OAR Corporation