summaryrefslogtreecommitdiff
path: root/i386/i386/fpu.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2009-11-28 17:09:38 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2009-11-28 17:09:38 +0100
commit9e608d32e9e85246decd868f326efde66108c7f3 (patch)
tree5fdbd40c0b0833c86447c382a8daf82e1f4ac4a5 /i386/i386/fpu.h
parent77c3d3e9505853ea2d5e1b68f7c7e6c2481cccaf (diff)
Add XMM FPU registers save/restore support.
* i386/include/mach/i386/fp_reg.h (struct i386_fp_regs): Invert array indices. (struct i386_xfp_save): New structure. (FP_387X): New macro. * i386/i386/thread.h (struct i386_fpsave_state): Add xfp_save_state member, keep existing fp_save_state and fp_regs members in an unnamed union member. Move fp_valid member to the end of the structure. * i386/i386/fpu.h (fxsave, fxrstor): New macros. (fpu_save_context): Use fxsave() when FPU is FXSR-capable. * i386/i386/fpu.c: Include <i386/locore.h> (mxcsr_feature_mask): New variable. (fp_save, fp_load): Add declaration. (init_fpu): Add FXSR-capable FPU detection. (fpu_module_init): Request 16-byte alignment to zinit() for i386_fpsave_state structures. (twd_i387_to_fxsr, twd_fxsr_to_i387): New functions. (fpu_set_state): Convert FPU state when FPU is FXSR-capable. (fpu_get_state): Convert FPU state when FPU is FXSR-capable. (fpexterrflt): Pass to i386_exception either xfp_save_state or fp_save_state according to FPU type. (fpastintr): Likewise. (fp_load): Likewise. Use fxrstor() when FPU is FXSR-capable. (fp_save): Use fxsave() when FPU is FXSR-capable. (fp_state_alloc): Add FXSR-aware initialization.
Diffstat (limited to 'i386/i386/fpu.h')
-rw-r--r--i386/i386/fpu.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/i386/i386/fpu.h b/i386/i386/fpu.h
index 7efb7e2..1a1b61f 100644
--- a/i386/i386/fpu.h
+++ b/i386/i386/fpu.h
@@ -67,6 +67,12 @@
#define frstor(state) \
asm volatile("frstor %0" : : "m" (state))
+#define fxsave(state) \
+ asm volatile("fxsave %0" : "=m" (*state))
+
+#define fxrstor(state) \
+ asm volatile("fxrstor %0" : : "m" (state))
+
#define fwait() \
asm("fwait");
@@ -86,7 +92,10 @@
if (ifps != 0 && !ifps->fp_valid) { \
/* registers are in FPU - save to memory */ \
ifps->fp_valid = TRUE; \
- fnsave(&ifps->fp_save_state); \
+ if (fp_kind == FP_387X) \
+ fxsave(&ifps->xfp_save_state); \
+ else \
+ fnsave(&ifps->fp_save_state); \
set_ts(); \
} \
}