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