]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S
Removed use of pre-initialized global data in this file as it was causing problems...
[mirror_edk2.git] / UefiCpuPkg / Library / BaseUefiCpuLib / X64 / InitializeFpu.S
CommitLineData
989322c3 1#------------------------------------------------------------------------------
2#*
3d49c108 3#* Copyright 2009 - 2010, Intel Corporation
989322c3 4#* All rights reserved. This program and the accompanying materials
5#* are licensed and made available under the terms and conditions of the BSD License
6#* which accompanies this distribution. The full text of the license may be found at
7#* http://opensource.org/licenses/bsd-license.php
8#*
9#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11#*
12#*
13#------------------------------------------------------------------------------
14
989322c3 15#
3d49c108
EB
16# Initializes floating point units for requirement of UEFI specification.
17#
18# This function initializes floating-point control word to 0x027F (all exceptions
19# masked,double-precision, round-to-nearest) and multimedia-extensions control word
20# (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero
989322c3 21# for masked underflow).
22#
23ASM_GLOBAL ASM_PFX(InitializeFloatingPointUnits)
24ASM_PFX(InitializeFloatingPointUnits):
25
3d49c108
EB
26 #
27 # Initialize floating point units
28 #
29 finit
30
31 #
32 # Float control word initial value:
33 # all exceptions masked, double-precision, round-to-nearest
34 #
35 pushq $0x027F
36 lea (%rsp), %rax
37 fldcw (%rax)
38 popq %rax
989322c3 39
40 #
41 # Set OSFXSR bit 9 in CR4
42 #
43 movq %cr4, %rax
44 or $200, %rax
45 movq %rax, %cr4
3d49c108
EB
46
47 #
48 # Multimedia-extensions control word:
49 # all exceptions masked, round-to-nearest, flush to zero for masked underflow
50 #
51 pushq $0x01F80
52 lea (%rsp), %rax
53 ldmxcsr (%rax)
54 popq %rax
989322c3 55
56 ret
57