forked from Imagelibrary/rtems
Added support for context switching the data used by the gcc m68k
software floating point emulation code. Code implemented by Karen Sara Looney <Karen.Looney@colorado.edu> with much email assistance from Joel.
This commit is contained in:
@@ -47,7 +47,7 @@ typedef unsigned32 rtems_attribute;
|
|||||||
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
||||||
#define RTEMS_PRIORITY_CEILING 0x00000040
|
#define RTEMS_PRIORITY_CEILING 0x00000040
|
||||||
|
|
||||||
#if ( CPU_HARDWARE_FP == TRUE )
|
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||||
#define ATTRIBUTES_NOT_SUPPORTED 0
|
#define ATTRIBUTES_NOT_SUPPORTED 0
|
||||||
#else
|
#else
|
||||||
#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT
|
#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ typedef unsigned32 rtems_attribute;
|
|||||||
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
||||||
#define RTEMS_PRIORITY_CEILING 0x00000040
|
#define RTEMS_PRIORITY_CEILING 0x00000040
|
||||||
|
|
||||||
#if ( CPU_HARDWARE_FP == TRUE )
|
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||||
#define ATTRIBUTES_NOT_SUPPORTED 0
|
#define ATTRIBUTES_NOT_SUPPORTED 0
|
||||||
#else
|
#else
|
||||||
#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT
|
#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT
|
||||||
|
|||||||
@@ -177,3 +177,32 @@ const unsigned char __BFFFOtable[256] = {
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*PAGE
|
||||||
|
*
|
||||||
|
* The following code context switches the software FPU emulation
|
||||||
|
* code provided with GCC.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (CPU_SOFTWARE_FP == TRUE)
|
||||||
|
extern Context_Control_fp _fpCCR;
|
||||||
|
|
||||||
|
void CPU_Context_save_fp (void **fp_context_ptr)
|
||||||
|
{
|
||||||
|
Context_Control_fp *fp;
|
||||||
|
|
||||||
|
fp = (Context_Control_fp *) *fp_context_ptr;
|
||||||
|
|
||||||
|
*fp = _fpCCR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPU_Context_restore_fp (void **fp_context_ptr)
|
||||||
|
{
|
||||||
|
Context_Control_fp *fp;
|
||||||
|
|
||||||
|
fp = (Context_Control_fp *) *fp_context_ptr;
|
||||||
|
|
||||||
|
_fpCCR = *fp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -52,12 +52,22 @@ extern "C" {
|
|||||||
/*
|
/*
|
||||||
* Some family members have no FP, some have an FPU such as the
|
* Some family members have no FP, some have an FPU such as the
|
||||||
* MC68881/MC68882 for the MC68020, others have it built in (MC68030, 040).
|
* MC68881/MC68882 for the MC68020, others have it built in (MC68030, 040).
|
||||||
|
*
|
||||||
|
* NOTE: If on a CPU without hardware FP, then one can use software
|
||||||
|
* emulation. The gcc software FP emulation code has data which
|
||||||
|
* must be contexted switched on a per task basis.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ( M68K_HAS_FPU == 1 )
|
#if ( M68K_HAS_FPU == 1 )
|
||||||
#define CPU_HARDWARE_FP TRUE
|
#define CPU_HARDWARE_FP TRUE
|
||||||
|
#define CPU_SOFTWARE_FP FALSE
|
||||||
#else
|
#else
|
||||||
#define CPU_HARDWARE_FP FALSE
|
#define CPU_HARDWARE_FP FALSE
|
||||||
|
#if defined(__GCC__)
|
||||||
|
#define CPU_SOFTWARE_FP TRUE
|
||||||
|
#else
|
||||||
|
#define CPU_SOFTWARE_FP FALSE
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -107,6 +117,38 @@ typedef struct {
|
|||||||
void *a7_msp; /* (a7) master stack pointer */
|
void *a7_msp; /* (a7) master stack pointer */
|
||||||
} Context_Control;
|
} Context_Control;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Floating point context ares
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (CPU_SOFTWARE_FP == TRUE)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the same as gcc's view of the software FP condition code
|
||||||
|
* register _fpCCR. The implementation of the emulation code is
|
||||||
|
* in the gcc-VERSION/config/m68k directory. This structure is
|
||||||
|
* correct as of gcc 2.7.2.2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned16 _exception_bits;
|
||||||
|
unsigned16 _trap_enable_bits;
|
||||||
|
unsigned16 _sticky_bits;
|
||||||
|
unsigned16 _rounding_mode;
|
||||||
|
unsigned16 _format;
|
||||||
|
unsigned16 _last_operation;
|
||||||
|
union {
|
||||||
|
float sf;
|
||||||
|
double df;
|
||||||
|
} _operand1;
|
||||||
|
union {
|
||||||
|
float sf;
|
||||||
|
double df;
|
||||||
|
} _operand2;
|
||||||
|
} Context_Control_fp;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FP context save area for the M68881/M68882 numeric coprocessors.
|
* FP context save area for the M68881/M68882 numeric coprocessors.
|
||||||
*/
|
*/
|
||||||
@@ -117,6 +159,7 @@ typedef struct {
|
|||||||
/* 12 bytes for FMOVEM CREGS */
|
/* 12 bytes for FMOVEM CREGS */
|
||||||
/* 4 bytes for non-null flag */
|
/* 4 bytes for non-null flag */
|
||||||
} Context_Control_fp;
|
} Context_Control_fp;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following structure defines the set of information saved
|
* The following structure defines the set of information saved
|
||||||
@@ -291,6 +334,34 @@ unsigned32 _CPU_ISR_Get_level( void );
|
|||||||
: "0" ((_the_context)->sr), "1" ((_the_context)->a7_msp) ); \
|
: "0" ((_the_context)->sr), "1" ((_the_context)->a7_msp) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Floating Point Context Area Support routines
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (CPU_SOFTWARE_FP == TRUE)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This software FP implementation is only for GCC.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _CPU_Context_Fp_start( _base, _offset ) \
|
||||||
|
((void *) _Addresses_Add_offset( (_base), (_offset) ) )
|
||||||
|
|
||||||
|
|
||||||
|
#define _CPU_Context_Initialize_fp( _fp_area ) \
|
||||||
|
{ \
|
||||||
|
Context_Control_fp *_fp; \
|
||||||
|
_fp = *(Context_Control_fp **)_fp_area; \
|
||||||
|
_fp->_exception_bits = 0; \
|
||||||
|
_fp->_trap_enable_bits = 0; \
|
||||||
|
_fp->_sticky_bits = 0; \
|
||||||
|
_fp->_rounding_mode = 0; /* ROUND_TO_NEAREST */ \
|
||||||
|
_fp->_format = 0; /* NIL */ \
|
||||||
|
_fp->_last_operation = 0; /* NOOP */ \
|
||||||
|
_fp->_operand1.df = 0; \
|
||||||
|
_fp->_operand2.df = 0; \
|
||||||
|
}
|
||||||
|
#else
|
||||||
#define _CPU_Context_Fp_start( _base, _offset ) \
|
#define _CPU_Context_Fp_start( _base, _offset ) \
|
||||||
((void *) \
|
((void *) \
|
||||||
_Addresses_Add_offset( \
|
_Addresses_Add_offset( \
|
||||||
@@ -305,6 +376,7 @@ unsigned32 _CPU_ISR_Get_level( void );
|
|||||||
*(--(_fp_context)) = 0; \
|
*(--(_fp_context)) = 0; \
|
||||||
*(_fp_area) = (unsigned8 *)(_fp_context); \
|
*(_fp_area) = (unsigned8 *)(_fp_context); \
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* end of Context handler macros */
|
/* end of Context handler macros */
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,14 @@ restore: movml a0@,d1-d7/a2-a7 | restore context
|
|||||||
*
|
*
|
||||||
* CPU_FP_CONTEXT_SIZE is higher than expected to account for the
|
* CPU_FP_CONTEXT_SIZE is higher than expected to account for the
|
||||||
* -1 pushed at end of this sequence.
|
* -1 pushed at end of this sequence.
|
||||||
|
*
|
||||||
|
* Neither of these entries is required if we have software FPU
|
||||||
|
* emulation. But if we don't have an FPU or emulation, then
|
||||||
|
* we need the stub versions of these routines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if (CPU_SOFTWARE_FP == FALSE)
|
||||||
|
|
||||||
.set FPCONTEXT_ARG, 4 | save FP context argument
|
.set FPCONTEXT_ARG, 4 | save FP context argument
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
@@ -86,6 +92,7 @@ norst: frestore a0@+ | restore the fp state frame
|
|||||||
movl a0,a1@ | save pointer to saved context
|
movl a0,a1@ | save pointer to saved context
|
||||||
#endif
|
#endif
|
||||||
rts
|
rts
|
||||||
|
#endif
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
* void _ISR_Handler()
|
* void _ISR_Handler()
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ void _Thread_Start_multitasking( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if ( CPU_HARDWARE_FP == TRUE )
|
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||||
/*
|
/*
|
||||||
* don't need to worry about saving BSP's floating point state
|
* don't need to worry about saving BSP's floating point state
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ typedef unsigned32 rtems_attribute;
|
|||||||
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
||||||
#define RTEMS_PRIORITY_CEILING 0x00000040
|
#define RTEMS_PRIORITY_CEILING 0x00000040
|
||||||
|
|
||||||
#if ( CPU_HARDWARE_FP == TRUE )
|
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||||
#define ATTRIBUTES_NOT_SUPPORTED 0
|
#define ATTRIBUTES_NOT_SUPPORTED 0
|
||||||
#else
|
#else
|
||||||
#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT
|
#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT
|
||||||
|
|||||||
@@ -177,3 +177,32 @@ const unsigned char __BFFFOtable[256] = {
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*PAGE
|
||||||
|
*
|
||||||
|
* The following code context switches the software FPU emulation
|
||||||
|
* code provided with GCC.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (CPU_SOFTWARE_FP == TRUE)
|
||||||
|
extern Context_Control_fp _fpCCR;
|
||||||
|
|
||||||
|
void CPU_Context_save_fp (void **fp_context_ptr)
|
||||||
|
{
|
||||||
|
Context_Control_fp *fp;
|
||||||
|
|
||||||
|
fp = (Context_Control_fp *) *fp_context_ptr;
|
||||||
|
|
||||||
|
*fp = _fpCCR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPU_Context_restore_fp (void **fp_context_ptr)
|
||||||
|
{
|
||||||
|
Context_Control_fp *fp;
|
||||||
|
|
||||||
|
fp = (Context_Control_fp *) *fp_context_ptr;
|
||||||
|
|
||||||
|
_fpCCR = *fp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ void _Thread_Start_multitasking( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if ( CPU_HARDWARE_FP == TRUE )
|
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||||
/*
|
/*
|
||||||
* don't need to worry about saving BSP's floating point state
|
* don't need to worry about saving BSP's floating point state
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user