00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _RTAI_ASM_I386_FPU_H
00030 #define _RTAI_ASM_I386_FPU_H
00031
00032 #ifndef __cplusplus
00033 #include <asm/processor.h>
00034 #endif
00035
00036 typedef union i387_union FPU_ENV;
00037
00038 #ifdef CONFIG_RTAI_FPU_SUPPORT
00039
00040 #define load_mxcsr(val) \
00041 do { \
00042 unsigned long __mxcsr = ((unsigned long)(val) & 0xffbf); \
00043 __asm__ __volatile__ ("ldmxcsr %0": : "m" (__mxcsr)); \
00044 } while (0)
00045
00046 #define save_cr0_and_clts(x) \
00047 do { \
00048 __asm__ __volatile__ ("movl %%cr0,%0; clts": "=r" (x)); \
00049 } while (0)
00050
00051 #define restore_cr0(x) \
00052 do { \
00053 if (x & 8) { \
00054 unsigned long flags; \
00055 rtai_hw_lock(flags); \
00056 __asm__ __volatile__ ("movl %%cr0, %0": "=r" (x)); \
00057 __asm__ __volatile__ ("movl %0, %%cr0": :"r" (8 | x)); \
00058 rtai_hw_unlock(flags); \
00059 } \
00060 } while (0)
00061
00062 #define enable_fpu() \
00063 do { \
00064 __asm__ __volatile__ ("clts"); \
00065 } while (0)
00066
00067 #define init_xfpu() \
00068 do { \
00069 __asm__ __volatile__ ("clts; fninit"); \
00070 if (cpu_has_xmm) { \
00071 load_mxcsr(0x1f80); \
00072 } \
00073 } while (0)
00074
00075 #define save_fpenv(x) \
00076 do { \
00077 if (cpu_has_fxsr) { \
00078 __asm__ __volatile__ ("fxsave %0; fnclex": "=m" (x)); \
00079 } else { \
00080 __asm__ __volatile__ ("fnsave %0; fwait": "=m" (x)); \
00081 } \
00082 } while (0)
00083
00084 #define restore_fpenv(x) \
00085 do { \
00086 if (cpu_has_fxsr) { \
00087 __asm__ __volatile__ ("fxrstor %0": : "m" (x)); \
00088 } else { \
00089 __asm__ __volatile__ ("frstor %0": : "m" (x)); \
00090 } \
00091 } while (0)
00092
00093 #define restore_task_fpenv(t) \
00094 do { \
00095 clts(); \
00096 restore_fpenv((t)->thread.i387.fsave); \
00097 } while (0)
00098
00099 #define restore_fpenv_lxrt(t) restore_task_fpenv(t)
00100
00101 #else
00102
00103 #define save_cr0_and_clts(x)
00104 #define restore_cr0(x)
00105 #define enable_fpu()
00106 #define load_mxcsr(val)
00107 #define init_xfpu()
00108 #define save_fpenv(x)
00109 #define restore_fpenv(x)
00110 #define restore_task_fpenv(t)
00111 #define restore_fpenv_lxrt(t)
00112
00113 #endif
00114
00115 #endif