TianoCore EDK2 master
Loading...
Searching...
No Matches
TdProbe.c
Go to the documentation of this file.
1
8#include <Library/BaseLib.h>
10
17BOOLEAN
18EFIAPI
20 )
21{
22 UINT32 Eax;
23 UINT32 Ebx;
24 UINT32 Ecx;
25 UINT32 Edx;
26 UINT32 LargestEax;
27 BOOLEAN TdEnabled;
28 CPUID_VERSION_INFO_ECX CpuIdVersionInfoEcx;
29
30 TdEnabled = FALSE;
31
32 do {
33 AsmCpuid (CPUID_SIGNATURE, &LargestEax, &Ebx, &Ecx, &Edx);
34
36 || (Edx != CPUID_SIGNATURE_GENUINE_INTEL_EDX)
37 || (Ecx != CPUID_SIGNATURE_GENUINE_INTEL_ECX))
38 {
39 break;
40 }
41
42 AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, &CpuIdVersionInfoEcx.Uint32, NULL);
43 if (CpuIdVersionInfoEcx.Bits.ParaVirtualized == 0) {
44 break;
45 }
46
47 if (LargestEax < CPUID_GUESTTD_RUNTIME_ENVIRONMENT) {
48 break;
49 }
50
51 AsmCpuidEx (CPUID_GUESTTD_RUNTIME_ENVIRONMENT, 0, &Eax, &Ebx, &Ecx, &Edx);
53 || (Edx != CPUID_GUESTTD_SIGNATURE_GENUINE_INTEL_EDX)
54 || (Ecx != CPUID_GUESTTD_SIGNATURE_GENUINE_INTEL_ECX))
55 {
56 break;
57 }
58
59 TdEnabled = TRUE;
60 } while (FALSE);
61
62 return TdEnabled;
63}
UINT32 EFIAPI AsmCpuidEx(IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
Definition: CpuIdEx.c:43
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define CPUID_GUESTTD_RUNTIME_ENVIRONMENT
Definition: Cpuid.h:3716
#define CPUID_SIGNATURE
Definition: Cpuid.h:45
#define CPUID_SIGNATURE_GENUINE_INTEL_EBX
Definition: Cpuid.h:50
#define CPUID_GUESTTD_SIGNATURE_GENUINE_INTEL_EBX
Definition: Cpuid.h:3721
#define CPUID_VERSION_INFO
Definition: Cpuid.h:81
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
Definition: CpuId.c:36
BOOLEAN EFIAPI TdIsEnabled()
Definition: TdProbe.c:19
UINT32 ParaVirtualized
Definition: Cpuid.h:328
struct CPUID_VERSION_INFO_ECX::@695 Bits