X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/4452a7af2eac33dbad800bcc91f2399d62c18f53..b0d623f7f2ae71ed96e60569f61f9a9a27016e80:/osfmk/i386/fpu.h diff --git a/osfmk/i386/fpu.h b/osfmk/i386/fpu.h index 7979b66fa..7b6f86a82 100644 --- a/osfmk/i386/fpu.h +++ b/osfmk/i386/fpu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -54,9 +54,6 @@ * the rights to redistribute these changes. */ -/* - */ - #ifndef _I386_FPU_H_ #define _I386_FPU_H_ @@ -65,11 +62,11 @@ * floating-point processor. */ #include -#include #include #include #include #include +#include extern int fp_kind; @@ -92,8 +89,10 @@ extern void fpexterrflt(void); extern void fpSSEexterrflt(void); extern void fpflush(thread_t); extern void fp_setvalid(boolean_t); +#ifdef __i386__ extern void fxsave64(struct x86_fx_save *); extern void fxrstor64(struct x86_fx_save *); +#endif /* * FPU instructions. @@ -107,9 +106,8 @@ extern void fxrstor64(struct x86_fx_save *); #define fldcw(control) \ __asm__ volatile("fldcw %0" : : "m" (*(unsigned short *) &(control)) ) -extern unsigned short fnstsw(void); - -extern __inline__ unsigned short fnstsw(void) +static inline unsigned short +fnstsw(void) { unsigned short status; __asm__ volatile("fnstsw %0" : "=ma" (status)); @@ -139,6 +137,7 @@ static inline void clear_fpu(void) set_ts(); } + /* * Save thread`s FPU context. */ @@ -158,6 +157,8 @@ static inline void fpu_save_context(thread_t thread) clear_ts(); /* registers are in FPU - save to memory */ ifps->fp_valid = TRUE; + +#if defined(__i386__) if (!thread_is_64bit(thread) || is_saved_state32(thread->machine.pcb->iss)) { /* save the compatibility/legacy mode XMM+x87 state */ fxsave(&ifps->fx_save_state); @@ -170,6 +171,13 @@ static inline void fpu_save_context(thread_t thread) fxsave64(&ifps->fx_save_state); ifps->fp_save_layout = FXSAVE64; } +#elif defined(__x86_64__) + /* for a 64-bit long mode kernel, we can always use plain fxsave */ + fxsave(&ifps->fx_save_state); + ifps->fp_save_layout = thread_is_64bit(thread) ? FXSAVE64 + : FXSAVE32; + +#endif } set_ts(); }