2 This driver produces PEI_LOCK_PHYSICAL_PRESENCE_PPI to indicate
3 whether TPM need be locked or not. It can be replaced by a platform
6 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Ppi/LockPhysicalPresence.h>
13 #include <Ppi/ReadOnlyVariable2.h>
14 #include <Guid/PhysicalPresenceData.h>
15 #include <Library/PcdLib.h>
16 #include <Library/PeiServicesLib.h>
19 This interface returns whether TPM physical presence needs be locked or not.
21 @param[in] PeiServices The pointer to the PEI Services Table.
23 @retval TRUE The TPM physical presence should be locked.
24 @retval FALSE The TPM physical presence cannot be locked.
29 LockTpmPhysicalPresence (
30 IN CONST EFI_PEI_SERVICES
**PeiServices
34 // Gobal defintions for lock physical presence PPI and its descriptor.
36 PEI_LOCK_PHYSICAL_PRESENCE_PPI mLockPhysicalPresencePpi
= {
37 LockTpmPhysicalPresence
40 EFI_PEI_PPI_DESCRIPTOR mLockPhysicalPresencePpiList
= {
41 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
42 &gPeiLockPhysicalPresencePpiGuid
,
43 &mLockPhysicalPresencePpi
47 This interface returns whether TPM physical presence needs be locked or not.
49 @param[in] PeiServices The pointer to the PEI Services Table.
51 @retval TRUE The TPM physical presence should be locked.
52 @retval FALSE The TPM physical presence cannot be locked.
57 LockTpmPhysicalPresence (
58 IN CONST EFI_PEI_SERVICES
**PeiServices
62 EFI_PEI_READ_ONLY_VARIABLE2_PPI
*Variable
;
64 EFI_PHYSICAL_PRESENCE TcgPpData
;
67 // The CRTM has sensed the physical presence assertion of the user. For example,
68 // the user has pressed the startup button or inserted a USB dongle. The details
69 // of the implementation are vendor-specific. Here we read a PCD value to indicate
70 // whether operator physical presence.
72 if (!PcdGetBool (PcdTpmPhysicalPresence
)) {
77 // Check the pending TPM requests. Lock TPM physical presence if there is no TPM
80 Status
= PeiServicesLocatePpi (
81 &gEfiPeiReadOnlyVariable2PpiGuid
,
86 if (!EFI_ERROR (Status
)) {
87 DataSize
= sizeof (EFI_PHYSICAL_PRESENCE
);
88 Status
= Variable
->GetVariable (
90 PHYSICAL_PRESENCE_VARIABLE
,
91 &gEfiPhysicalPresenceGuid
,
96 if (!EFI_ERROR (Status
)) {
97 if (TcgPpData
.PPRequest
!= 0) {
104 // Lock TPM physical presence by default.
110 Entry point of this module.
112 It installs lock physical presence PPI.
114 @param[in] FileHandle Handle of the file being invoked.
115 @param[in] PeiServices Describes the list of possible PEI Services.
117 @return Status of install lock physical presence PPI.
123 IN EFI_PEI_FILE_HANDLE FileHandle
,
124 IN CONST EFI_PEI_SERVICES
**PeiServices
127 return PeiServicesInstallPpi (&mLockPhysicalPresencePpiList
);