]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | AsmWriteMsr64 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 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
13 | value.\r | |
14 | \r | |
15 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
16 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
17 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
18 | caller must either guarantee that Index and Value are valid, or the caller\r | |
19 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 20 | IA-32 and x64.\r |
42eedea9 | 21 | \r |
22 | @param Index The 32-bit MSR index to write.\r | |
23 | @param Value The 64-bit value to write to the MSR.\r | |
24 | \r | |
25 | @return Value\r | |
26 | \r | |
27 | **/\r | |
e1f414b6 | 28 | UINT64\r |
29 | EFIAPI\r | |
30 | AsmWriteMsr64 (\r | |
31 | IN UINT32 Index,\r | |
32 | IN UINT64 Value\r | |
33 | )\r | |
34 | {\r | |
2f88bd3a | 35 | BOOLEAN Flag;\r |
dc4d4230 DB |
36 | \r |
37 | Flag = FilterBeforeMsrWrite (Index, &Value);\r | |
38 | if (Flag) {\r | |
39 | _asm {\r | |
40 | mov edx, dword ptr [Value + 4]\r | |
41 | mov eax, dword ptr [Value + 0]\r | |
42 | mov ecx, Index\r | |
43 | wrmsr\r | |
44 | }\r | |
e1f414b6 | 45 | }\r |
2f88bd3a | 46 | \r |
dc4d4230 DB |
47 | FilterAfterMsrWrite (Index, &Value);\r |
48 | \r | |
49 | return Value;\r | |
e1f414b6 | 50 | }\r |