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