1 /* $OpenBSD: fpu.h,v 1.11 2015/03/25 21:05:18 kettenis Exp $ */ 2 /* $NetBSD: fpu.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ 3 4 #ifndef _MACHINE_FPU_H_ 5 #define _MACHINE_FPU_H_ 6 7 #include <sys/types.h> 8 9 /* 10 * amd64 only uses the extended save/restore format used 11 * by fxsave/fsrestore, to always deal with the SSE registers, 12 * which are part of the ABI to pass floating point values. 13 * Must be stored in memory on a 16-byte boundary. 14 */ 15 16 struct fxsave64 { 17 u_int16_t fx_fcw; 18 u_int16_t fx_fsw; 19 u_int8_t fx_ftw; 20 u_int8_t fx_unused1; 21 u_int16_t fx_fop; 22 u_int64_t fx_rip; 23 u_int64_t fx_rdp; 24 u_int32_t fx_mxcsr; 25 u_int32_t fx_mxcsr_mask; 26 u_int64_t fx_st[8][2]; /* 8 normal FP regs */ 27 u_int64_t fx_xmm[16][2]; /* 16 SSE2 registers */ 28 u_int8_t fx_unused3[96]; 29 } __packed; 30 31 struct xstate_hdr { 32 uint64_t xstate_bv; 33 uint64_t xstate_xcomp_bv; 34 uint8_t xstate_rsrv0[0]; 35 uint8_t xstate_rsrv[40]; 36 } __packed; 37 38 struct savefpu { 39 struct fxsave64 fp_fxsave; /* see above */ 40 struct xstate_hdr fp_xstate; 41 u_int64_t fp_ymm[16][2]; 42 u_int16_t fp_ex_sw; /* saved status from last exception */ 43 u_int16_t fp_ex_tw; /* saved tag from last exception */ 44 }; 45 46 /* 47 * The i387 defaults to Intel extended precision mode and round to nearest, 48 * with all exceptions masked. 49 */ 50 #define __INITIAL_NPXCW__ 0x037f 51 #define __INITIAL_MXCSR__ 0x1f80 52 #define __INITIAL_MXCSR_MASK__ 0xffbf 53 54 #ifdef _KERNEL 55 /* 56 * XXX 57 */ 58 struct trapframe; 59 struct cpu_info; 60 61 extern size_t fpu_save_len; 62 extern uint32_t fpu_mxcsr_mask; 63 extern uint64_t xsave_mask; 64 65 void fpuinit(struct cpu_info *); 66 void fpudrop(void); 67 void fpudiscard(struct proc *); 68 void fputrap(struct trapframe *); 69 void fpusave_proc(struct proc *, int); 70 void fpusave_cpu(struct cpu_info *, int); 71 void fpu_kernel_enter(void); 72 void fpu_kernel_exit(void); 73 74 #endif 75 76 #endif /* _MACHINE_FPU_H_ */ 77