]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | AsmCpuidEx 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 using an extended leaf identifier.\r | |
11 | \r | |
12 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
13 | and ECX set to the value specified by SubIndex. This function always returns\r | |
14 | Index. This function is only available on IA-32 and x64.\r | |
15 | \r | |
16 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
17 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
18 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
19 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
20 | \r | |
44b013bd | 21 | @param Index The 32-bit value to load into EAX prior to invoking the\r |
22 | CPUID instruction.\r | |
23 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
24 | CPUID instruction.\r | |
35a17154 | 25 | @param RegisterEax A pointer to the 32-bit EAX value returned by the CPUID\r |
44b013bd | 26 | instruction. This is an optional parameter that may be\r |
27 | NULL.\r | |
35a17154 | 28 | @param RegisterEbx A pointer to the 32-bit EBX value returned by the CPUID\r |
44b013bd | 29 | instruction. This is an optional parameter that may be\r |
30 | NULL.\r | |
35a17154 | 31 | @param RegisterEcx A pointer to the 32-bit ECX value returned by the CPUID\r |
44b013bd | 32 | instruction. This is an optional parameter that may be\r |
33 | 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\r |
36 | NULL.\r | |
42eedea9 | 37 | \r |
2fe241a2 | 38 | @return Index.\r |
42eedea9 | 39 | \r |
40 | **/\r | |
e1f414b6 | 41 | UINT32\r |
42 | EFIAPI\r | |
43 | AsmCpuidEx (\r | |
44 | IN UINT32 Index,\r | |
45 | IN UINT32 SubIndex,\r | |
d0e2f823 MK |
46 | OUT UINT32 *RegisterEax OPTIONAL,\r |
47 | OUT UINT32 *RegisterEbx OPTIONAL,\r | |
48 | OUT UINT32 *RegisterEcx OPTIONAL,\r | |
14f268ba | 49 | OUT UINT32 *RegisterEdx OPTIONAL\r |
e1f414b6 | 50 | )\r |
51 | {\r | |
52 | _asm {\r | |
53 | mov eax, Index\r | |
54 | mov ecx, SubIndex\r | |
55 | cpuid\r | |
56 | push ecx\r | |
14f268ba | 57 | mov ecx, RegisterEax\r |
e1f414b6 | 58 | jecxz SkipEax\r |
59 | mov [ecx], eax\r | |
60 | SkipEax:\r | |
14f268ba | 61 | mov ecx, RegisterEbx\r |
e1f414b6 | 62 | jecxz SkipEbx\r |
63 | mov [ecx], ebx\r | |
64 | SkipEbx:\r | |
65 | pop eax\r | |
14f268ba | 66 | mov ecx, RegisterEcx\r |
e1f414b6 | 67 | jecxz SkipEcx\r |
68 | mov [ecx], eax\r | |
69 | SkipEcx:\r | |
14f268ba | 70 | mov ecx, RegisterEdx\r |
e1f414b6 | 71 | jecxz SkipEdx\r |
72 | mov [ecx], edx\r | |
73 | SkipEdx:\r | |
74 | mov eax, Index\r | |
75 | }\r | |
76 | }\r |