33#define CONFIRM_BUFFER_SIZE 4096
68 OUT BOOLEAN *LifetimeLock,
69 OUT BOOLEAN *CmdEnable
76 UINT8 SendBuffer[
sizeof (*TpmRqu) +
sizeof (UINT32) * 3];
87 TpmRqu->paramSize =
SwapBytes32 (
sizeof (SendBuffer));
88 TpmRqu->ordinal =
SwapBytes32 (TPM_ORD_GetCapability);
93 SendBufPtr = (UINT32 *)(TpmRqu + 1);
98 Status = TcgProtocol->PassThroughToTpm (
105 if (EFI_ERROR (Status)) {
109 if ((TpmRsp->tag !=
SwapBytes16 (TPM_TAG_RSP_COMMAND)) || (TpmRsp->returnCode != 0)) {
110 return EFI_DEVICE_ERROR;
115 if (LifetimeLock !=
NULL) {
116 *LifetimeLock = TpmPermanentFlags->physicalPresenceLifetimeLock;
119 if (CmdEnable !=
NULL) {
120 *CmdEnable = TpmPermanentFlags->physicalPresenceCMDEnable;
147 UINT8 Buffer[
sizeof (*TpmRqu) +
sizeof (*TpmPp)];
154 TpmRqu->ordinal =
SwapBytes32 (TSC_ORD_PhysicalPresence);
157 Status = TcgProtocol->PassThroughToTpm (
164 if (EFI_ERROR (Status)) {
168 if (TpmRsp.tag !=
SwapBytes16 (TPM_TAG_RSP_COMMAND)) {
169 return EFI_DEVICE_ERROR;
172 if (TpmRsp.returnCode != 0) {
176 return EFI_SECURITY_VIOLATION;
199 IN UINTN AdditionalParameterSize,
200 IN VOID *AdditionalParameters
209 if (TpmRqu ==
NULL) {
210 return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
214 Size = (UINT32)(
sizeof (*TpmRqu) + AdditionalParameterSize);
217 CopyMem (TpmRqu + 1, AdditionalParameters, AdditionalParameterSize);
219 Status = TcgProtocol->PassThroughToTpm (
223 (UINT32)
sizeof (TpmRsp),
227 if (EFI_ERROR (Status) || (TpmRsp.tag !=
SwapBytes16 (TPM_TAG_RSP_COMMAND))) {
228 return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
250 IN UINT32 CommandCode,
258 switch (CommandCode) {
259 case PHYSICAL_PRESENCE_ENABLE:
262 TPM_ORD_PhysicalEnable,
267 case PHYSICAL_PRESENCE_DISABLE:
270 TPM_ORD_PhysicalDisable,
275 case PHYSICAL_PRESENCE_ACTIVATE:
279 TPM_ORD_PhysicalSetDeactivated,
284 case PHYSICAL_PRESENCE_DEACTIVATE:
288 TPM_ORD_PhysicalSetDeactivated,
293 case PHYSICAL_PRESENCE_CLEAR:
301 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:
303 if (TpmResponse == 0) {
309 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:
311 if (TpmResponse == 0) {
317 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:
321 TPM_ORD_SetOwnerInstall,
326 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:
330 TPM_ORD_SetOwnerInstall,
335 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:
340 if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {
342 PpiFlags->PPFlags |= TCG_VENDOR_LIB_FLAG_RESET_TRACK;
345 PpiFlags->PPFlags &= ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;
350 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:
352 if (TpmResponse == 0) {
358 case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:
361 InData[2] =
SwapBytes32 (TPM_SD_DEFERREDPHYSICALPRESENCE);
366 TPM_ORD_SetCapability,
371 case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:
377 return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
379 case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:
381 if (TpmResponse == 0) {
387 case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE:
388 PpiFlags->PPFlags &= ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;
391 case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:
392 PpiFlags->PPFlags |= TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;
395 case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:
396 PpiFlags->PPFlags &= ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;
399 case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
400 PpiFlags->PPFlags |= TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;
403 case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:
404 PpiFlags->PPFlags &= ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE;
407 case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:
408 PpiFlags->PPFlags |= TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE;
411 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:
416 if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {
418 PpiFlags->PPFlags |= TCG_VENDOR_LIB_FLAG_RESET_TRACK;
421 PpiFlags->PPFlags &= ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;
426 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:
431 if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {
433 PpiFlags->PPFlags |= TCG_VENDOR_LIB_FLAG_RESET_TRACK;
436 PpiFlags->PPFlags &= ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;
445 return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
460 IN BOOLEAN CautionKey
471 if (Status == EFI_NOT_READY) {
476 if (Status == EFI_DEVICE_ERROR) {
480 if (Key.ScanCode == SCAN_ESC) {
481 InputKey = Key.ScanCode;
484 if ((Key.ScanCode == SCAN_F10) && !CautionKey) {
485 InputKey = Key.ScanCode;
488 if ((Key.ScanCode == SCAN_F12) && CautionKey) {
489 InputKey = Key.ScanCode;
491 }
while (InputKey == 0);
493 if (InputKey != SCAN_ESC) {
519 mPpStringPackHandle =
HiiAddPackages (&gEfiPhysicalPresenceGuid, ImageHandle, DxeTcgPhysicalPresenceLibStrings,
NULL);
520 ASSERT (mPpStringPackHandle !=
NULL);
535 IN UINT32 TpmPpCommand
548 BufSize = CONFIRM_BUFFER_SIZE;
550 ASSERT (ConfirmText !=
NULL);
552 switch (TpmPpCommand) {
553 case PHYSICAL_PRESENCE_ENABLE:
561 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
565 case PHYSICAL_PRESENCE_DISABLE:
573 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
577 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
581 case PHYSICAL_PRESENCE_ACTIVATE:
589 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
593 case PHYSICAL_PRESENCE_DEACTIVATE:
601 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
605 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
609 case PHYSICAL_PRESENCE_CLEAR:
618 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
619 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), L
" \n\n", (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
623 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
627 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:
635 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
639 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
643 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:
651 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
655 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
659 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
663 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:
671 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
675 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:
683 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
687 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:
695 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
699 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
703 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:
711 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
715 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
719 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
723 case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:
732 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
736 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
740 case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:
748 case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:
757 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
761 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
765 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
769 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
773 case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:
781 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
785 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
789 case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
798 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
802 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
803 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), L
" \n\n", (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
807 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
811 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
815 case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:
824 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
828 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
832 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
836 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:
845 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
846 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), L
" \n\n", (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
850 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
854 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:
863 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
867 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
871 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
875 StrnCatS (ConfirmText, BufSize /
sizeof (CHAR16), TmpStr1, (BufSize /
sizeof (CHAR16)) -
StrLen (ConfirmText) - 1);
883 if (TmpStr2 ==
NULL) {
889 BufSize -=
StrSize (ConfirmText);
893 for (Index = 0; Index <
StrLen (ConfirmText); Index += 80) {
894 StrnCpyS (DstStr,
sizeof (DstStr) /
sizeof (CHAR16), ConfirmText + Index,
sizeof (DstStr) /
sizeof (CHAR16) - 1);
928 OUT BOOLEAN *RequestConfirmed
931 BOOLEAN IsRequestValid;
933 *RequestConfirmed =
FALSE;
935 switch (TcgPpData->PPRequest) {
936 case PHYSICAL_PRESENCE_NO_ACTION:
937 *RequestConfirmed =
TRUE;
939 case PHYSICAL_PRESENCE_ENABLE:
940 case PHYSICAL_PRESENCE_DISABLE:
941 case PHYSICAL_PRESENCE_ACTIVATE:
942 case PHYSICAL_PRESENCE_DEACTIVATE:
943 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:
944 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:
945 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:
946 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:
947 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:
948 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:
949 case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:
950 if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) {
951 *RequestConfirmed =
TRUE;
956 case PHYSICAL_PRESENCE_CLEAR:
957 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:
958 if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) {
959 *RequestConfirmed =
TRUE;
964 case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:
965 if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE) != 0) {
966 *RequestConfirmed =
TRUE;
971 case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:
972 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:
973 if (((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) && ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0)) {
974 *RequestConfirmed =
TRUE;
979 case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE:
980 case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:
981 case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:
982 *RequestConfirmed =
TRUE;
985 case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:
986 case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
987 case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:
991 if (TcgPpData->PPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
993 if (!IsRequestValid) {
1006 if ((Flags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) != 0) {
1010 *RequestConfirmed =
TRUE;
1040 BOOLEAN RequestConfirmed;
1042 BOOLEAN ResetRequired;
1049 TcgPpData->PPResponse = TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
1050 TcgPpData->LastPPRequest = TcgPpData->PPRequest;
1051 TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;
1053 Status =
gRT->SetVariable (
1054 PHYSICAL_PRESENCE_VARIABLE,
1055 &gEfiPhysicalPresenceGuid,
1063 ResetRequired =
FALSE;
1064 if (TcgPpData->PPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
1066 NewPPFlags = NewFlags.PPFlags;
1068 NewFlags.PPFlags = (UINT8)NewPPFlags;
1070 if (!RequestConfirmed) {
1074 RequestConfirmed =
UserConfirm (TcgPpData->PPRequest);
1080 TcgPpData->PPResponse = TCG_PP_OPERATION_RESPONSE_USER_ABORT;
1082 if (RequestConfirmed) {
1091 Status =
gRT->SetVariable (
1092 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
1093 &gEfiPhysicalPresenceGuid,
1098 if (EFI_ERROR (Status)) {
1106 if ((NewFlags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {
1107 TcgPpData->LastPPRequest = TcgPpData->PPRequest;
1108 TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;
1115 Status =
gRT->SetVariable (
1116 PHYSICAL_PRESENCE_VARIABLE,
1117 &gEfiPhysicalPresenceGuid,
1122 if (EFI_ERROR (Status)) {
1126 if (TcgPpData->PPResponse == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {
1133 switch (TcgPpData->LastPPRequest) {
1134 case PHYSICAL_PRESENCE_ACTIVATE:
1135 case PHYSICAL_PRESENCE_DEACTIVATE:
1136 case PHYSICAL_PRESENCE_CLEAR:
1137 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:
1138 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:
1139 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:
1140 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:
1141 case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:
1142 case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:
1143 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:
1144 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:
1147 if (TcgPpData->LastPPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
1148 if (ResetRequired) {
1155 if (TcgPpData->PPRequest != PHYSICAL_PRESENCE_NO_ACTION) {
1162 Print (L
"Rebooting system to make TPM settings in effect\n");
1187 BOOLEAN LifetimeLock;
1195 Status =
gBS->LocateProtocol (&gEfiTcgProtocolGuid,
NULL, (VOID **)&TcgProtocol);
1196 if (EFI_ERROR (Status)) {
1204 Status =
gRT->GetVariable (
1205 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
1206 &gEfiPhysicalPresenceGuid,
1211 if (EFI_ERROR (Status)) {
1212 PpiFlags.PPFlags = TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;
1213 Status =
gRT->SetVariable (
1214 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
1215 &gEfiPhysicalPresenceGuid,
1220 if (EFI_ERROR (Status)) {
1221 DEBUG ((DEBUG_ERROR,
"[TPM] Set physical presence flag failed, Status = %r\n", Status));
1226 DEBUG ((DEBUG_INFO,
"[TPM] PpiFlags = %x\n", PpiFlags.PPFlags));
1232 Status =
gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid,
NULL, (VOID **)&VariableLockProtocol);
1233 if (!EFI_ERROR (Status)) {
1234 Status = VariableLockProtocol->RequestToLock (
1235 VariableLockProtocol,
1236 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
1237 &gEfiPhysicalPresenceGuid
1239 if (EFI_ERROR (Status)) {
1240 DEBUG ((DEBUG_ERROR,
"[TPM] Error when lock variable %s, Status = %r\n", PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status));
1249 Status =
gRT->GetVariable (
1250 PHYSICAL_PRESENCE_VARIABLE,
1251 &gEfiPhysicalPresenceGuid,
1256 if (EFI_ERROR (Status)) {
1257 ZeroMem ((VOID *)&TcgPpData,
sizeof (TcgPpData));
1259 Status =
gRT->SetVariable (
1260 PHYSICAL_PRESENCE_VARIABLE,
1261 &gEfiPhysicalPresenceGuid,
1266 if (EFI_ERROR (Status)) {
1267 DEBUG ((DEBUG_ERROR,
"[TPM] Set physical presence variable failed, Status = %r\n", Status));
1272 DEBUG ((DEBUG_INFO,
"[TPM] Flags=%x, PPRequest=%x\n", PpiFlags.PPFlags, TcgPpData.
PPRequest));
1274 if (TcgPpData.
PPRequest == PHYSICAL_PRESENCE_NO_ACTION) {
1282 if (EFI_ERROR (Status)) {
1295 if (EFI_ERROR (Status)) {
1304 if (EFI_ERROR (Status)) {
1312 DEBUG ((DEBUG_INFO,
"[TPM] PPResponse = %x\n", TcgPpData.PPResponse));
1339 BOOLEAN RequestConfirmed;
1340 BOOLEAN LifetimeLock;
1345 Status =
gBS->LocateProtocol (&gEfiTcgProtocolGuid,
NULL, (VOID **)&TcgProtocol);
1346 if (EFI_ERROR (Status)) {
1354 Status =
gRT->GetVariable (
1355 PHYSICAL_PRESENCE_VARIABLE,
1356 &gEfiPhysicalPresenceGuid,
1361 if (EFI_ERROR (Status)) {
1366 Status =
gRT->GetVariable (
1367 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
1368 &gEfiPhysicalPresenceGuid,
1373 if (EFI_ERROR (Status)) {
1377 if (TcgPpData.
PPRequest == PHYSICAL_PRESENCE_NO_ACTION) {
1395 if (EFI_ERROR (Status)) {
1408 if (!RequestConfirmed) {
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)
RETURN_STATUS EFIAPI StrnCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI TcgPhysicalPresenceLibNeedUserConfirm(VOID)
UINT32 TpmCommandNoReturnData(IN EFI_TCG_PROTOCOL *TcgProtocol, IN TPM_COMMAND_CODE Ordinal, IN UINTN AdditionalParameterSize, IN VOID *AdditionalParameters)
EFI_STATUS GetTpmCapability(IN EFI_TCG_PROTOCOL *TcgProtocol, OUT BOOLEAN *LifetimeLock, OUT BOOLEAN *CmdEnable)
EFI_STATUS EFIAPI TcgPhysicalPresenceLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
BOOLEAN UserConfirm(IN UINT32 TpmPpCommand)
UINT32 ExecutePhysicalPresence(IN EFI_TCG_PROTOCOL *TcgProtocol, IN UINT32 CommandCode, IN OUT EFI_PHYSICAL_PRESENCE_FLAGS *PpiFlags)
BOOLEAN ReadUserKey(IN BOOLEAN CautionKey)
EFI_STATUS TpmPhysicalPresence(IN EFI_TCG_PROTOCOL *TcgProtocol, IN TPM_PHYSICAL_PRESENCE PhysicalPresence)
VOID EFIAPI TcgPhysicalPresenceLibProcessRequest(VOID)
CHAR16 * PhysicalPresenceGetStringById(IN EFI_STRING_ID Id)
VOID ExecutePendingTpmRequest(IN EFI_TCG_PROTOCOL *TcgProtocol, IN EFI_PHYSICAL_PRESENCE *TcgPpData, IN EFI_PHYSICAL_PRESENCE_FLAGS Flags)
BOOLEAN HaveValidTpmRequest(IN EFI_PHYSICAL_PRESENCE *TcgPpData, IN EFI_PHYSICAL_PRESENCE_FLAGS Flags, OUT BOOLEAN *RequestConfirmed)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
BOOLEAN EFIAPI TcgPpVendorLibHasValidRequest(IN UINT32 OperationRequest, IN UINT32 ManagementFlags, OUT BOOLEAN *RequestConfirmed)
UINT32 EFIAPI TcgPpVendorLibExecutePendingRequest(IN UINT32 OperationRequest, IN OUT UINT32 *ManagementFlags, OUT BOOLEAN *ResetRequired)
#define TPM_PHYSICAL_PRESENCE_LOCK
Sets PhysicalPresenceLock = TRUE.
#define TPM_PHYSICAL_PRESENCE_PRESENT
Sets PhysicalPresence = TRUE.
UINT16 TPM_PHYSICAL_PRESENCE
#define TPM_PHYSICAL_PRESENCE_NOTPRESENT
Sets PhysicalPresence = FALSE.
#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE
Sets the physicalPresenceCMDEnable to TRUE.
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
#define EFI_VARIABLE_NON_VOLATILE
UINT8 PPRequest
Physical Presence request command.
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn