]>
Commit | Line | Data |
---|---|---|
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 | |
1efcc4ae | 9 | \r |
dc4d4230 | 10 | #include <Library/RegisterFilterLib.h>\r |
e1f414b6 | 11 | \r |
42eedea9 | 12 | /**\r |
13 | Returns a 64-bit Machine Specific Register(MSR).\r | |
14 | \r | |
15 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
16 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
17 | caller must either guarantee that Index is valid, or the caller must set up\r | |
18 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 19 | on IA-32 and x64.\r |
42eedea9 | 20 | \r |
21 | @param Index The 32-bit MSR index to read.\r | |
22 | \r | |
23 | @return The value of the MSR identified by Index.\r | |
24 | \r | |
25 | **/\r | |
e1f414b6 | 26 | UINT64\r |
dc4d4230 | 27 | AsmReadMsr64Internal (\r |
e1f414b6 | 28 | IN UINT32 Index\r |
29 | )\r | |
30 | {\r | |
31 | _asm {\r | |
32 | mov ecx, Index\r | |
33 | rdmsr\r | |
34 | }\r | |
35 | }\r | |
36 | \r | |
dc4d4230 DB |
37 | /**\r |
38 | Returns a 64-bit Machine Specific Register(MSR).\r | |
39 | \r | |
40 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
41 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
42 | caller must either guarantee that Index is valid, or the caller must set up\r | |
43 | exception handlers to catch the exceptions. This function is only available\r | |
44 | on IA-32 and x64.\r | |
45 | \r | |
46 | @param Index The 32-bit MSR index to read.\r | |
47 | \r | |
48 | @return The value of the MSR identified by Index.\r | |
49 | \r | |
50 | **/\r | |
51 | UINT64\r | |
52 | EFIAPI\r | |
53 | AsmReadMsr64 (\r | |
54 | IN UINT32 Index\r | |
55 | )\r | |
56 | {\r | |
57 | UINT64 Value;\r | |
58 | BOOLEAN Flag;\r | |
59 | \r | |
60 | Flag = FilterBeforeMsrRead (Index, &Value);\r | |
61 | if (Flag) {\r | |
62 | Value = AsmReadMsr64Internal (Index);\r | |
63 | }\r | |
64 | FilterAfterMsrRead (Index, &Value);\r | |
65 | \r | |
66 | return Value;\r | |
67 | }\r |