]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S
UefiCpuPkg: Clean up source files
[mirror_edk2.git] / UefiCpuPkg / Library / BaseUefiCpuLib / X64 / InitializeFpu.S
CommitLineData
7798fb83
HT
1#------------------------------------------------------------------------------\r
2#*\r
7367cc6c 3#* Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
7798fb83
HT
4#* 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# Initializes floating point units for requirement of UEFI specification.\r
17#\r
18# This function initializes floating-point control word to 0x037F (all exceptions\r
19# masked,double-extended-precision, round-to-nearest) and multimedia-extensions control word\r
20# (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero\r
21# for masked underflow).\r
22#\r
23ASM_GLOBAL ASM_PFX(InitializeFloatingPointUnits)\r
24ASM_PFX(InitializeFloatingPointUnits):\r
25\r
26 #\r
27 # Initialize floating point units\r
28 #\r
29 finit\r
7367cc6c 30\r
7798fb83 31 #\r
7367cc6c 32 # Float control word initial value:\r
7798fb83
HT
33 # all exceptions masked, double-precision, round-to-nearest\r
34 #\r
35 pushq $0x037F\r
7367cc6c 36 lea (%rsp), %rax\r
7798fb83
HT
37 fldcw (%rax)\r
38 popq %rax\r
7367cc6c 39\r
7798fb83
HT
40 #\r
41 # Set OSFXSR bit 9 in CR4\r
42 #\r
7367cc6c 43 movq %cr4, %rax\r
7798fb83
HT
44 or $0x200, %rax\r
45 movq %rax, %cr4\r
46\r
47 #\r
48 # Multimedia-extensions control word:\r
49 # all exceptions masked, round-to-nearest, flush to zero for masked underflow\r
7367cc6c 50 #\r
7798fb83
HT
51 pushq $0x01F80\r
52 lea (%rsp), %rax\r
53 ldmxcsr (%rax)\r
54 popq %rax\r
7367cc6c 55\r
7798fb83
HT
56 ret\r
57\r