Oops, missing files
[reactos.git] / reactos / ntoskrnl / ke / i386 / fpu.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /*
20 * PROJECT: ReactOS kernel
21 * FILE: ntoskrnl/ke/i386/fpu.c
22 * PURPOSE: Handles the FPU
23 * PROGRAMMER: David Welch (welch@mcmail.com)
24 * UPDATE HISTORY:
25 * Created 22/05/98
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <ddk/ntddk.h>
31 #include <internal/ke.h>
32 #include <internal/mm.h>
33 #include <internal/ps.h>
34
35 #define NDEBUG
36 #include <internal/debug.h>
37
38 /* GLOBALS *******************************************************************/
39
40 static ULONG HardwareMathSupport;
41
42 /* FUNCTIONS *****************************************************************/
43
44 VOID
45 KiCheckFPU(VOID)
46 {
47 unsigned short int status;
48 int cr0;
49
50 HardwareMathSupport = 0;
51
52 __asm__("clts\n\t");
53 __asm__("fninit\n\t");
54 __asm__("fstsw %0\n\t" : "=a" (status));
55 if (status != 0)
56 {
57 __asm__("movl %%cr0, %0\n\t" : "=a" (cr0));
58 cr0 = cr0 | 0x4;
59 __asm__("movl %0, %%cr0\n\t" :
60 : "a" (cr0));
61 DbgPrint("No FPU detected\n");
62 return;
63 }
64 /* FIXME: Do fsetpm */
65 HardwareMathSupport = 1;
66 }