/** @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
UINT32\r
EFIAPI\r
AsmReadMsr32 (\r
- IN UINT32 Index\r
+ IN UINT32 Index\r
)\r
{\r
return (UINT32)AsmReadMsr64 (Index);\r
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
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
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
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
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
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
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
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
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
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
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
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
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
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
\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
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
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
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
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