]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/WriteMsr64.c
77a068950a6885ee4f8934cae730b984cfd99756
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / WriteMsr64.c
1 /** @file
2 AsmWriteMsr64 function
3
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 //
16 // Include common header file for this module.
17 //
18
19
20 /**
21 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
22 value.
23
24 Writes the 64-bit value specified by Value to the MSR specified by Index. The
25 64-bit value written to the MSR is returned. No parameter checking is
26 performed on Index or Value, and some of these may cause CPU exceptions. The
27 caller must either guarantee that Index and Value are valid, or the caller
28 must establish proper exception handlers. This function is only available on
29 IA-32 and X64.
30
31 @param Index The 32-bit MSR index to write.
32 @param Value The 64-bit value to write to the MSR.
33
34 @return Value
35
36 **/
37 UINT64
38 EFIAPI
39 AsmWriteMsr64 (
40 IN UINT32 Index,
41 IN UINT64 Value
42 )
43 {
44 _asm {
45 mov edx, dword ptr [Value + 4]
46 mov eax, dword ptr [Value + 0]
47 mov ecx, Index
48 wrmsr
49 }
50 }
51