]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c
8bee1926b3c45c2c0e2f86601150199692868560
[mirror_edk2.git] / OvmfPkg / Tcg / Tcg2Config / Tcg2ConfigPeim.c
1 /** @file
2 The module entry point for Tcg2 configuration module.
3
4 Copyright (c) 2018, Red Hat, Inc.
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17
18 #include <PiPei.h>
19
20 #include <Guid/TpmInstance.h>
21 #include <Library/DebugLib.h>
22 #include <Library/PeiServicesLib.h>
23 #include <Library/Tpm2DeviceLib.h>
24 #include <Ppi/TpmInitialized.h>
25
26 STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi = {
27 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
28 &gEfiTpmDeviceSelectedGuid,
29 NULL
30 };
31
32 STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {
33 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
34 &gPeiTpmInitializationDonePpiGuid,
35 NULL
36 };
37
38 /**
39 The entry point for Tcg2 configuration driver.
40
41 @param FileHandle Handle of the file being invoked.
42 @param PeiServices Describes the list of possible PEI Services.
43 **/
44 EFI_STATUS
45 EFIAPI
46 Tcg2ConfigPeimEntryPoint (
47 IN EFI_PEI_FILE_HANDLE FileHandle,
48 IN CONST EFI_PEI_SERVICES **PeiServices
49 )
50 {
51 UINTN Size;
52 EFI_STATUS Status;
53
54 DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__));
55
56 Status = Tpm2RequestUseTpm ();
57 if (!EFI_ERROR (Status)) {
58 DEBUG ((DEBUG_INFO, "%a: TPM2 detected\n", __FUNCTION__));
59 Size = sizeof(gEfiTpmDeviceInstanceTpm20DtpmGuid);
60 Status = PcdSetPtrS (
61 PcdTpmInstanceGuid,
62 &Size,
63 &gEfiTpmDeviceInstanceTpm20DtpmGuid
64 );
65 ASSERT_EFI_ERROR (Status);
66 } else {
67 DEBUG ((DEBUG_INFO, "%a: no TPM2 detected\n", __FUNCTION__));
68 // If no TPM2 was detected, we still need to install
69 // TpmInitializationDonePpi. Namely, Tcg2Pei will exit early upon
70 // seeing the default (all-bits-zero) contents of
71 // PcdTpmInstanceGuid, thus we have to install the PPI in its place,
72 // in order to unblock any dependent PEIMs.
73 Status = PeiServicesInstallPpi (&mTpmInitializationDonePpiList);
74 ASSERT_EFI_ERROR (Status);
75 }
76
77 //
78 // Selection done
79 //
80 Status = PeiServicesInstallPpi (&mTpmSelectedPpi);
81 ASSERT_EFI_ERROR (Status);
82
83 return Status;
84 }