]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
58 * Macro definitions for routines to manipulate the
59 * floating-point processor.
63 #include <i386/proc_reg.h>
64 #include <i386/thread.h>
65 #include <kern/kern_types.h>
66 #include <mach/i386/kern_return.h>
67 #include <mach/i386/thread_status.h>
73 __asm__ volatile("fninit")
75 #define fnstcw(control) \
76 __asm__("fnstcw %0" : "=m" (*(unsigned short *)(control)))
78 #define fldcw(control) \
79 __asm__ volatile("fldcw %0" : : "m" (*(unsigned short *) &(control)) )
81 extern unsigned short fnstsw(void);
83 extern __inline__
unsigned short fnstsw(void)
85 unsigned short status
;
86 __asm__
volatile("fnstsw %0" : "=ma" (status
));
91 __asm__ volatile("fnclex")
93 #define fnsave(state) \
94 __asm__ volatile("fnsave %0" : "=m" (*state))
96 #define frstor(state) \
97 __asm__ volatile("frstor %0" : : "m" (state))
103 #define fpu_load_context(pcb)
106 * Save thread`s FPU context.
107 * If only one CPU, we just set the task-switched bit,
108 * to keep the new thread from using the coprocessor.
109 * If multiple CPUs, we save the entire state.
112 #define fpu_save_context(thread) \
114 register struct i386_fpsave_state *ifps; \
115 ifps = (thread)->top_act->mact.pcb->ims.ifps; \
116 if (ifps != 0 && !ifps->fp_valid) { \
117 /* registers are in FPU - save to memory */ \
118 ifps->fp_valid = TRUE; \
119 fnsave(&ifps->fp_save_state); \
124 #else /* NCPUS == 1 */
125 #define fpu_save_context(thread) \
130 #endif /* NCPUS == 1 */
135 extern void init_fpu(void);
136 extern void fpu_module_init(void);
138 struct i386_fpsave_state
* fps
);
139 extern kern_return_t
fpu_set_state(
140 thread_act_t thr_act
,
141 struct i386_float_state
* st
);
142 extern kern_return_t
fpu_get_state(
143 thread_act_t thr_act
,
144 struct i386_float_state
* st
);
145 extern void fpnoextflt(void);
146 extern void fpextovrflt(void);
147 extern void fpexterrflt(void);
148 extern void fp_state_alloc(void);
149 extern void fpintr(void);
150 extern void fpflush(thread_act_t
);
152 #endif /* _I386_FPU_H_ */