TianoCore EDK2 master
Loading...
Searching...
No Matches
PhysicalPresencePei.c
Go to the documentation of this file.
1
11#include <PiPei.h>
15#include <Library/PcdLib.h>
17
27BOOLEAN
28EFIAPI
30 IN CONST EFI_PEI_SERVICES **PeiServices
31 );
32
33//
34// Global definitions for lock physical presence PPI and its descriptor.
35//
36PEI_LOCK_PHYSICAL_PRESENCE_PPI mLockPhysicalPresencePpi = {
38};
39
40EFI_PEI_PPI_DESCRIPTOR mLockPhysicalPresencePpiList = {
41 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
42 &gPeiLockPhysicalPresencePpiGuid,
43 &mLockPhysicalPresencePpi
44};
45
55BOOLEAN
56EFIAPI
58 IN CONST EFI_PEI_SERVICES **PeiServices
59 )
60{
61 EFI_STATUS Status;
63 UINTN DataSize;
64 EFI_PHYSICAL_PRESENCE TcgPpData;
65
66 //
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.
71 //
72 if (!PcdGetBool (PcdTpmPhysicalPresence)) {
73 return TRUE;
74 }
75
76 //
77 // Check the pending TPM requests. Lock TPM physical presence if there is no TPM
78 // request.
79 //
80 Status = PeiServicesLocatePpi (
81 &gEfiPeiReadOnlyVariable2PpiGuid,
82 0,
83 NULL,
84 (VOID **)&Variable
85 );
86 if (!EFI_ERROR (Status)) {
87 DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
88 Status = Variable->GetVariable (
89 Variable,
90 PHYSICAL_PRESENCE_VARIABLE,
91 &gEfiPhysicalPresenceGuid,
92 NULL,
93 &DataSize,
94 &TcgPpData
95 );
96 if (!EFI_ERROR (Status)) {
97 if (TcgPpData.PPRequest != 0) {
98 return FALSE;
99 }
100 }
101 }
102
103 //
104 // Lock TPM physical presence by default.
105 //
106 return TRUE;
107}
108
121EFIAPI
123 IN EFI_PEI_FILE_HANDLE FileHandle,
124 IN CONST EFI_PEI_SERVICES **PeiServices
125 )
126{
127 return PeiServicesInstallPpi (&mLockPhysicalPresencePpiList);
128}
UINT64 UINTN
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define PcdGetBool(TokenName)
Definition: PcdLib.h:401
BOOLEAN EFIAPI LockTpmPhysicalPresence(IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI PeimEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINT8 PPRequest
Physical Presence request command.