VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c@ 94368

Last change on this file since 94368 was 89983, checked in by vboxsync, 4 years ago

Devices/EFI: Merge edk-stable202105 and openssl 1.1.1j and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1/** @file
2 Set TPM device type
3
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 TPM
6 hardware detection.
7
8 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
9 Copyright (C) 2018, Red Hat, Inc.
10
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12**/
13
14
15#include <PiPei.h>
16
17#include <Guid/TpmInstance.h>
18#include <Library/DebugLib.h>
19#include <Library/PeiServicesLib.h>
20#include <Library/Tpm2DeviceLib.h>
21#include <Ppi/TpmInitialized.h>
22
23#include "Tpm12Support.h"
24
25STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi = {
26 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
27 &gEfiTpmDeviceSelectedGuid,
28 NULL
29};
30
31STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {
32 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
33 &gPeiTpmInitializationDonePpiGuid,
34 NULL
35};
36
37/**
38 The entry point for Tcg2 configuration driver.
39
40 @param FileHandle Handle of the file being invoked.
41 @param PeiServices Describes the list of possible PEI Services.
42**/
43EFI_STATUS
44EFIAPI
45Tcg2ConfigPeimEntryPoint (
46 IN EFI_PEI_FILE_HANDLE FileHandle,
47 IN CONST EFI_PEI_SERVICES **PeiServices
48 )
49{
50 UINTN Size;
51 EFI_STATUS Status;
52
53 DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__));
54
55 Status = InternalTpm12Detect ();
56 if (!EFI_ERROR (Status)) {
57 DEBUG ((DEBUG_INFO, "%a: TPM1.2 detected\n", __FUNCTION__));
58 Size = sizeof (gEfiTpmDeviceInstanceTpm12Guid);
59 Status = PcdSetPtrS (
60 PcdTpmInstanceGuid,
61 &Size,
62 &gEfiTpmDeviceInstanceTpm12Guid
63 );
64 ASSERT_EFI_ERROR (Status);
65 } else {
66 Status = Tpm2RequestUseTpm ();
67 if (!EFI_ERROR (Status)) {
68 DEBUG ((DEBUG_INFO, "%a: TPM2 detected\n", __FUNCTION__));
69 Size = sizeof (gEfiTpmDeviceInstanceTpm20DtpmGuid);
70 Status = PcdSetPtrS (
71 PcdTpmInstanceGuid,
72 &Size,
73 &gEfiTpmDeviceInstanceTpm20DtpmGuid
74 );
75 ASSERT_EFI_ERROR (Status);
76 } else {
77 DEBUG ((DEBUG_INFO, "%a: no TPM detected\n", __FUNCTION__));
78 //
79 // If no TPM2 was detected, we still need to install
80 // TpmInitializationDonePpi. Namely, Tcg2Pei will exit early upon seeing
81 // the default (all-bits-zero) contents of PcdTpmInstanceGuid, thus we have
82 // to install the PPI in its place, in order to unblock any dependent
83 // PEIMs.
84 //
85 Status = PeiServicesInstallPpi (&mTpmInitializationDonePpiList);
86 ASSERT_EFI_ERROR (Status);
87 }
88 }
89
90 //
91 // Selection done
92 //
93 Status = PeiServicesInstallPpi (&mTpmSelectedPpi);
94 ASSERT_EFI_ERROR (Status);
95
96 return Status;
97}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette