]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/BaseLib/Ia32/CpuIdEx.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / CpuIdEx.c
... / ...
CommitLineData
1/** @file\r
2 AsmCpuidEx 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 using an extended leaf identifier.\r
11\r
12 Executes the CPUID instruction with EAX set to the value specified by Index\r
13 and ECX set to the value specified by SubIndex. This function always returns\r
14 Index. This function is only available on IA-32 and x64.\r
15\r
16 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
17 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
18 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
19 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
20\r
21 @param Index The 32-bit value to load into EAX prior to invoking the\r
22 CPUID instruction.\r
23 @param SubIndex The 32-bit value to load into ECX prior to invoking the\r
24 CPUID instruction.\r
25 @param RegisterEax A pointer to the 32-bit EAX value returned by the CPUID\r
26 instruction. This is an optional parameter that may be\r
27 NULL.\r
28 @param RegisterEbx A pointer to the 32-bit EBX value returned by the CPUID\r
29 instruction. This is an optional parameter that may be\r
30 NULL.\r
31 @param RegisterEcx A pointer to the 32-bit ECX value returned by the CPUID\r
32 instruction. This is an optional parameter that may be\r
33 NULL.\r
34 @param RegisterEdx A pointer to the 32-bit EDX value returned by the CPUID\r
35 instruction. This is an optional parameter that may be\r
36 NULL.\r
37\r
38 @return Index.\r
39\r
40**/\r
41UINT32\r
42EFIAPI\r
43AsmCpuidEx (\r
44 IN UINT32 Index,\r
45 IN UINT32 SubIndex,\r
46 OUT UINT32 *RegisterEax OPTIONAL,\r
47 OUT UINT32 *RegisterEbx OPTIONAL,\r
48 OUT UINT32 *RegisterEcx OPTIONAL,\r
49 OUT UINT32 *RegisterEdx OPTIONAL\r
50 )\r
51{\r
52 _asm {\r
53 mov eax, Index\r
54 mov ecx, SubIndex\r
55 cpuid\r
56 push ecx\r
57 mov ecx, RegisterEax\r
58 jecxz SkipEax\r
59 mov [ecx], eax\r
60SkipEax:\r
61 mov ecx, RegisterEbx\r
62 jecxz SkipEbx\r
63 mov [ecx], ebx\r
64SkipEbx:\r
65 pop eax\r
66 mov ecx, RegisterEcx\r
67 jecxz SkipEcx\r
68 mov [ecx], eax\r
69SkipEcx:\r
70 mov ecx, RegisterEdx\r
71 jecxz SkipEdx\r
72 mov [ecx], edx\r
73SkipEdx:\r
74 mov eax, Index\r
75 }\r
76}\r