]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | AsmCpuid 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.\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 | |
14f268ba | 28 | @param RegisterEax 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 |
14f268ba | 30 | @param RegisterEbx 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 |
14f268ba | 32 | @param RegisterEcx 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 |
14f268ba | 34 | @param RegisterEdx 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 | 40 | UINT32\r |
41 | EFIAPI\r | |
42 | AsmCpuid (\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 | |
57 | SkipEax:\r | |
14f268ba | 58 | mov ecx, RegisterEbx\r |
e1f414b6 | 59 | jecxz SkipEbx\r |
60 | mov [ecx], ebx\r | |
61 | SkipEbx:\r | |
62 | pop eax\r | |
14f268ba | 63 | mov ecx, RegisterEcx\r |
e1f414b6 | 64 | jecxz SkipEcx\r |
65 | mov [ecx], eax\r | |
66 | SkipEcx:\r | |
14f268ba | 67 | mov ecx, RegisterEdx\r |
e1f414b6 | 68 | jecxz SkipEdx\r |
69 | mov [ecx], edx\r | |
70 | SkipEdx:\r | |
71 | mov eax, Index\r | |
72 | }\r | |
73 | }\r | |
74 | \r |