]>
Commit | Line | Data |
---|---|---|
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 | |
14f268ba | 31 | @param RegisterEax 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 | |
14f268ba | 34 | @param RegisterEbx 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 | |
14f268ba | 37 | @param RegisterEcx 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 | |
14f268ba | 40 | @param RegisterEdx 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 | 47 | UINT32\r |
48 | EFIAPI\r | |
49 | AsmCpuidEx (\r | |
50 | IN UINT32 Index,\r | |
51 | IN UINT32 SubIndex,\r | |
14f268ba | 52 | OUT UINT32 *RegisterEax, OPTIONAL\r |
53 | OUT UINT32 *RegisterEbx, OPTIONAL\r | |
54 | OUT UINT32 *RegisterEcx, OPTIONAL\r | |
55 | OUT UINT32 *RegisterEdx 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 | |
14f268ba | 63 | mov ecx, RegisterEax\r |
e1f414b6 | 64 | jecxz SkipEax\r |
65 | mov [ecx], eax\r | |
66 | SkipEax:\r | |
14f268ba | 67 | mov ecx, RegisterEbx\r |
e1f414b6 | 68 | jecxz SkipEbx\r |
69 | mov [ecx], ebx\r | |
70 | SkipEbx:\r | |
71 | pop eax\r | |
14f268ba | 72 | mov ecx, RegisterEcx\r |
e1f414b6 | 73 | jecxz SkipEcx\r |
74 | mov [ecx], eax\r | |
75 | SkipEcx:\r | |
14f268ba | 76 | mov ecx, RegisterEdx\r |
e1f414b6 | 77 | jecxz SkipEdx\r |
78 | mov [ecx], edx\r | |
79 | SkipEdx:\r | |
80 | mov eax, Index\r | |
81 | }\r | |
82 | }\r |