]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/PhysicalPresencePei/PhysicalPresencePei.c
SecurityPkg: Fix spelling errors
[mirror_edk2.git] / SecurityPkg / Tcg / PhysicalPresencePei / PhysicalPresencePei.c
CommitLineData
0c18794e 1/** @file\r
b3548d32
LG
2 This driver produces PEI_LOCK_PHYSICAL_PRESENCE_PPI to indicate\r
3 whether TPM need be locked or not. It can be replaced by a platform\r
0c18794e 4 specific driver.\r
5\r
b3548d32 6Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
289b714b 7SPDX-License-Identifier: BSD-2-Clause-Patent\r
0c18794e 8\r
9**/\r
10\r
11#include <PiPei.h>\r
12#include <Ppi/LockPhysicalPresence.h>\r
13#include <Ppi/ReadOnlyVariable2.h>\r
14#include <Guid/PhysicalPresenceData.h>\r
15#include <Library/PcdLib.h>\r
16#include <Library/PeiServicesLib.h>\r
17\r
18/**\r
19 This interface returns whether TPM physical presence needs be locked or not.\r
20\r
21 @param[in] PeiServices The pointer to the PEI Services Table.\r
22\r
23 @retval TRUE The TPM physical presence should be locked.\r
24 @retval FALSE The TPM physical presence cannot be locked.\r
25\r
26**/\r
27BOOLEAN\r
28EFIAPI\r
29LockTpmPhysicalPresence (\r
30 IN CONST EFI_PEI_SERVICES **PeiServices\r
31 );\r
32\r
33//\r
d6b926e7 34// Global defintions for lock physical presence PPI and its descriptor.\r
0c18794e 35//\r
36PEI_LOCK_PHYSICAL_PRESENCE_PPI mLockPhysicalPresencePpi = {\r
37 LockTpmPhysicalPresence\r
38};\r
39\r
40EFI_PEI_PPI_DESCRIPTOR mLockPhysicalPresencePpiList = {\r
41 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
42 &gPeiLockPhysicalPresencePpiGuid,\r
43 &mLockPhysicalPresencePpi\r
44};\r
45\r
46/**\r
47 This interface returns whether TPM physical presence needs be locked or not.\r
48\r
49 @param[in] PeiServices The pointer to the PEI Services Table.\r
50\r
51 @retval TRUE The TPM physical presence should be locked.\r
52 @retval FALSE The TPM physical presence cannot be locked.\r
53\r
54**/\r
55BOOLEAN\r
56EFIAPI\r
57LockTpmPhysicalPresence (\r
58 IN CONST EFI_PEI_SERVICES **PeiServices\r
59 )\r
60{\r
61 EFI_STATUS Status;\r
62 EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;\r
63 UINTN DataSize;\r
64 EFI_PHYSICAL_PRESENCE TcgPpData;\r
65\r
66 //\r
b3548d32
LG
67 // The CRTM has sensed the physical presence assertion of the user. For example,\r
68 // the user has pressed the startup button or inserted a USB dongle. The details\r
0c18794e 69 // of the implementation are vendor-specific. Here we read a PCD value to indicate\r
70 // whether operator physical presence.\r
b3548d32 71 //\r
0c18794e 72 if (!PcdGetBool (PcdTpmPhysicalPresence)) {\r
73 return TRUE;\r
74 }\r
75\r
76 //\r
b3548d32
LG
77 // Check the pending TPM requests. Lock TPM physical presence if there is no TPM\r
78 // request.\r
0c18794e 79 //\r
80 Status = PeiServicesLocatePpi (\r
81 &gEfiPeiReadOnlyVariable2PpiGuid,\r
82 0,\r
83 NULL,\r
84 (VOID **)&Variable\r
85 );\r
86 if (!EFI_ERROR (Status)) {\r
87 DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
b3548d32
LG
88 Status = Variable->GetVariable (\r
89 Variable,\r
0c18794e 90 PHYSICAL_PRESENCE_VARIABLE,\r
91 &gEfiPhysicalPresenceGuid,\r
92 NULL,\r
93 &DataSize,\r
94 &TcgPpData\r
95 );\r
96 if (!EFI_ERROR (Status)) {\r
97 if (TcgPpData.PPRequest != 0) {\r
98 return FALSE;\r
99 }\r
100 }\r
101 }\r
102\r
103 //\r
104 // Lock TPM physical presence by default.\r
105 //\r
106 return TRUE;\r
107}\r
108\r
109/**\r
110 Entry point of this module.\r
111\r
b3548d32 112 It installs lock physical presence PPI.\r
0c18794e 113\r
114 @param[in] FileHandle Handle of the file being invoked.\r
115 @param[in] PeiServices Describes the list of possible PEI Services.\r
116\r
117 @return Status of install lock physical presence PPI.\r
118\r
119**/\r
120EFI_STATUS\r
121EFIAPI\r
122PeimEntry (\r
123 IN EFI_PEI_FILE_HANDLE FileHandle,\r
124 IN CONST EFI_PEI_SERVICES **PeiServices\r
125 )\r
126{\r
127 return PeiServicesInstallPpi (&mLockPhysicalPresencePpiList);\r
128}\r