]>
Commit | Line | Data |
---|---|---|
c8ec22a2 JY |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
3 | ; Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r | |
16a16ea6 | 4 | ; SPDX-License-Identifier: BSD-2-Clause-Patent\r |
c8ec22a2 JY |
5 | ;\r |
6 | ; Abstract:\r | |
7 | ;\r | |
8 | ;------------------------------------------------------------------------------\r | |
9 | \r | |
10 | .686\r | |
11 | .model flat,C\r | |
12 | .const\r | |
13 | ;\r | |
14 | ; Float control word initial value:\r | |
15 | ; all exceptions masked, double-precision, round-to-nearest\r | |
16 | ;\r | |
17 | mFpuControlWord DW 027Fh\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 | mMmxControlWord DD 01F80h\r | |
23 | \r | |
24 | .xmm\r | |
25 | .code\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 | InitializeFloatingPointUnits PROC PUBLIC\r | |
36 | \r | |
37 | push ebx\r | |
38 | \r | |
39 | ;\r | |
40 | ; Initialize floating point units\r | |
41 | ;\r | |
42 | finit\r | |
43 | fldcw mFpuControlWord\r | |
44 | \r | |
45 | ;\r | |
46 | ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test\r | |
47 | ; whether the processor supports SSE instruction.\r | |
48 | ;\r | |
49 | mov eax, 1\r | |
50 | cpuid\r | |
51 | bt edx, 25\r | |
52 | jnc Done\r | |
53 | \r | |
54 | ;\r | |
55 | ; Set OSFXSR bit 9 in CR4\r | |
56 | ;\r | |
57 | mov eax, cr4\r | |
58 | or eax, BIT9\r | |
59 | mov cr4, eax\r | |
60 | \r | |
61 | ;\r | |
62 | ; The processor should support SSE instruction and we can use\r | |
63 | ; ldmxcsr instruction\r | |
64 | ;\r | |
65 | ldmxcsr mMmxControlWord\r | |
66 | Done:\r | |
67 | pop ebx\r | |
68 | \r | |
69 | ret\r | |
70 | \r | |
71 | InitializeFloatingPointUnits ENDP\r | |
72 | \r | |
73 | END\r |