]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | AsmCpuid function.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
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 | |
18 | This function is only available on IA-32 and x64.\r | |
19 | \r | |
20 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
21 | instruction.\r | |
22 | @param RegisterEax A pointer to the 32-bit EAX value returned by the CPUID\r | |
23 | instruction. This is an optional parameter that may be NULL.\r | |
24 | @param RegisterEbx A pointer to the 32-bit EBX value returned by the CPUID\r | |
25 | instruction. This is an optional parameter that may be NULL.\r | |
26 | @param RegisterEcx A pointer to the 32-bit ECX value returned by the CPUID\r | |
27 | instruction. This is an optional parameter that may be NULL.\r | |
28 | @param RegisterEdx A pointer to the 32-bit EDX value returned by the CPUID\r | |
29 | instruction. This is an optional parameter that may be NULL.\r | |
30 | \r | |
31 | @return Index.\r | |
32 | \r | |
33 | **/\r | |
34 | UINT32\r | |
35 | EFIAPI\r | |
36 | AsmCpuid (\r | |
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 | |
42 | )\r | |
43 | {\r | |
44 | _asm {\r | |
45 | mov eax, Index\r | |
46 | cpuid\r | |
47 | push ecx\r | |
48 | mov ecx, RegisterEax\r | |
49 | jecxz SkipEax\r | |
50 | mov [ecx], eax\r | |
51 | SkipEax:\r | |
52 | mov ecx, RegisterEbx\r | |
53 | jecxz SkipEbx\r | |
54 | mov [ecx], ebx\r | |
55 | SkipEbx:\r | |
56 | pop eax\r | |
57 | mov ecx, RegisterEcx\r | |
58 | jecxz SkipEcx\r | |
59 | mov [ecx], eax\r | |
60 | SkipEcx:\r | |
61 | mov ecx, RegisterEdx\r | |
62 | jecxz SkipEdx\r | |
63 | mov [ecx], edx\r | |
64 | SkipEdx:\r | |
65 | mov eax, Index\r | |
66 | }\r | |
67 | }\r |