]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/CpuId.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / CpuId.c
CommitLineData
e1f414b6 1/** @file\r
2 AsmCpuid function.\r
3\r
35a17154 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e1f414b6 6\r
7**/\r
8\r
42eedea9 9/**\r
10 Retrieves CPUID information.\r
11\r
12 Executes the CPUID instruction with EAX set to the value specified by Index.\r
13 This function always returns Index.\r
14 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
15 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
16 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
17 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
030cd1a2 18 This function is only available on IA-32 and x64.\r
42eedea9 19\r
44b013bd 20 @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r
21 instruction.\r
35a17154 22 @param RegisterEax A pointer to the 32-bit EAX value returned by the CPUID\r
44b013bd 23 instruction. This is an optional parameter that may be NULL.\r
35a17154 24 @param RegisterEbx A pointer to the 32-bit EBX value returned by the CPUID\r
44b013bd 25 instruction. This is an optional parameter that may be NULL.\r
35a17154 26 @param RegisterEcx A pointer to the 32-bit ECX value returned by the CPUID\r
44b013bd 27 instruction. This is an optional parameter that may be NULL.\r
35a17154 28 @param RegisterEdx A pointer to the 32-bit EDX value returned by the CPUID\r
44b013bd 29 instruction. This is an optional parameter that may be NULL.\r
42eedea9 30\r
2fe241a2 31 @return Index.\r
42eedea9 32\r
33**/\r
e1f414b6 34UINT32\r
35EFIAPI\r
36AsmCpuid (\r
2f88bd3a
MK
37 IN UINT32 Index,\r
38 OUT UINT32 *RegisterEax OPTIONAL,\r
39 OUT UINT32 *RegisterEbx OPTIONAL,\r
40 OUT UINT32 *RegisterEcx OPTIONAL,\r
41 OUT UINT32 *RegisterEdx OPTIONAL\r
e1f414b6 42 )\r
43{\r
44 _asm {\r
45 mov eax, Index\r
46 cpuid\r
47 push ecx\r
14f268ba 48 mov ecx, RegisterEax\r
e1f414b6 49 jecxz SkipEax\r
50 mov [ecx], eax\r
51SkipEax:\r
14f268ba 52 mov ecx, RegisterEbx\r
e1f414b6 53 jecxz SkipEbx\r
54 mov [ecx], ebx\r
55SkipEbx:\r
56 pop eax\r
14f268ba 57 mov ecx, RegisterEcx\r
e1f414b6 58 jecxz SkipEcx\r
59 mov [ecx], eax\r
60SkipEcx:\r
14f268ba 61 mov ecx, RegisterEdx\r
e1f414b6 62 jecxz SkipEdx\r
63 mov [ecx], edx\r
64SkipEdx:\r
65 mov eax, Index\r
66 }\r
67}\r