4 In SecurityPkg, this module initializes the TPM device type based on a UEFI
5 variable and/or hardware detection. In OvmfPkg, the module only performs TPM2
8 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
9 Copyright (C) 2018, Red Hat, Inc.
11 This program and the accompanying materials are licensed and made available
12 under the terms and conditions of the BSD License which accompanies this
13 distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
17 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include <Guid/TpmInstance.h>
24 #include <Library/DebugLib.h>
25 #include <Library/PeiServicesLib.h>
26 #include <Library/Tpm2DeviceLib.h>
27 #include <Ppi/TpmInitialized.h>
29 STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi
= {
30 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
31 &gEfiTpmDeviceSelectedGuid
,
35 STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList
= {
36 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
37 &gPeiTpmInitializationDonePpiGuid
,
42 The entry point for Tcg2 configuration driver.
44 @param FileHandle Handle of the file being invoked.
45 @param PeiServices Describes the list of possible PEI Services.
49 Tcg2ConfigPeimEntryPoint (
50 IN EFI_PEI_FILE_HANDLE FileHandle
,
51 IN CONST EFI_PEI_SERVICES
**PeiServices
57 DEBUG ((DEBUG_INFO
, "%a\n", __FUNCTION__
));
59 Status
= Tpm2RequestUseTpm ();
60 if (!EFI_ERROR (Status
)) {
61 DEBUG ((DEBUG_INFO
, "%a: TPM2 detected\n", __FUNCTION__
));
62 Size
= sizeof (gEfiTpmDeviceInstanceTpm20DtpmGuid
);
66 &gEfiTpmDeviceInstanceTpm20DtpmGuid
68 ASSERT_EFI_ERROR (Status
);
70 DEBUG ((DEBUG_INFO
, "%a: no TPM2 detected\n", __FUNCTION__
));
72 // If no TPM2 was detected, we still need to install
73 // TpmInitializationDonePpi. Namely, Tcg2Pei will exit early upon seeing
74 // the default (all-bits-zero) contents of PcdTpmInstanceGuid, thus we have
75 // to install the PPI in its place, in order to unblock any dependent
78 Status
= PeiServicesInstallPpi (&mTpmInitializationDonePpiList
);
79 ASSERT_EFI_ERROR (Status
);
85 Status
= PeiServicesInstallPpi (&mTpmSelectedPpi
);
86 ASSERT_EFI_ERROR (Status
);