]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/CpuIdEx.c
remove unnecessary comments introduced by tools from MdePkg. The regular express...
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / CpuIdEx.c
1 /** @file
2 AsmCpuidEx 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
17
18 /**
19 Retrieves CPUID information using an extended leaf identifier.
20
21 Executes the CPUID instruction with EAX set to the value specified by Index
22 and ECX set to the value specified by SubIndex. This function always returns
23 Index. This function is only available on IA-32 and x64.
24
25 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
26 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
27 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
28 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
29
30 @param Index The 32-bit value to load into EAX prior to invoking the
31 CPUID instruction.
32 @param SubIndex The 32-bit value to load into ECX prior to invoking the
33 CPUID instruction.
34 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
35 instruction. This is an optional parameter that may be
36 NULL.
37 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
38 instruction. This is an optional parameter that may be
39 NULL.
40 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
41 instruction. This is an optional parameter that may be
42 NULL.
43 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
44 instruction. This is an optional parameter that may be
45 NULL.
46
47 @return Index
48
49 **/
50 UINT32
51 EFIAPI
52 AsmCpuidEx (
53 IN UINT32 Index,
54 IN UINT32 SubIndex,
55 OUT UINT32 *RegisterEax, OPTIONAL
56 OUT UINT32 *RegisterEbx, OPTIONAL
57 OUT UINT32 *RegisterEcx, OPTIONAL
58 OUT UINT32 *RegisterEdx OPTIONAL
59 )
60 {
61 _asm {
62 mov eax, Index
63 mov ecx, SubIndex
64 cpuid
65 push ecx
66 mov ecx, RegisterEax
67 jecxz SkipEax
68 mov [ecx], eax
69 SkipEax:
70 mov ecx, RegisterEbx
71 jecxz SkipEbx
72 mov [ecx], ebx
73 SkipEbx:
74 pop eax
75 mov ecx, RegisterEcx
76 jecxz SkipEcx
77 mov [ecx], eax
78 SkipEcx:
79 mov ecx, RegisterEdx
80 jecxz SkipEdx
81 mov [ecx], edx
82 SkipEdx:
83 mov eax, Index
84 }
85 }