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