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