TianoCore EDK2 master
Loading...
Searching...
No Matches
X86Msr.c File Reference
#include "BaseLibInternals.h"

Go to the source code of this file.

Functions

UINT32 EFIAPI AsmReadMsr32 (IN UINT32 Index)
 
UINT32 EFIAPI AsmWriteMsr32 (IN UINT32 Index, IN UINT32 Value)
 
UINT32 EFIAPI AsmMsrOr32 (IN UINT32 Index, IN UINT32 OrData)
 
UINT32 EFIAPI AsmMsrAnd32 (IN UINT32 Index, IN UINT32 AndData)
 
UINT32 EFIAPI AsmMsrAndThenOr32 (IN UINT32 Index, IN UINT32 AndData, IN UINT32 OrData)
 
UINT32 EFIAPI AsmMsrBitFieldRead32 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit)
 
UINT32 EFIAPI AsmMsrBitFieldWrite32 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
 
UINT32 EFIAPI AsmMsrBitFieldOr32 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
 
UINT32 EFIAPI AsmMsrBitFieldAnd32 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
 
UINT32 EFIAPI AsmMsrBitFieldAndThenOr32 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
 
UINT64 EFIAPI AsmMsrOr64 (IN UINT32 Index, IN UINT64 OrData)
 
UINT64 EFIAPI AsmMsrAnd64 (IN UINT32 Index, IN UINT64 AndData)
 
UINT64 EFIAPI AsmMsrAndThenOr64 (IN UINT32 Index, IN UINT64 AndData, IN UINT64 OrData)
 
UINT64 EFIAPI AsmMsrBitFieldRead64 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit)
 
UINT64 EFIAPI AsmMsrBitFieldWrite64 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 Value)
 
UINT64 EFIAPI AsmMsrBitFieldOr64 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 OrData)
 
UINT64 EFIAPI AsmMsrBitFieldAnd64 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 AndData)
 
UINT64 EFIAPI AsmMsrBitFieldAndThenOr64 (IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 AndData, IN UINT64 OrData)
 

Detailed Description

IA-32/x64 MSR functions.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file X86Msr.c.

Function Documentation

◆ AsmMsrAnd32()

UINT32 EFIAPI AsmMsrAnd32 ( IN UINT32  Index,
IN UINT32  AndData 
)

Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes the result back to the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND between the lower 32-bits of the read result and the value specified by AndData, and writes the result to the 64-bit MSR specified by Index. The lower 32-bits of the value written to the MSR is returned. No parameter checking is performed on Index or AndData, and some of these may cause CPU exceptions. The caller must either guarantee that Index and AndData are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
AndDataThe value to AND with the read value from the MSR.
Returns
The lower 32-bit value written to the MSR.

Definition at line 111 of file X86Msr.c.

◆ AsmMsrAnd64()

UINT64 EFIAPI AsmMsrAnd64 ( IN UINT32  Index,
IN UINT64  AndData 
)

Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND between the read result and the value specified by OrData, and writes the result to the 64-bit MSR specified by Index. The value written to the MSR is returned. No parameter checking is performed on Index or OrData, and some of these may cause CPU exceptions. The caller must either guarantee that Index and OrData are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
AndDataThe value to AND with the read value from the MSR.
Returns
The value written back to the MSR.

Definition at line 406 of file X86Msr.c.

◆ AsmMsrAndThenOr32()

UINT32 EFIAPI AsmMsrAndThenOr32 ( IN UINT32  Index,
IN UINT32  AndData,
IN UINT32  OrData 
)

Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR on the lower 32-bits, and writes the result back to the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND between the lower 32-bits of the read result and the value specified by AndData preserving the upper 32-bits, performs a bitwise OR between the result of the AND operation and the value specified by OrData, and writes the result to the 64-bit MSR specified by Address. The lower 32-bits of the value written to the MSR is returned. No parameter checking is performed on Index, AndData, or OrData, and some of these may cause CPU exceptions. The caller must either guarantee that Index, AndData, and OrData are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
AndDataThe value to AND with the read value from the MSR.
OrDataThe value to OR with the result of the AND operation.
Returns
The lower 32-bit value written to the MSR.

Definition at line 143 of file X86Msr.c.

◆ AsmMsrAndThenOr64()

