]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/ReadMsr64.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / ReadMsr64.c
1 /** @file
2 AsmReadMsr64 function
3
4 Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <Library/RegisterFilterLib.h>
10
11 /**
12 Returns a 64-bit Machine Specific Register(MSR).
13
14 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
15 performed on Index, and some Index values may cause CPU exceptions. The
16 caller must either guarantee that Index is valid, or the caller must set up
17 exception handlers to catch the exceptions. This function is only available
18 on IA-32 and x64.
19
20 @param Index The 32-bit MSR index to read.
21
22 @return The value of the MSR identified by Index.
23
24 **/
25 UINT64
26 AsmReadMsr64Internal (
27 IN UINT32 Index
28 )
29 {
30 _asm {
31 mov ecx, Index
32 rdmsr
33 }
34 }
35
36 /**
37 Returns a 64-bit Machine Specific Register(MSR).
38
39 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
40 performed on Index, and some Index values may cause CPU exceptions. The
41 caller must either guarantee that Index is valid, or the caller must set up
42 exception handlers to catch the exceptions. This function is only available
43 on IA-32 and x64.
44
45 @param Index The 32-bit MSR index to read.
46
47 @return The value of the MSR identified by Index.
48
49 **/
50 UINT64
51 EFIAPI
52 AsmReadMsr64 (
53 IN UINT32 Index
54 )
55 {
56 UINT64 Value;
57 BOOLEAN Flag;
58
59 Flag = FilterBeforeMsrRead (Index, &Value);
60 if (Flag) {
61 Value = AsmReadMsr64Internal (Index);
62 }
63
64 FilterAfterMsrRead (Index, &Value);
65
66 return Value;
67 }