]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/CpuIdEx.c
Sync function prototype of CpuId and CpuIdEx with MDE library specification.
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / CpuIdEx.c
CommitLineData
e1f414b6 1/** @file\r
2 AsmCpuidEx function.\r
3\r
44b013bd 4 Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
e1f414b6 5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
42eedea9 15/**\r
16 Retrieves CPUID information using an extended leaf identifier.\r
17\r
18 Executes the CPUID instruction with EAX set to the value specified by Index\r
19 and ECX set to the value specified by SubIndex. This function always returns\r
20 Index. This function is only available on IA-32 and x64.\r
21\r
22 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
23 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
24 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
25 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
26\r
44b013bd 27 @param Index The 32-bit value to load into EAX prior to invoking the\r
28 CPUID instruction.\r
29 @param SubIndex The 32-bit value to load into ECX prior to invoking the\r
30 CPUID instruction.\r
610204a8 31 @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r
44b013bd 32 instruction. This is an optional parameter that may be\r
33 NULL.\r
610204a8 34 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r
44b013bd 35 instruction. This is an optional parameter that may be\r
36 NULL.\r
610204a8 37 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r
44b013bd 38 instruction. This is an optional parameter that may be\r
39 NULL.\r
610204a8 40 @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r
44b013bd 41 instruction. This is an optional parameter that may be\r
42 NULL.\r
42eedea9 43\r
44 @return Index\r
45\r
46**/\r
e1f414b6 47UINT32\r
48EFIAPI\r
49AsmCpuidEx (\r
50 IN UINT32 Index,\r
51 IN UINT32 SubIndex,\r
610204a8 52 OUT UINT32 *Eax, OPTIONAL\r
53 OUT UINT32 *Ebx, OPTIONAL\r
54 OUT UINT32 *Ecx, OPTIONAL\r
55 OUT UINT32 *Edx OPTIONAL\r
e1f414b6 56 )\r
57{\r
58 _asm {\r
59 mov eax, Index\r
60 mov ecx, SubIndex\r
61 cpuid\r
62 push ecx\r
610204a8 63 mov ecx, Eax\r
e1f414b6 64 jecxz SkipEax\r
65 mov [ecx], eax\r
66SkipEax:\r
610204a8 67 mov ecx, Ebx\r
e1f414b6 68 jecxz SkipEbx\r
69 mov [ecx], ebx\r
70SkipEbx:\r
71 pop eax\r
610204a8 72 mov ecx, Ecx\r
e1f414b6 73 jecxz SkipEcx\r
74 mov [ecx], eax\r
75SkipEcx:\r
610204a8 76 mov ecx, Edx\r
e1f414b6 77 jecxz SkipEdx\r
78 mov [ecx], edx\r
79SkipEdx:\r
80 mov eax, Index\r
81 }\r
82}\r