]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/X86Msr.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86Msr.c
index 9430980401b4f571a4a52429b37ebf32ee2cb2d0..1995cb8fd31213b697de42b521609dd7c90adb40 100644 (file)
@@ -1,21 +1,13 @@
 /** @file\r
   IA-32/x64 MSR functions.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-\r
 #include "BaseLibInternals.h"\r
 \r
-\r
 /**\r
   Returns the lower 32-bits of a Machine Specific Register(MSR).\r
 \r
@@ -33,7 +25,7 @@
 UINT32\r
 EFIAPI\r
 AsmReadMsr32 (\r
-  IN      UINT32                    Index\r
+  IN      UINT32  Index\r
   )\r
 {\r
   return (UINT32)AsmReadMsr64 (Index);\r
@@ -59,8 +51,8 @@ AsmReadMsr32 (
 UINT32\r
 EFIAPI\r
 AsmWriteMsr32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT32                    Value\r
+  IN      UINT32  Index,\r
+  IN      UINT32  Value\r
   )\r
 {\r
   return (UINT32)AsmWriteMsr64 (Index, Value);\r
@@ -88,8 +80,8 @@ AsmWriteMsr32 (
 UINT32\r
 EFIAPI\r
 AsmMsrOr32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT32                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   return (UINT32)AsmMsrOr64 (Index, OrData);\r
@@ -117,8 +109,8 @@ AsmMsrOr32 (
 UINT32\r
 EFIAPI\r
 AsmMsrAnd32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT32                    AndData\r
+  IN      UINT32  Index,\r
+  IN      UINT32  AndData\r
   )\r
 {\r
   return (UINT32)AsmMsrAnd64 (Index, AndData);\r
@@ -149,9 +141,9 @@ AsmMsrAnd32 (
 UINT32\r
 EFIAPI\r
 AsmMsrAndThenOr32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT32                    AndData,\r
-  IN      UINT32                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINT32  AndData,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData);\r
@@ -182,9 +174,9 @@ AsmMsrAndThenOr32 (
 UINT32\r
 EFIAPI\r
 AsmMsrBitFieldRead32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit\r
   )\r
 {\r
   return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit);\r
@@ -196,8 +188,8 @@ AsmMsrBitFieldRead32 (
   Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
   field is specified by the StartBit and the EndBit. All other bits in the\r
   destination MSR are preserved. The lower 32-bits of the MSR written is\r
-  returned. The caller must either guarantee that Index and the data written \r
-  is valid, or the caller must set up exception handlers to catch the exceptions. \r
+  returned. The caller must either guarantee that Index and the data written\r
+  is valid, or the caller must set up exception handlers to catch the exceptions.\r
   This function is only available on IA-32 and x64.\r
 \r
   If StartBit is greater than 31, then ASSERT().\r
@@ -218,10 +210,10 @@ AsmMsrBitFieldRead32 (
 UINT32\r
 EFIAPI\r
 AsmMsrBitFieldWrite32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    Value\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  Value\r
   )\r
 {\r
   ASSERT (EndBit < sizeof (Value) * 8);\r
@@ -259,10 +251,10 @@ AsmMsrBitFieldWrite32 (
 UINT32\r
 EFIAPI\r
 AsmMsrBitFieldOr32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   ASSERT (EndBit < sizeof (OrData) * 8);\r
@@ -300,10 +292,10 @@ AsmMsrBitFieldOr32 (
 UINT32\r
 EFIAPI\r
 AsmMsrBitFieldAnd32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    AndData\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  AndData\r
   )\r
 {\r
   ASSERT (EndBit < sizeof (AndData) * 8);\r
@@ -345,11 +337,11 @@ AsmMsrBitFieldAnd32 (
 UINT32\r
 EFIAPI\r
 AsmMsrBitFieldAndThenOr32 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    AndData,\r
-  IN      UINT32                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  AndData,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   ASSERT (EndBit < sizeof (AndData) * 8);\r
@@ -384,8 +376,8 @@ AsmMsrBitFieldAndThenOr32 (
 UINT64\r
 EFIAPI\r
 AsmMsrOr64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT64                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINT64  OrData\r
   )\r
 {\r
   return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData);\r
@@ -412,15 +404,15 @@ AsmMsrOr64 (
 UINT64\r
 EFIAPI\r
 AsmMsrAnd64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT64                    AndData\r
+  IN      UINT32  Index,\r
+  IN      UINT64  AndData\r
   )\r
 {\r
   return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData);\r
 }\r
 \r
 /**\r
-  Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise \r
+  Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise\r
   OR, and writes the result back to the 64-bit MSR.\r
 \r
   Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
@@ -443,9 +435,9 @@ AsmMsrAnd64 (
 UINT64\r
 EFIAPI\r
 AsmMsrAndThenOr64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINT64                    AndData,\r
-  IN      UINT64                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINT64  AndData,\r
+  IN      UINT64  OrData\r
   )\r
 {\r
   return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData);\r
@@ -476,9 +468,9 @@ AsmMsrAndThenOr64 (
 UINT64\r
 EFIAPI\r
 AsmMsrBitFieldRead64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit\r
   )\r
 {\r
   return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit);\r
@@ -489,8 +481,8 @@ AsmMsrBitFieldRead64 (
 \r
   Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
   the StartBit and the EndBit. All other bits in the destination MSR are\r
-  preserved. The MSR written is returned. The caller must either guarantee \r
-  that Index and the data written is valid, or the caller must set up exception \r
+  preserved. The MSR written is returned. The caller must either guarantee\r
+  that Index and the data written is valid, or the caller must set up exception\r
   handlers to catch the exceptions. This function is only available on IA-32 and x64.\r
 \r
   If StartBit is greater than 63, then ASSERT().\r
@@ -511,10 +503,10 @@ AsmMsrBitFieldRead64 (
 UINT64\r
 EFIAPI\r
 AsmMsrBitFieldWrite64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT64                    Value\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT64  Value\r
   )\r
 {\r
   return AsmWriteMsr64 (\r
@@ -553,10 +545,10 @@ AsmMsrBitFieldWrite64 (
 UINT64\r
 EFIAPI\r
 AsmMsrBitFieldOr64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT64                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT64  OrData\r
   )\r
 {\r
   return AsmWriteMsr64 (\r
@@ -595,10 +587,10 @@ AsmMsrBitFieldOr64 (
 UINT64\r
 EFIAPI\r
 AsmMsrBitFieldAnd64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT64                    AndData\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT64  AndData\r
   )\r
 {\r
   return AsmWriteMsr64 (\r
@@ -640,11 +632,11 @@ AsmMsrBitFieldAnd64 (
 UINT64\r
 EFIAPI\r
 AsmMsrBitFieldAndThenOr64 (\r
-  IN      UINT32                    Index,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT64                    AndData,\r
-  IN      UINT64                    OrData\r
+  IN      UINT32  Index,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT64  AndData,\r
+  IN      UINT64  OrData\r
   )\r
 {\r
   return AsmWriteMsr64 (\r