]>
Commit | Line | Data |
---|---|---|
cf1d4549 JY |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
efa12a3f | 3 | ; Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r |
9672cd30 | 4 | ; SPDX-License-Identifier: BSD-2-Clause-Patent\r |
cf1d4549 JY |
5 | ;\r |
6 | ; Abstract:\r | |
7 | ;\r | |
8 | ;------------------------------------------------------------------------------\r | |
9 | \r | |
10 | \r | |
11 | SECTION .data\r | |
12 | ;\r | |
13 | ; Float control word initial value:\r | |
14 | ; all exceptions masked, double-precision, round-to-nearest\r | |
15 | ;\r | |
16 | ASM_PFX(mFpuControlWord):\r | |
17 | dw 0x027F\r | |
18 | ;\r | |
19 | ; Multimedia-extensions control word:\r | |
20 | ; all exceptions masked, round-to-nearest, flush to zero for masked underflow\r | |
21 | ;\r | |
22 | ASM_PFX(mMmxControlWord):\r | |
23 | dd 0x01F80\r | |
24 | \r | |
25 | SECTION .text\r | |
26 | \r | |
27 | ;\r | |
28 | ; Initializes floating point units for requirement of UEFI specification.\r | |
29 | ;\r | |
30 | ; This function initializes floating-point control word to 0x027F (all exceptions\r | |
31 | ; masked,double-precision, round-to-nearest) and multimedia-extensions control word\r | |
32 | ; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero\r | |
33 | ; for masked underflow).\r | |
34 | ;\r | |
35 | \r | |
36 | global ASM_PFX(InitializeFloatingPointUnits)\r | |
37 | ASM_PFX(InitializeFloatingPointUnits):\r | |
38 | \r | |
39 | \r | |
40 | push ebx\r | |
41 | \r | |
42 | ;\r | |
43 | ; Initialize floating point units\r | |
44 | ;\r | |
45 | finit\r | |
46 | fldcw [ASM_PFX(mFpuControlWord)]\r | |
47 | \r | |
48 | ;\r | |
efa12a3f | 49 | ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test\r |
cf1d4549 JY |
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 [ASM_PFX(mMmxControlWord)]\r | |
69 | Done:\r | |
70 | pop ebx\r | |
71 | \r | |
72 | ret\r |