--- /dev/null
+/** @file\r
+ IA-32/x64 MSR functions.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. 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
+\r
+**/\r
+\r
+\r
+#include <BaseLibInternals.h>\r
+\r
+\r
+/**\r
+ Returns the lower 32-bits of a Machine Specific Register(MSR).\r
+\r
+ Reads and returns the lower 32-bits of the MSR specified by Index.\r
+ No parameter checking is performed on Index, and some Index values may cause\r
+ CPU exceptions. The caller must either guarantee that Index is valid, or the\r
+ caller must set up exception handlers to catch the exceptions. This function\r
+ is only available on IA-32 and X64.\r
+\r
+ @param Index The 32-bit MSR index to read.\r
+\r
+ @return The lower 32 bits of the MSR identified by Index.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmReadMsr32 (\r
+ IN UINT32 Index\r
+ )\r
+{\r
+ return (UINT32)AsmReadMsr64 (Index);\r
+}\r
+\r
+/**\r
+ Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
+\r
+ Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
+ upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
+ the MSR is returned. No parameter checking is performed on Index or Value,\r
+ and some of these may cause CPU exceptions. The caller must either guarantee\r
+ that Index and Value are valid, or the caller must establish proper exception\r
+ handlers. This function is only available on IA-32 and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param Value The 32-bit value to write to the MSR.\r
+\r
+ @return Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmWriteMsr32 (\r
+ IN UINT32 Index,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ return (UINT32)AsmWriteMsr64 (Index, Value);\r
+}\r
+\r
+/**\r
+ Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r
+ writes the result back to the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+ between the lower 32-bits of the read result and the value specified by\r
+ OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
+ 32-bits of the value written to the MSR is returned. No parameter checking is\r
+ performed on Index or OrData, and some of these may cause CPU exceptions. The\r
+ caller must either guarantee that Index and OrData are valid, or the caller\r
+ must establish proper exception handlers. This function is only available on\r
+ IA-32 and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param OrData The value to OR with the read value from the MSR.\r
+\r
+ @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrOr32 (\r
+ IN UINT32 Index,\r
+ IN UINT32 OrData\r
+ )\r
+{\r
+ return (UINT32)AsmMsrOr64 (Index, OrData);\r
+}\r
+\r
+/**\r
+ Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
+ the result back to the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+ lower 32-bits of the read result and the value specified by AndData, and\r
+ writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
+ the value written to the MSR is returned. No parameter checking is performed\r
+ on Index or AndData, and some of these may cause CPU exceptions. The caller\r
+ must either guarantee that Index and AndData are valid, or the caller must\r
+ establish proper exception handlers. This function is only available on IA-32\r
+ and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param AndData The value to AND with the read value from the MSR.\r
+\r
+ @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrAnd32 (\r
+ IN UINT32 Index,\r
+ IN UINT32 AndData\r
+ )\r
+{\r
+ return (UINT32)AsmMsrAnd64 (Index, AndData);\r
+}\r
+\r
+/**\r
+ Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r
+ on the lower 32-bits, 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 the\r
+ lower 32-bits of the read result and the value specified by AndData\r
+ preserving the upper 32-bits, performs a bitwise inclusive OR between the\r
+ result of the AND operation and the value specified by OrData, and writes the\r
+ result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
+ written to the MSR is returned. No parameter checking is performed on Index,\r
+ AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
+ must either guarantee that Index, AndData, and OrData are valid, or the\r
+ caller must establish proper exception handlers. This function is only\r
+ available on IA-32 and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param AndData The value to AND with the read value from the MSR.\r
+ @param OrData The value to OR with the result of the AND operation.\r
+\r
+ @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrAndThenOr32 (\r
+ IN UINT32 Index,\r
+ IN UINT32 AndData,\r
+ IN UINT32 OrData\r
+ )\r
+{\r
+ return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData);\r
+}\r
+\r
+/**\r
+ Reads a bit field of an MSR.\r
+\r
+ Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
+ specified by the StartBit and the EndBit. The value of the bit field is\r
+ returned. The caller must either guarantee that Index is valid, or the caller\r
+ must set up exception handlers to catch the exceptions. This function is only\r
+ available on IA-32 and X64.\r
+\r
+ If StartBit is greater than 31, then ASSERT().\r
+ If EndBit is greater than 31, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to read.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..31.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..31.\r
+\r
+ @return The bit field read from the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldRead32 (\r
+ IN UINT32 Index,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit\r
+ )\r
+{\r
+ return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+ Writes a bit field to an MSR.\r
+\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. Extra left bits in Value are stripped. The caller must either\r
+ guarantee that Index and the data written is valid, or the caller must set up\r
+ exception handlers to catch the exceptions. This function is only available\r
+ on IA-32 and X64.\r
+\r
+ If StartBit is greater than 31, then ASSERT().\r
+ If EndBit is greater than 31, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..31.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..31.\r
+ @param Value New value of the bit field.\r
+\r
+ @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldWrite32 (\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
+ ASSERT (StartBit <= EndBit);\r
+ return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+ Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
+ result back to the bit field in the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+ between the read result and the value specified by OrData, and writes the\r
+ result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
+ written to the MSR are returned. Extra left bits in OrData are stripped. The\r
+ caller must either guarantee that Index and the data written is valid, or\r
+ the caller must set up exception handlers to catch the exceptions. This\r
+ function is only available on IA-32 and X64.\r
+\r
+ If StartBit is greater than 31, then ASSERT().\r
+ If EndBit is greater than 31, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..31.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..31.\r
+ @param OrData The value to OR with the read value from the MSR.\r
+\r
+ @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldOr32 (\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
+ ASSERT (StartBit <= EndBit);\r
+ return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
+ result back to the bit field in the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+ read result and the value specified by AndData, and writes the result to the\r
+ 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
+ MSR are returned. Extra left bits in AndData are stripped. The caller must\r
+ either guarantee that Index and the data written is valid, or the caller must\r
+ set up exception handlers to catch the exceptions. This function is only\r
+ available on IA-32 and X64.\r
+\r
+ If StartBit is greater than 31, then ASSERT().\r
+ If EndBit is greater than 31, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..31.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..31.\r
+ @param AndData The value to AND with the read value from the MSR.\r
+\r
+ @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldAnd32 (\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
+ ASSERT (StartBit <= EndBit);\r
+ return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
+ bitwise inclusive OR, and writes the result back to the bit field in the\r
+ 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
+ bitwise inclusive OR between the read result and the value specified by\r
+ AndData, and writes the result to the 64-bit MSR specified by Index. The\r
+ lower 32-bits of the value written to the MSR are returned. Extra left bits\r
+ in both AndData and OrData are stripped. 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\r
+ and X64.\r
+\r
+ If StartBit is greater than 31, then ASSERT().\r
+ If EndBit is greater than 31, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..31.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..31.\r
+ @param AndData The value to AND with the read value from the MSR.\r
+ @param OrData The value to OR with the result of the AND operation.\r
+\r
+ @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\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
+ )\r
+{\r
+ ASSERT (EndBit < sizeof (AndData) * 8);\r
+ ASSERT (StartBit <= EndBit);\r
+ return (UINT32)AsmMsrBitFieldAndThenOr64 (\r
+ Index,\r
+ StartBit,\r
+ EndBit,\r
+ AndData,\r
+ OrData\r
+ );\r
+}\r
+\r
+/**\r
+ Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r
+ back to the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+ between the read result and the value specified by OrData, and writes the\r
+ result to the 64-bit MSR specified by Index. The value written to the MSR is\r
+ returned. No parameter checking is performed on Index or OrData, and some of\r
+ these may cause CPU exceptions. The caller must either guarantee that Index\r
+ and OrData are valid, or the caller must establish proper exception handlers.\r
+ This function is only available on IA-32 and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param OrData The value to OR with the read value from the MSR.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrOr64 (\r
+ IN UINT32 Index,\r
+ IN UINT64 OrData\r
+ )\r
+{\r
+ return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData);\r
+}\r
+\r
+/**\r
+ Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
+ 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+ read result and the value specified by OrData, and writes the result to the\r
+ 64-bit MSR specified by Index. The value written to the MSR is returned. No\r
+ parameter checking is performed on Index or OrData, and some of these may\r
+ cause CPU exceptions. The caller must either guarantee that Index and OrData\r
+ are valid, or the caller must establish proper exception handlers. This\r
+ function is only available on IA-32 and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param AndData The value to AND with the read value from the MSR.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrAnd64 (\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 inclusive\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
+ result and the value specified by AndData, performs a bitwise inclusive OR\r
+ between the result of the AND operation and the value specified by OrData,\r
+ and writes the result to the 64-bit MSR specified by Index. The value written\r
+ to the MSR is returned. No parameter checking is performed on Index, AndData,\r
+ or OrData, and some of these may cause CPU exceptions. The caller must either\r
+ guarantee that Index, AndData, and OrData are valid, or the caller must\r
+ establish proper exception handlers. This function is only available on IA-32\r
+ and X64.\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param AndData The value to AND with the read value from the MSR.\r
+ @param OrData The value to OR with the result of the AND operation.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrAndThenOr64 (\r
+ IN UINT32 Index,\r
+ IN UINT64 AndData,\r
+ IN UINT64 OrData\r
+ )\r
+{\r
+ return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+ Reads a bit field of an MSR.\r
+\r
+ Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
+ StartBit and the EndBit. The value of the bit field is returned. The caller\r
+ must either guarantee that Index is valid, or the caller must set up\r
+ exception handlers to catch the exceptions. This function is only available\r
+ on IA-32 and X64.\r
+\r
+ If StartBit is greater than 63, then ASSERT().\r
+ If EndBit is greater than 63, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to read.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..63.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..63.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldRead64 (\r
+ IN UINT32 Index,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit\r
+ )\r
+{\r
+ return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+ Writes a bit field to an MSR.\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. Extra left bits in Value are\r
+ stripped. The caller must either guarantee that Index and the data written is\r
+ 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 63, then ASSERT().\r
+ If EndBit is greater than 63, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..63.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..63.\r
+ @param Value New value of the bit field.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldWrite64 (\r
+ IN UINT32 Index,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit,\r
+ IN UINT64 Value\r
+ )\r
+{\r
+ return AsmWriteMsr64 (\r
+ Index,\r
+ BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value)\r
+ );\r
+}\r
+\r
+/**\r
+ Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r
+ writes the result back to the bit field in the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+ between the read result and the value specified by OrData, and writes the\r
+ result to the 64-bit MSR specified by Index. The value written to the MSR is\r
+ returned. Extra left bits in OrData are stripped. The caller must either\r
+ guarantee that Index and the data written is valid, or the caller must set up\r
+ exception handlers to catch the exceptions. This function is only available\r
+ on IA-32 and X64.\r
+\r
+ If StartBit is greater than 63, then ASSERT().\r
+ If EndBit is greater than 63, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..63.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..63.\r
+ @param OrData The value to OR with the read value from the bit field.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldOr64 (\r
+ IN UINT32 Index,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit,\r
+ IN UINT64 OrData\r
+ )\r
+{\r
+ return AsmWriteMsr64 (\r
+ Index,\r
+ BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData)\r
+ );\r
+}\r
+\r
+/**\r
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
+ result back to the bit field in the 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+ read result and the value specified by AndData, and writes the result to the\r
+ 64-bit MSR specified by Index. The value written to the MSR is returned.\r
+ Extra left bits in AndData are stripped. 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\r
+ and X64.\r
+\r
+ If StartBit is greater than 63, then ASSERT().\r
+ If EndBit is greater than 63, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..63.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..63.\r
+ @param AndData The value to AND with the read value from the bit field.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldAnd64 (\r
+ IN UINT32 Index,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit,\r
+ IN UINT64 AndData\r
+ )\r
+{\r
+ return AsmWriteMsr64 (\r
+ Index,\r
+ BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData)\r
+ );\r
+}\r
+\r
+/**\r
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
+ bitwise inclusive OR, and writes the result back to the bit field in the\r
+ 64-bit MSR.\r
+\r
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
+ a bitwise inclusive OR between the read result and the value specified by\r
+ AndData, and writes the result to the 64-bit MSR specified by Index. The\r
+ value written to the MSR is returned. Extra left bits in both AndData and\r
+ OrData are stripped. The caller must either guarantee that Index and the data\r
+ written is valid, or the caller must set up exception handlers to catch the\r
+ exceptions. This function is only available on IA-32 and X64.\r
+\r
+ If StartBit is greater than 63, then ASSERT().\r
+ If EndBit is greater than 63, then ASSERT().\r
+ If EndBit is less than StartBit, then ASSERT().\r
+\r
+ @param Index The 32-bit MSR index to write.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ Range 0..63.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ Range 0..63.\r
+ @param AndData The value to AND with the read value from the bit field.\r
+ @param OrData The value to OR with the result of the AND operation.\r
+\r
+ @return The value written back to the MSR.\r
+\r
+**/\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
+ )\r
+{\r
+ return AsmWriteMsr64 (\r
+ Index,\r
+ BitFieldAndThenOr64 (\r
+ AsmReadMsr64 (Index),\r
+ StartBit,\r
+ EndBit,\r
+ AndData,\r
+ OrData\r
+ )\r
+ );\r
+}\r
+++ /dev/null
-/** @file\r
- IA-32/x64 MSR functions.\r
-\r
- Copyright (c) 2006, Intel Corporation<BR>\r
- All rights reserved. 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
-\r
-**/\r
-\r
-\r
-#include <BaseLibInternals.h>\r
-\r
-\r
-/**\r
- Returns the lower 32-bits of a Machine Specific Register(MSR).\r
-\r
- Reads and returns the lower 32-bits of the MSR specified by Index.\r
- No parameter checking is performed on Index, and some Index values may cause\r
- CPU exceptions. The caller must either guarantee that Index is valid, or the\r
- caller must set up exception handlers to catch the exceptions. This function\r
- is only available on IA-32 and X64.\r
-\r
- @param Index The 32-bit MSR index to read.\r
-\r
- @return The lower 32 bits of the MSR identified by Index.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmReadMsr32 (\r
- IN UINT32 Index\r
- )\r
-{\r
- return (UINT32)AsmReadMsr64 (Index);\r
-}\r
-\r
-/**\r
- Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
-\r
- Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
- upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
- the MSR is returned. No parameter checking is performed on Index or Value,\r
- and some of these may cause CPU exceptions. The caller must either guarantee\r
- that Index and Value are valid, or the caller must establish proper exception\r
- handlers. This function is only available on IA-32 and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param Value The 32-bit value to write to the MSR.\r
-\r
- @return Value\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmWriteMsr32 (\r
- IN UINT32 Index,\r
- IN UINT32 Value\r
- )\r
-{\r
- return (UINT32)AsmWriteMsr64 (Index, Value);\r
-}\r
-\r
-/**\r
- Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r
- writes the result back to the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
- between the lower 32-bits of the read result and the value specified by\r
- OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
- 32-bits of the value written to the MSR is returned. No parameter checking is\r
- performed on Index or OrData, and some of these may cause CPU exceptions. The\r
- caller must either guarantee that Index and OrData are valid, or the caller\r
- must establish proper exception handlers. This function is only available on\r
- IA-32 and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param OrData The value to OR with the read value from the MSR.\r
-\r
- @return The lower 32-bit value written to the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrOr32 (\r
- IN UINT32 Index,\r
- IN UINT32 OrData\r
- )\r
-{\r
- return (UINT32)AsmMsrOr64 (Index, OrData);\r
-}\r
-\r
-/**\r
- Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
- the result back to the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
- lower 32-bits of the read result and the value specified by AndData, and\r
- writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
- the value written to the MSR is returned. No parameter checking is performed\r
- on Index or AndData, and some of these may cause CPU exceptions. The caller\r
- must either guarantee that Index and AndData are valid, or the caller must\r
- establish proper exception handlers. This function is only available on IA-32\r
- and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param AndData The value to AND with the read value from the MSR.\r
-\r
- @return The lower 32-bit value written to the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrAnd32 (\r
- IN UINT32 Index,\r
- IN UINT32 AndData\r
- )\r
-{\r
- return (UINT32)AsmMsrAnd64 (Index, AndData);\r
-}\r
-\r
-/**\r
- Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r
- on the lower 32-bits, 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 the\r
- lower 32-bits of the read result and the value specified by AndData\r
- preserving the upper 32-bits, performs a bitwise inclusive OR between the\r
- result of the AND operation and the value specified by OrData, and writes the\r
- result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
- written to the MSR is returned. No parameter checking is performed on Index,\r
- AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
- must either guarantee that Index, AndData, and OrData are valid, or the\r
- caller must establish proper exception handlers. This function is only\r
- available on IA-32 and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param AndData The value to AND with the read value from the MSR.\r
- @param OrData The value to OR with the result of the AND operation.\r
-\r
- @return The lower 32-bit value written to the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrAndThenOr32 (\r
- IN UINT32 Index,\r
- IN UINT32 AndData,\r
- IN UINT32 OrData\r
- )\r
-{\r
- return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData);\r
-}\r
-\r
-/**\r
- Reads a bit field of an MSR.\r
-\r
- Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
- specified by the StartBit and the EndBit. The value of the bit field is\r
- returned. The caller must either guarantee that Index is valid, or the caller\r
- must set up exception handlers to catch the exceptions. This function is only\r
- available on IA-32 and X64.\r
-\r
- If StartBit is greater than 31, then ASSERT().\r
- If EndBit is greater than 31, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to read.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..31.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..31.\r
-\r
- @return The bit field read from the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrBitFieldRead32 (\r
- IN UINT32 Index,\r
- IN UINTN StartBit,\r
- IN UINTN EndBit\r
- )\r
-{\r
- return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit);\r
-}\r
-\r
-/**\r
- Writes a bit field to an MSR.\r
-\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. Extra left bits in Value are stripped. The caller must either\r
- guarantee that Index and the data written is valid, or the caller must set up\r
- exception handlers to catch the exceptions. This function is only available\r
- on IA-32 and X64.\r
-\r
- If StartBit is greater than 31, then ASSERT().\r
- If EndBit is greater than 31, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..31.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..31.\r
- @param Value New value of the bit field.\r
-\r
- @return The lower 32-bit of the value written to the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrBitFieldWrite32 (\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
- ASSERT (StartBit <= EndBit);\r
- return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value);\r
-}\r
-\r
-/**\r
- Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
- result back to the bit field in the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
- between the read result and the value specified by OrData, and writes the\r
- result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
- written to the MSR are returned. Extra left bits in OrData are stripped. The\r
- caller must either guarantee that Index and the data written is valid, or\r
- the caller must set up exception handlers to catch the exceptions. This\r
- function is only available on IA-32 and X64.\r
-\r
- If StartBit is greater than 31, then ASSERT().\r
- If EndBit is greater than 31, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..31.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..31.\r
- @param OrData The value to OR with the read value from the MSR.\r
-\r
- @return The lower 32-bit of the value written to the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrBitFieldOr32 (\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
- ASSERT (StartBit <= EndBit);\r
- return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData);\r
-}\r
-\r
-/**\r
- Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
- result back to the bit field in the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
- read result and the value specified by AndData, and writes the result to the\r
- 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
- MSR are returned. Extra left bits in AndData are stripped. The caller must\r
- either guarantee that Index and the data written is valid, or the caller must\r
- set up exception handlers to catch the exceptions. This function is only\r
- available on IA-32 and X64.\r
-\r
- If StartBit is greater than 31, then ASSERT().\r
- If EndBit is greater than 31, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..31.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..31.\r
- @param AndData The value to AND with the read value from the MSR.\r
-\r
- @return The lower 32-bit of the value written to the MSR.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AsmMsrBitFieldAnd32 (\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
- ASSERT (StartBit <= EndBit);\r
- return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData);\r
-}\r
-\r
-/**\r
- Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
- bitwise inclusive OR, and writes the result back to the bit field in the\r
- 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
- bitwise inclusive OR between the read result and the value specified by\r
- AndData, and writes the result to the 64-bit MSR specified by Index. The\r
- lower 32-bits of the value written to the MSR are returned. Extra left bits\r
- in both AndData and OrData are stripped. 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\r
- and X64.\r
-\r
- If StartBit is greater than 31, then ASSERT().\r
- If EndBit is greater than 31, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..31.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..31.\r
- @param AndData The value to AND with the read value from the MSR.\r
- @param OrData The value to OR with the result of the AND operation.\r
-\r
- @return The lower 32-bit of the value written to the MSR.\r
-\r
-**/\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
- )\r
-{\r
- ASSERT (EndBit < sizeof (AndData) * 8);\r
- ASSERT (StartBit <= EndBit);\r
- return (UINT32)AsmMsrBitFieldAndThenOr64 (\r
- Index,\r
- StartBit,\r
- EndBit,\r
- AndData,\r
- OrData\r
- );\r
-}\r
-\r
-/**\r
- Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r
- back to the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
- between the read result and the value specified by OrData, and writes the\r
- result to the 64-bit MSR specified by Index. The value written to the MSR is\r
- returned. No parameter checking is performed on Index or OrData, and some of\r
- these may cause CPU exceptions. The caller must either guarantee that Index\r
- and OrData are valid, or the caller must establish proper exception handlers.\r
- This function is only available on IA-32 and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param OrData The value to OR with the read value from the MSR.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrOr64 (\r
- IN UINT32 Index,\r
- IN UINT64 OrData\r
- )\r
-{\r
- return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData);\r
-}\r
-\r
-/**\r
- Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
- 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
- read result and the value specified by OrData, and writes the result to the\r
- 64-bit MSR specified by Index. The value written to the MSR is returned. No\r
- parameter checking is performed on Index or OrData, and some of these may\r
- cause CPU exceptions. The caller must either guarantee that Index and OrData\r
- are valid, or the caller must establish proper exception handlers. This\r
- function is only available on IA-32 and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param AndData The value to AND with the read value from the MSR.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrAnd64 (\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 inclusive\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
- result and the value specified by AndData, performs a bitwise inclusive OR\r
- between the result of the AND operation and the value specified by OrData,\r
- and writes the result to the 64-bit MSR specified by Index. The value written\r
- to the MSR is returned. No parameter checking is performed on Index, AndData,\r
- or OrData, and some of these may cause CPU exceptions. The caller must either\r
- guarantee that Index, AndData, and OrData are valid, or the caller must\r
- establish proper exception handlers. This function is only available on IA-32\r
- and X64.\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param AndData The value to AND with the read value from the MSR.\r
- @param OrData The value to OR with the result of the AND operation.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrAndThenOr64 (\r
- IN UINT32 Index,\r
- IN UINT64 AndData,\r
- IN UINT64 OrData\r
- )\r
-{\r
- return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData);\r
-}\r
-\r
-/**\r
- Reads a bit field of an MSR.\r
-\r
- Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
- StartBit and the EndBit. The value of the bit field is returned. The caller\r
- must either guarantee that Index is valid, or the caller must set up\r
- exception handlers to catch the exceptions. This function is only available\r
- on IA-32 and X64.\r
-\r
- If StartBit is greater than 63, then ASSERT().\r
- If EndBit is greater than 63, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to read.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..63.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..63.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrBitFieldRead64 (\r
- IN UINT32 Index,\r
- IN UINTN StartBit,\r
- IN UINTN EndBit\r
- )\r
-{\r
- return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit);\r
-}\r
-\r
-/**\r
- Writes a bit field to an MSR.\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. Extra left bits in Value are\r
- stripped. The caller must either guarantee that Index and the data written is\r
- 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 63, then ASSERT().\r
- If EndBit is greater than 63, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..63.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..63.\r
- @param Value New value of the bit field.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrBitFieldWrite64 (\r
- IN UINT32 Index,\r
- IN UINTN StartBit,\r
- IN UINTN EndBit,\r
- IN UINT64 Value\r
- )\r
-{\r
- return AsmWriteMsr64 (\r
- Index,\r
- BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value)\r
- );\r
-}\r
-\r
-/**\r
- Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r
- writes the result back to the bit field in the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
- between the read result and the value specified by OrData, and writes the\r
- result to the 64-bit MSR specified by Index. The value written to the MSR is\r
- returned. Extra left bits in OrData are stripped. The caller must either\r
- guarantee that Index and the data written is valid, or the caller must set up\r
- exception handlers to catch the exceptions. This function is only available\r
- on IA-32 and X64.\r
-\r
- If StartBit is greater than 63, then ASSERT().\r
- If EndBit is greater than 63, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..63.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..63.\r
- @param OrData The value to OR with the read value from the bit field.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrBitFieldOr64 (\r
- IN UINT32 Index,\r
- IN UINTN StartBit,\r
- IN UINTN EndBit,\r
- IN UINT64 OrData\r
- )\r
-{\r
- return AsmWriteMsr64 (\r
- Index,\r
- BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData)\r
- );\r
-}\r
-\r
-/**\r
- Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
- result back to the bit field in the 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
- read result and the value specified by AndData, and writes the result to the\r
- 64-bit MSR specified by Index. The value written to the MSR is returned.\r
- Extra left bits in AndData are stripped. 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\r
- and X64.\r
-\r
- If StartBit is greater than 63, then ASSERT().\r
- If EndBit is greater than 63, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..63.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..63.\r
- @param AndData The value to AND with the read value from the bit field.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmMsrBitFieldAnd64 (\r
- IN UINT32 Index,\r
- IN UINTN StartBit,\r
- IN UINTN EndBit,\r
- IN UINT64 AndData\r
- )\r
-{\r
- return AsmWriteMsr64 (\r
- Index,\r
- BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData)\r
- );\r
-}\r
-\r
-/**\r
- Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
- bitwise inclusive OR, and writes the result back to the bit field in the\r
- 64-bit MSR.\r
-\r
- Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
- a bitwise inclusive OR between the read result and the value specified by\r
- AndData, and writes the result to the 64-bit MSR specified by Index. The\r
- value written to the MSR is returned. Extra left bits in both AndData and\r
- OrData are stripped. The caller must either guarantee that Index and the data\r
- written is valid, or the caller must set up exception handlers to catch the\r
- exceptions. This function is only available on IA-32 and X64.\r
-\r
- If StartBit is greater than 63, then ASSERT().\r
- If EndBit is greater than 63, then ASSERT().\r
- If EndBit is less than StartBit, then ASSERT().\r
-\r
- @param Index The 32-bit MSR index to write.\r
- @param StartBit The ordinal of the least significant bit in the bit field.\r
- Range 0..63.\r
- @param EndBit The ordinal of the most significant bit in the bit field.\r
- Range 0..63.\r
- @param AndData The value to AND with the read value from the bit field.\r
- @param OrData The value to OR with the result of the AND operation.\r
-\r
- @return The value written back to the MSR.\r
-\r
-**/\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
- )\r
-{\r
- return AsmWriteMsr64 (\r
- Index,\r
- BitFieldAndThenOr64 (\r
- AsmReadMsr64 (Index),\r
- StartBit,\r
- EndBit,\r
- AndData,\r
- OrData\r
- )\r
- );\r
-}\r