Introduce UefiCpuLib library class in UefiCpuPkg and add one instance of BaseUefiCpuL...
[mirror_edk2.git] / UefiCpuPkg / Library / BaseUefiCpuLib / X64 / 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.const\r
17;\r
18; Float control word initial value: \r
19; all exceptions masked, double-precision, round-to-nearest\r
20;\r
21mFpuControlWord DW 027Fh\r
22;\r
23; Multimedia-extensions control word:\r
24; all exceptions masked, round-to-nearest, flush to zero for masked underflow\r
25;\r
26mMmxControlWord DD 01F80h \r
27\r
28.code\r
29\r
30\r
31;
32; Initializes floating point units for requirement of UEFI specification.\r
33;\r
34; This function initializes floating-point control word to 0x027F (all exceptions\r
35; masked,double-precision, round-to-nearest) and multimedia-extensions control word\r
36; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero\r
37; for masked underflow).
38;\r
39InitializeFloatingPointUnits PROC PUBLIC\r
40\r
41 ;\r
42 ; Initialize floating point units\r
43 ;\r
44 finit\r
45 fldcw mFpuControlWord\r
46 \r
47 ;\r
48 ; Set OSFXSR bit 9 in CR4\r
49 ;\r
50 mov rax, cr4\r
51 or rax, BIT9\r
52 mov cr4, rax\r
53\r
54 ldmxcsr mMmxControlWord\r
55 \r
56 ret\r
57InitializeFloatingPointUnits ENDP\r
58\r
59END\r