UINT64 EFIAPI AsmMsrAndThenOr64 ( IN UINT32  Index,
IN UINT64  AndData,
IN UINT64  OrData 
)

Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR, and writes the result back to the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND between read result and the value specified by AndData, performs a bitwise OR between the result of the AND operation and the value specified by OrData, and writes the result to the 64-bit MSR specified by Index. The value written to the MSR is returned. No parameter checking is performed on Index, AndData, or OrData, and some of these may cause CPU exceptions. The caller must either guarantee that Index, AndData, and OrData are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
AndDataThe value to AND with the read value from the MSR.
OrDataThe value to OR with the result of the AND operation.
Returns
The value written back to the MSR.

Definition at line 437 of file X86Msr.c.

◆ AsmMsrBitFieldAnd32()

UINT32 EFIAPI AsmMsrBitFieldAnd32 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT32  AndData 
)

Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the result back to the bit field in the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND between the read result and the value specified by AndData, and writes the result to the 64-bit MSR specified by Index. The lower 32-bits of the value written to the MSR are returned. Extra left bits in AndData are stripped. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..31.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..31.
AndDataThe value to AND with the read value from the MSR.
Returns
The lower 32-bit of the value written to the MSR.

Definition at line 294 of file X86Msr.c.

◆ AsmMsrBitFieldAnd64()

UINT64 EFIAPI AsmMsrBitFieldAnd64 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT64  AndData 
)

Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the result back to the bit field in the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND between the read result and the value specified by AndData, and writes the result to the 64-bit MSR specified by Index. The value written to the MSR is returned. Extra left bits in AndData are stripped. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..63.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..63.
AndDataThe value to AND with the read value from the bit field.
Returns
The value written back to the MSR.

Definition at line 589 of file X86Msr.c.

◆ AsmMsrBitFieldAndThenOr32()

UINT32 EFIAPI AsmMsrBitFieldAndThenOr32 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT32  AndData,
IN UINT32  OrData 
)

Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a bitwise OR, and writes the result back to the bit field in the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a bitwise OR between the read result and the value specified by AndData, and writes the result to the 64-bit MSR specified by Index. The lower 32-bits of the value written to the MSR are returned. Extra left bits in both AndData and OrData are stripped. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..31.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..31.
AndDataThe value to AND with the read value from the MSR.
OrDataThe value to OR with the result of the AND operation.
Returns
The lower 32-bit of the value written to the MSR.

Definition at line 339 of file X86Msr.c.

◆ AsmMsrBitFieldAndThenOr64()

UINT64 EFIAPI AsmMsrBitFieldAndThenOr64 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT64  AndData,
IN UINT64  OrData 
)

Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a bitwise OR, and writes the result back to the bit field in the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a bitwise OR between the read result and the value specified by AndData, and writes the result to the 64-bit MSR specified by Index. The value written to the MSR is returned. Extra left bits in both AndData and OrData are stripped. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..63.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..63.
AndDataThe value to AND with the read value from the bit field.
OrDataThe value to OR with the result of the AND operation.
Returns
The value written back to the MSR.

Definition at line 634 of file X86Msr.c.

◆ AsmMsrBitFieldOr32()

UINT32 EFIAPI AsmMsrBitFieldOr32 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT32  OrData 
)

Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the result back to the bit field in the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise OR between the read result and the value specified by OrData, and writes the result to the 64-bit MSR specified by Index. The lower 32-bits of the value written to the MSR are returned. Extra left bits in OrData are stripped. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..31.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..31.
OrDataThe value to OR with the read value from the MSR.
Returns
The lower 32-bit of the value written to the MSR.

Definition at line 253 of file X86Msr.c.

◆ AsmMsrBitFieldOr64()

UINT64 EFIAPI AsmMsrBitFieldOr64 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT64  OrData 
)

Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the result back to the bit field in the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise OR between the read result and the value specified by OrData, and writes the result to the 64-bit MSR specified by Index. The value written to the MSR is returned. Extra left bits in OrData are stripped. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..63.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..63.
OrDataThe value to OR with the read value from the bit field.
Returns
The value written back to the MSR.

Definition at line 547 of file X86Msr.c.

◆ AsmMsrBitFieldRead32()

UINT32 EFIAPI AsmMsrBitFieldRead32 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit 
)

Reads a bit field of an MSR.

Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is specified by the StartBit and the EndBit. The value of the bit field is returned. The caller must either guarantee that Index is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to read.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..31.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..31.
Returns
The bit field read from the MSR.

