]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/Ia32/WriteMsr64.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / WriteMsr64.c
index 5937ac80442795e7d29ed3c03eed55333417d015..e8e49212f1898178846735deeef3a85e15a235be 100644 (file)
@@ -1,19 +1,12 @@
 /** @file\r
   AsmWriteMsr64 function\r
 \r
-  Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-\r
-\r
+#include <Library/RegisterFilterLib.h>\r
 \r
 /**\r
   Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
@@ -24,7 +17,7 @@
   performed on Index or Value, and some of these may cause CPU exceptions. The\r
   caller must either guarantee that Index and Value are valid, or the caller\r
   must establish proper exception handlers. This function is only available on\r
-  IA-32 and X64.\r
+  IA-32 and x64.\r
 \r
   @param  Index The 32-bit MSR index to write.\r
   @param  Value The 64-bit value to write to the MSR.\r
@@ -39,11 +32,19 @@ AsmWriteMsr64 (
   IN UINT64  Value\r
   )\r
 {\r
-  _asm {\r
-    mov     edx, dword ptr [Value + 4]\r
-    mov     eax, dword ptr [Value + 0]\r
-    mov     ecx, Index\r
-    wrmsr\r
+  BOOLEAN  Flag;\r
+\r
+  Flag = FilterBeforeMsrWrite (Index, &Value);\r
+  if (Flag) {\r
+    _asm {\r
+      mov     edx, dword ptr [Value + 4]\r
+      mov     eax, dword ptr [Value + 0]\r
+      mov     ecx, Index\r
+      wrmsr\r
+    }\r
   }\r
-}\r
 \r
+  FilterAfterMsrWrite (Index, &Value);\r
+\r
+  return Value;\r
+}\r