]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/CpuId.c
MdePkg/BaseLib: Support IA32 processors without CLFLUSH
[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
bb817c56 5 This program and the accompanying materials\r
e1f414b6 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
35a17154 8 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 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.\r
17\r
18 Executes the CPUID instruction with EAX set to the value specified by Index.\r
19 This function always returns Index.\r
20 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
21 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
22 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
23 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
030cd1a2 24 This function is only available on IA-32 and x64.\r
42eedea9 25\r
44b013bd 26 @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r
27 instruction.\r
35a17154 28 @param RegisterEax A pointer to the 32-bit EAX value returned by the CPUID\r
44b013bd 29 instruction. This is an optional parameter that may be NULL.\r
35a17154 30 @param RegisterEbx A pointer to the 32-bit EBX value returned by the CPUID\r
44b013bd 31 instruction. This is an optional parameter that may be NULL.\r
35a17154 32 @param RegisterEcx A pointer to the 32-bit ECX value returned by the CPUID\r
44b013bd 33 instruction. This is an optional parameter that may be NULL.\r
35a17154 34 @param RegisterEdx A pointer to the 32-bit EDX value returned by the CPUID\r
44b013bd 35 instruction. This is an optional parameter that may be NULL.\r
42eedea9 36\r
2fe241a2 37 @return Index.\r
42eedea9 38\r
39**/\r
e1f414b6 40UINT32\r
41EFIAPI\r
42AsmCpuid (\r
43 IN UINT32 Index,\r
14f268ba 44 OUT UINT32 *RegisterEax, OPTIONAL\r
45 OUT UINT32 *RegisterEbx, OPTIONAL\r
46 OUT UINT32 *RegisterEcx, OPTIONAL\r
47 OUT UINT32 *RegisterEdx OPTIONAL\r
e1f414b6 48 )\r
49{\r
50 _asm {\r
51 mov eax, Index\r
52 cpuid\r
53 push ecx\r
14f268ba 54 mov ecx, RegisterEax\r
e1f414b6 55 jecxz SkipEax\r
56 mov [ecx], eax\r
57SkipEax:\r
14f268ba 58 mov ecx, RegisterEbx\r
e1f414b6 59 jecxz SkipEbx\r
60 mov [ecx], ebx\r
61SkipEbx:\r
62 pop eax\r
14f268ba 63 mov ecx, RegisterEcx\r
e1f414b6 64 jecxz SkipEcx\r
65 mov [ecx], eax\r
66SkipEcx:\r
14f268ba 67 mov ecx, RegisterEdx\r
e1f414b6 68 jecxz SkipEdx\r
69 mov [ecx], edx\r
70SkipEdx:\r
71 mov eax, Index\r
72 }\r
73}\r
74\r