Definition at line 176 of file X86Msr.c.

◆ AsmMsrBitFieldRead64()

UINT64 EFIAPI AsmMsrBitFieldRead64 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit 
)

Reads a bit field of an MSR.

Reads the bit field in the 64-bit MSR. The bit field is specified by the StartBit and the EndBit. The value of the bit field is returned. The caller must either guarantee that Index is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to read.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..63.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..63.
Returns
The value read from the MSR.

Definition at line 470 of file X86Msr.c.

◆ AsmMsrBitFieldWrite32()

UINT32 EFIAPI AsmMsrBitFieldWrite32 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT32  Value 
)

Writes a bit field to an MSR.

Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit field is specified by the StartBit and the EndBit. All other bits in the destination MSR are preserved. The lower 32-bits of the MSR written is returned. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..31.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..31.
ValueThe new value of the bit field.
Returns
The lower 32-bit of the value written to the MSR.

Definition at line 212 of file X86Msr.c.

◆ AsmMsrBitFieldWrite64()

UINT64 EFIAPI AsmMsrBitFieldWrite64 ( IN UINT32  Index,
IN UINTN  StartBit,
IN UINTN  EndBit,
IN UINT64  Value 
)

Writes a bit field to an MSR.

Writes Value to a bit field in a 64-bit MSR. The bit field is specified by the StartBit and the EndBit. All other bits in the destination MSR are preserved. The MSR written is returned. The caller must either guarantee that Index and the data written is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().

Parameters
IndexThe 32-bit MSR index to write.
StartBitThe ordinal of the least significant bit in the bit field. Range 0..63.
EndBitThe ordinal of the most significant bit in the bit field. Range 0..63.
ValueThe new value of the bit field.
Returns
The value written back to the MSR.

Definition at line 505 of file X86Msr.c.

◆ AsmMsrOr32()

UINT32 EFIAPI AsmMsrOr32 ( IN UINT32  Index,
IN UINT32  OrData 
)

Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and writes the result back to the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise OR between the lower 32-bits of the read result and the value specified by OrData, and writes the result to the 64-bit MSR specified by Index. The lower 32-bits of the value written to the MSR is returned. No parameter checking is performed on Index or OrData, and some of these may cause CPU exceptions. The caller must either guarantee that Index and OrData are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
OrDataThe value to OR with the read value from the MSR.
Returns
The lower 32-bit value written to the MSR.

Definition at line 82 of file X86Msr.c.

◆ AsmMsrOr64()

UINT64 EFIAPI AsmMsrOr64 ( IN UINT32  Index,
IN UINT64  OrData 
)

Reads a 64-bit MSR, performs a bitwise OR, and writes the result back to the 64-bit MSR.

Reads the 64-bit MSR specified by Index, performs a bitwise OR between the read result and the value specified by OrData, and writes the result to the 64-bit MSR specified by Index. The value written to the MSR is returned. No parameter checking is performed on Index or OrData, and some of these may cause CPU exceptions. The caller must either guarantee that Index and OrData are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
OrDataThe value to OR with the read value from the MSR.
Returns
The value written back to the MSR.

Definition at line 378 of file X86Msr.c.

◆ AsmReadMsr32()

UINT32 EFIAPI AsmReadMsr32 ( IN UINT32  Index)

Returns the lower 32-bits of a Machine Specific Register(MSR).

Reads and returns the lower 32-bits of the MSR specified by Index. No parameter checking is performed on Index, and some Index values may cause CPU exceptions. The caller must either guarantee that Index is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to read.
Returns
The lower 32 bits of the MSR identified by Index.

Definition at line 27 of file X86Msr.c.

◆ AsmWriteMsr32()

UINT32 EFIAPI AsmWriteMsr32 ( IN UINT32  Index,
IN UINT32  Value 
)

Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value. The upper 32-bits of the MSR are set to zero.

Writes the 32-bit value specified by Value to the MSR specified by Index. The upper 32-bits of the MSR write are set to zero. The 32-bit value written to the MSR is returned. No parameter checking is performed on Index or Value, and some of these may cause CPU exceptions. The caller must either guarantee that Index and Value are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
ValueThe 32-bit value to write to the MSR.
Returns
Value

Definition at line 53 of file X86Msr.c.