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