]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm
OVMF SEC: Modify to match new interface of reset vector module
[mirror_edk2.git] / UefiCpuPkg / Library / BaseUefiCpuLib / Ia32 / InitializeFpu.asm
CommitLineData
989322c3 1;------------------------------------------------------------------------------\r
2;*\r
3;* Copyright 2009, Intel Corporation\r
4;* All rights reserved. This program and the accompanying materials\r
5;* are licensed and made available under the terms and conditions of the BSD License\r
6;* which accompanies this distribution. The full text of the license may be found at\r
7;* http://opensource.org/licenses/bsd-license.php\r
8;*\r
9;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11;*\r
12;* \r
13;------------------------------------------------------------------------------\r
14\r
15\r
16 .686\r
17 .model flat,C\r
18 .const\r
19;\r
20; Float control word initial value: \r
21; all exceptions masked, double-precision, round-to-nearest\r
22;\r
23mFpuControlWord DW 027Fh\r
24;\r
25; Multimedia-extensions control word:\r
26; all exceptions masked, round-to-nearest, flush to zero for masked underflow\r
27;\r
28mMmxControlWord DD 01F80h \r
29\r
30 .xmm\r
31 .code\r
32\r
33;
34; Initializes floating point units for requirement of UEFI specification.\r
35;\r
36; This function initializes floating-point control word to 0x027F (all exceptions\r
37; masked,double-precision, round-to-nearest) and multimedia-extensions control word\r
38; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero\r
39; for masked underflow).
40;\r
41InitializeFloatingPointUnits PROC PUBLIC\r
42 ;\r
43 ; Initialize floating point units\r
44 ;\r
45 finit\r
46 fldcw mFpuControlWord\r
47 \r
48 ;\r
49 ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test\r
50 ; whether the processor supports SSE instruction.\r
51 ;\r
52 mov eax, 1\r
53 cpuid\r
54 bt edx, 25\r
55 jnc Done\r
56 \r
57 ;\r
58 ; Set OSFXSR bit 9 in CR4\r
59 ;\r
60 mov eax, cr4\r
61 or eax, BIT9\r
62 mov cr4, eax\r
63 \r
64 ;\r
65 ; The processor should support SSE instruction and we can use\r
66 ; ldmxcsr instruction\r
67 ;\r
68 ldmxcsr mMmxControlWord\r
69Done:\r
70\r
71 ret\r
72\r
73InitializeFloatingPointUnits ENDP\r
74\r
75END\r