]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/fpu.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991 Carnegie Mellon University
31 * All Rights Reserved.
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
61 * Macro definitions for routines to manipulate the
62 * floating-point processor.
66 #include <i386/proc_reg.h>
67 #include <i386/thread.h>
68 #include <kern/kern_types.h>
69 #include <mach/i386/kern_return.h>
70 #include <mach/i386/thread_status.h>
76 __asm__ volatile("fninit")
78 #define fnstcw(control) \
79 __asm__("fnstcw %0" : "=m" (*(unsigned short *)(control)))
81 #define fldcw(control) \
82 __asm__ volatile("fldcw %0" : : "m" (*(unsigned short *) &(control)) )
84 extern unsigned short fnstsw(void);
86 extern __inline__
unsigned short fnstsw(void)
88 unsigned short status
;
89 __asm__
volatile("fnstsw %0" : "=ma" (status
));
94 __asm__ volatile("fnclex")
96 #define fnsave(state) \
97 __asm__ volatile("fnsave %0" : "=m" (*state))
99 #define frstor(state) \
100 __asm__ volatile("frstor %0" : : "m" (state))
106 #define fpu_load_context(pcb)
109 * Save thread`s FPU context.
110 * If only one CPU, we just set the task-switched bit,
111 * to keep the new thread from using the coprocessor.
112 * If multiple CPUs, we save the entire state.
115 #define fpu_save_context(thread) \
117 register struct i386_fpsave_state *ifps; \
118 ifps = (thread)->top_act->mact.pcb->ims.ifps; \
119 if (ifps != 0 && !ifps->fp_valid) { \
120 /* registers are in FPU - save to memory */ \
121 ifps->fp_valid = TRUE; \
122 fnsave(&ifps->fp_save_state); \
127 #else /* NCPUS == 1 */
128 #define fpu_save_context(thread) \
133 #endif /* NCPUS == 1 */
138 extern void init_fpu(void);
139 extern void fpu_module_init(void);
141 struct i386_fpsave_state
* fps
);
142 extern kern_return_t
fpu_set_state(
143 thread_act_t thr_act
,
144 struct i386_float_state
* st
);
145 extern kern_return_t
fpu_get_state(
146 thread_act_t thr_act
,
147 struct i386_float_state
* st
);
148 extern void fpnoextflt(void);
149 extern void fpextovrflt(void);
150 extern void fpexterrflt(void);
151 extern void fp_state_alloc(void);
152 extern void fpintr(void);
153 extern void fpflush(thread_act_t
);
155 #endif /* _I386_FPU_H_ */