--- /dev/null
+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/Tcg2PhysicalPresenceData.h>\r
+#include <Guid/TcgPhysicalPresenceStorageData.h>\r
+\r
+#include <IndustryStandard/TcgPhysicalPresence.h>\r
+\r
+#include <Protocol/VariableLock.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/Tcg2PhysicalPresenceLib.h>\r
+#include <Library/TcgPhysicalPresenceStorageLib.h>\r
+\r
+#include "DxeTcgPhysicalPresenceStorageLibInternal.h"\r
+\r
+/**\r
+ Display the confirm text and get user confirmation.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] ManagementFlags BIOS TPM Management Flags.\r
+\r
+\r
+ @retval TRUE The user need to confirme the changes.\r
+ @retval FALSE The user doesn't need to confirme the changes.\r
+**/\r
+BOOLEAN\r
+Tcg2PpNeedUserConfirm (\r
+ IN UINT8 OperationRequest,\r
+ IN UINT32 ManagementFlags\r
+ )\r
+{\r
+ BOOLEAN NeedUserConfirm;\r
+\r
+ NeedUserConfirm = FALSE;\r
+\r
+ switch (OperationRequest) {\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ if ((ManagementFlags & TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID) != 0) {\r
+ NeedUserConfirm = TRUE;\r
+ }\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ if ((ManagementFlags & TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID) != 0) {\r
+ NeedUserConfirm = TRUE;\r
+ }\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ NeedUserConfirm = TRUE;\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return NeedUserConfirm;\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] RequestParameter TPM physical presence operation request parameter.\r
+\r
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+**/\r
+UINT32\r
+EFIAPI\r
+Tcg2SubmitStorageRequest (\r
+ IN UINT32 OperationRequest,\r
+ IN UINT32 RequestParameter\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_TCG2_PHYSICAL_PRESENCE PpData;\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter));\r
+\r
+ //\r
+ // Get the Physical Presence storage variable\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Get PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+ }\r
+\r
+ if ((OperationRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) &&\r
+ (OperationRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
+ }\r
+\r
+ if ((PpData.PPRequest != OperationRequest) ||\r
+ (PpData.PPRequestParameter != RequestParameter)) {\r
+ PpData.PPRequest = (UINT8)OperationRequest;\r
+ PpData.PPRequestParameter = RequestParameter;\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &PpData\r
+ );\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+ }\r
+\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;\r
+}\r
+\r
+/**\r
+ Check if the pending TPM request needs user input to confirm.\r
+\r
+ The TPM request may come from OS. This API will check if TPM request exists and need user\r
+ input to confirmation.\r
+\r
+ @retval TRUE TPM needs input to confirm user physical presence.\r
+ @retval FALSE TPM doesn't need input to confirm user physical presence.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Tcg2NeedUserConfirm(\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_TCG2_PHYSICAL_PRESENCE TcgPpData;\r
+ UINTN DataSize;\r
+ EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS PpiFlags;\r
+\r
+ //\r
+ // Check S4 resume\r
+ //\r
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
+ DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
+ return FALSE;\r
+ }\r
+\r
+ //\r
+ // Check Tpm requests\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ PpiFlags.PPFlags = TCG2_BIOS_TPM_MANAGEMENT_FLAG_DEFAULT;\r
+ }\r
+\r
+ if ((TcgPpData.PPRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) &&\r
+ (TcgPpData.PPRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN)) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ return Tcg2PpNeedUserConfirm(TcgPpData.PPRequest, PpiFlags.PPFlags);\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation Response to OS Environment.\r
+\r
+ @param[out] MostRecentRequest Most recent operation request.\r
+ @param[out] Response Response to the most recent operation request.\r
+\r
+ @return Return Code for Return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+EFIAPI\r
+Tcg2ReturnOperationResponseToOsFunction (\r
+ OUT UINT32 *MostRecentRequest,\r
+ OUT UINT32 *Response\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_TCG2_PHYSICAL_PRESENCE PpData;\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] ReturnOperationResponseToOsFunction\n"));\r
+\r
+ //\r
+ // Get the Physical Presence variable\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ *MostRecentRequest = 0;\r
+ *Response = 0;\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Get PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;\r
+ }\r
+\r
+ *MostRecentRequest = PpData.LastPPRequest;\r
+ *Response = PpData.PPResponse;\r
+\r
+ return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;\r
+}\r
+\r
+/**\r
+ Check and execute the requested physical presence command.\r
+\r
+ This API should be invoked in BIOS boot phase to process pending request.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ If OperationRequest < 128, then ASSERT().\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in, out] ManagementFlags BIOS TPM Management Flags.\r
+ @param[out] ResetRequired If reset is required to vendor settings in effect.\r
+ True, it indicates the reset is required.\r
+ False, it indicates the reset is not required.\r
+\r
+ @return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+Tcg2ExecutePendingRequest (\r
+ IN UINT8 OperationRequest,\r
+ IN OUT UINT32 *ManagementFlags,\r
+ OUT BOOLEAN *ResetRequired\r
+ )\r
+{\r
+ ASSERT ((OperationRequest >= TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) &&\r
+ (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION));\r
+\r
+ if (Tcg2PpNeedUserConfirm(OperationRequest, *ManagementFlags)) {\r
+ if (!TcgPpUserConfirm (OperationRequest)) {\r
+ return TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+ }\r
+ }\r
+\r
+ switch (OperationRequest) {\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ *ManagementFlags|= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_FALSE:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_FALSE:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
+}\r
+\r
+/**\r
+ Check and execute the pending TPM request.\r
+\r
+ The TPM request may come from OS or BIOS. This API will display request information and wait\r
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
+ take effect.\r
+\r
+ This API should be invoked after console in and console out are all ready as they are required\r
+ to display request information and get user input to confirm the request.\r
+\r
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.\r
+**/\r
+VOID\r
+EFIAPI\r
+Tcg2ProcessStorageRequest (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_TCG2_PHYSICAL_PRESENCE TcgPpData;\r
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;\r
+ EFI_TCG2_PHYSICAL_PRESENCE_FLAGS PpiFlags;\r
+ EFI_TCG2_PHYSICAL_PRESENCE_FLAGS NewPpiFlags;\r
+ BOOLEAN ResetRequired;\r
+\r
+ //\r
+ // Check S4 resume\r
+ //\r
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
+ DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // Initialize physical presence variable.\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set physical presence variable failed, Status = %r\n", Status));\r
+ return ;\r
+ }\r
+ }\r
+\r
+ if ((TcgPpData.PPRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) ||\r
+ (TcgPpData.PPRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] Only support TCG storage related PP actions, not support PPRequest=%x\n", TcgPpData.PPRequest));\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Initialize physical presence flags.\r
+ //\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ PpiFlags.PPFlags = TCG_BIOS_STORAGE_MANAGEMENT_FLAG_DEFAULT;\r
+ Status = gRT->SetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS),\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set physical presence flag failed, Status = %r\n", Status));\r
+ return ;\r
+ }\r
+ }\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] PpiFlags = %x\n", PpiFlags.PPFlags));\r
+\r
+ //\r
+ // This flags variable controls whether physical presence is required for TPM command.\r
+ // It should be protected from malicious software. We set it as read-only variable here.\r
+ //\r
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = VariableLockProtocol->RequestToLock (\r
+ VariableLockProtocol,\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Error when lock variable %s, Status = %r\n", TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE, Status));\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ }\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags.PPFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
+\r
+ NewPpiFlags.PPFlags = PpiFlags.PPFlags;\r
+ ResetRequired = FALSE;\r
+ TcgPpData.PPResponse = TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+\r
+ TcgPpData.PPResponse = Tcg2ExecutePendingRequest (TcgPpData.PPRequest, &NewPpiFlags.PPFlags, &ResetRequired);\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags));\r
+\r
+ if (TcgPpData.PPResponse == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Save the flags if it is updated.\r
+ //\r
+ if (CompareMem (&PpiFlags, &NewPpiFlags, sizeof(EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS)) != 0) {\r
+ Status = gRT->SetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS),\r
+ &NewPpiFlags\r
+ );\r
+ }\r
+\r
+ //\r
+ // Clear request\r
+ //\r
+ TcgPpData.LastPPRequest = TcgPpData.PPRequest;\r
+ TcgPpData.PPRequest = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
+ TcgPpData.PPRequestParameter = 0;\r
+\r
+ //\r
+ // Save changes\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return;\r
+ }\r
+\r
+ if (!ResetRequired) {\r
+ return;\r
+ }\r
+\r
+ Print (L"Rebooting system to make TPM2 settings in effect\n");\r
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+ ASSERT (FALSE);\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef _TCG2_PHYSICAL_PRESENCE_STORAGE_H_\r
+#define _TCG2_PHYSICAL_PRESENCE_STORAGE_H_\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] RequestParameter TPM physical presence operation request parameter.\r
+\r
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+**/\r
+UINT32\r
+Tcg2SubmitStorageRequest (\r
+ IN UINT32 OperationRequest,\r
+ IN UINT32 RequestParameter\r
+ );\r
+\r
+/**\r
+ Check if the pending TPM request needs user input to confirm.\r
+\r
+ The TPM request may come from OS. This API will check if TPM request exists and need user\r
+ input to confirmation.\r
+\r
+ @retval TRUE TPM needs input to confirm user physical presence.\r
+ @retval FALSE TPM doesn't need input to confirm user physical presence.\r
+\r
+**/\r
+BOOLEAN\r
+Tcg2NeedUserConfirm(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation Response to OS Environment.\r
+\r
+ @param[out] MostRecentRequest Most recent operation request.\r
+ @param[out] Response Response to the most recent operation request.\r
+\r
+ @return Return Code for Return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+EFIAPI\r
+Tcg2ReturnOperationResponseToOsFunction (\r
+ OUT UINT32 *MostRecentRequest,\r
+ OUT UINT32 *Response\r
+ );\r
+\r
+/**\r
+ Check and execute the pending TPM request.\r
+\r
+ The TPM request may come from OS or BIOS. This API will display request information and wait\r
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
+ take effect.\r
+\r
+ This API should be invoked after console in and console out are all ready as they are required\r
+ to display request information and get user input to confirm the request.\r
+\r
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.\r
+**/\r
+VOID\r
+EFIAPI\r
+Tcg2ProcessStorageRequest (\r
+ VOID\r
+ );\r
+\r
+\r
+#endif\r
+\r
--- /dev/null
+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/PhysicalPresenceData.h>\r
+#include <Guid/TcgPhysicalPresenceStorageData.h>\r
+\r
+#include <IndustryStandard/TcgPhysicalPresence.h>\r
+\r
+\r
+#include <Protocol/VariableLock.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/TcgPhysicalPresenceStorageLib.h>\r
+\r
+#include "DxeTcgPhysicalPresenceStorageLibInternal.h"\r
+\r
+/**\r
+ Display the confirm text and get user confirmation.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] ManagementFlags BIOS TPM Management Flags.\r
+\r
+\r
+ @retval TRUE The user need to confirme the changes.\r
+ @retval FALSE The user doesn't need to confirme the changes.\r
+**/\r
+BOOLEAN\r
+TcgPpNeedUserConfirm (\r
+ IN UINT8 OperationRequest,\r
+ IN UINT32 ManagementFlags\r
+ )\r
+{\r
+ BOOLEAN NeedUserConfirm;\r
+\r
+ NeedUserConfirm = FALSE;\r
+\r
+ switch (OperationRequest) {\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ if ((ManagementFlags & TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID) != 0) {\r
+ NeedUserConfirm = TRUE;\r
+ }\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ if ((ManagementFlags & TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID) != 0) {\r
+ NeedUserConfirm = TRUE;\r
+ }\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ NeedUserConfirm = TRUE;\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return NeedUserConfirm;\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] RequestParameter TPM physical presence operation request parameter.\r
+\r
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgSubmitStorageRequest (\r
+ IN UINT32 OperationRequest,\r
+ IN UINT32 RequestParameter\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_PHYSICAL_PRESENCE PpData;\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter));\r
+\r
+ //\r
+ // Get the Physical Presence storage variable\r
+ //\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Get PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+ }\r
+\r
+ if ((OperationRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) &&\r
+ (OperationRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
+ }\r
+\r
+ if (PpData.PPRequest != OperationRequest) {\r
+ PpData.PPRequest = (UINT8)OperationRequest;\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &PpData\r
+ );\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+ }\r
+\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;\r
+}\r
+\r
+/**\r
+ Check if the pending TPM request needs user input to confirm.\r
+\r
+ The TPM request may come from OS. This API will check if TPM request exists and need user\r
+ input to confirmation.\r
+\r
+ @retval TRUE TPM needs input to confirm user physical presence.\r
+ @retval FALSE TPM doesn't need input to confirm user physical presence.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgNeedUserConfirm(\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PHYSICAL_PRESENCE TcgPpData;\r
+ UINTN DataSize;\r
+ EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS PpiFlags;\r
+\r
+ //\r
+ // Check S4 resume\r
+ //\r
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
+ DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
+ return FALSE;\r
+ }\r
+\r
+ //\r
+ // Check Tpm requests\r
+ //\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ PpiFlags.PPFlags = TCG_BIOS_STORAGE_MANAGEMENT_FLAG_DEFAULT;\r
+ }\r
+\r
+ if ((TcgPpData.PPRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) &&\r
+ (TcgPpData.PPRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ return TcgPpNeedUserConfirm(TcgPpData.PPRequest, PpiFlags.PPFlags);\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation Response to OS Environment.\r
+\r
+ @param[out] MostRecentRequest Most recent operation request.\r
+ @param[out] Response Response to the most recent operation request.\r
+\r
+ @return Return Code for Return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgReturnOperationResponseToOsFunction (\r
+ OUT UINT32 *MostRecentRequest,\r
+ OUT UINT32 *Response\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_PHYSICAL_PRESENCE PpData;\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] ReturnOperationResponseToOsFunction\n"));\r
+\r
+ //\r
+ // Get the Physical Presence variable\r
+ //\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ *MostRecentRequest = 0;\r
+ *Response = 0;\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Get PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;\r
+ }\r
+\r
+ *MostRecentRequest = PpData.LastPPRequest;\r
+ *Response = PpData.PPResponse;\r
+\r
+ return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;\r
+}\r
+\r
+/**\r
+ Check and execute the requested physical presence command.\r
+\r
+ This API should be invoked in BIOS boot phase to process pending request.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ If OperationRequest < 128, then ASSERT().\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in, out] ManagementFlags BIOS TPM Management Flags.\r
+ @param[out] ResetRequired If reset is required to vendor settings in effect.\r
+ True, it indicates the reset is required.\r
+ False, it indicates the reset is not required.\r
+\r
+ @return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+TcgExecutePendingRequest (\r
+ IN UINT8 OperationRequest,\r
+ IN OUT UINT8 *ManagementFlags,\r
+ OUT BOOLEAN *ResetRequired\r
+ )\r
+{\r
+ ASSERT ((OperationRequest >= TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) &&\r
+ (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION));\r
+\r
+ if (TcgPpNeedUserConfirm(OperationRequest, *ManagementFlags)) {\r
+ if (!TcgPpUserConfirm (OperationRequest)) {\r
+ return TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+ }\r
+ }\r
+\r
+ switch (OperationRequest) {\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_FALSE:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_FALSE:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
+}\r
+\r
+/**\r
+ Check and execute the pending TPM request.\r
+\r
+ The TPM request may come from OS or BIOS. This API will display request information and wait\r
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
+ take effect.\r
+\r
+ This API should be invoked after console in and console out are all ready as they are required\r
+ to display request information and get user input to confirm the request.\r
+\r
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.\r
+**/\r
+VOID\r
+EFIAPI\r
+TcgProcessStorageRequest (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_PHYSICAL_PRESENCE TcgPpData;\r
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;\r
+ EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags;\r
+ EFI_PHYSICAL_PRESENCE_FLAGS NewPpiFlags;\r
+ BOOLEAN ResetRequired;\r
+\r
+ //\r
+ // Check S4 resume\r
+ //\r
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
+ DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // Initialize physical presence variable.\r
+ //\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set physical presence variable failed, Status = %r\n", Status));\r
+ return ;\r
+ }\r
+ }\r
+\r
+ if ((TcgPpData.PPRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) ||\r
+ (TcgPpData.PPRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] Only support TCG storage related PP actions, not support PPRequest=%x\n", TcgPpData.PPRequest));\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Initialize physical presence storage flags.\r
+ //\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ PpiFlags.PPFlags = TCG_BIOS_STORAGE_MANAGEMENT_FLAG_DEFAULT;\r
+ Status = gRT->SetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS),\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set physical presence flag failed, Status = %r\n", Status));\r
+ return ;\r
+ }\r
+ }\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] PpiFlags = %x\n", PpiFlags.PPFlags));\r
+\r
+ //\r
+ // This flags variable controls whether physical presence is required for TPM command.\r
+ // It should be protected from malicious software. We set it as read-only variable here.\r
+ //\r
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = VariableLockProtocol->RequestToLock (\r
+ VariableLockProtocol,\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Error when lock variable %s, Status = %r\n", TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE, Status));\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ }\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags.PPFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
+\r
+ NewPpiFlags.PPFlags = PpiFlags.PPFlags;\r
+ ResetRequired = FALSE;\r
+ TcgPpData.PPResponse = TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+\r
+ TcgPpData.PPResponse = TcgExecutePendingRequest (TcgPpData.PPRequest, &NewPpiFlags.PPFlags, &ResetRequired);\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags));\r
+\r
+ if (TcgPpData.PPResponse == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Save the flags if it is updated.\r
+ //\r
+ if (CompareMem (&PpiFlags, &NewPpiFlags, sizeof(EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS)) != 0) {\r
+ Status = gRT->SetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS),\r
+ &NewPpiFlags\r
+ );\r
+ }\r
+\r
+ //\r
+ // Clear request\r
+ //\r
+ TcgPpData.LastPPRequest = TcgPpData.PPRequest;\r
+ TcgPpData.PPRequest = TCG_PHYSICAL_PRESENCE_NO_ACTION;\r
+\r
+ //\r
+ // Save changes\r
+ //\r
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiPhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return;\r
+ }\r
+\r
+ if (!ResetRequired) {\r
+ return;\r
+ }\r
+\r
+ Print (L"Rebooting system to make TPM2 settings in effect\n");\r
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+ ASSERT (FALSE);\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef _TCG_PHYSICAL_PRESENCE_STORAGE_H_\r
+#define _TCG_PHYSICAL_PRESENCE_STORAGE_H_\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] RequestParameter TPM physical presence operation request parameter.\r
+\r
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+**/\r
+UINT32\r
+TcgSubmitStorageRequest (\r
+ IN UINT32 OperationRequest,\r
+ IN UINT32 RequestParameter\r
+ );\r
+\r
+/**\r
+ Check if the pending TPM request needs user input to confirm.\r
+\r
+ The TPM request may come from OS. This API will check if TPM request exists and need user\r
+ input to confirmation.\r
+\r
+ @retval TRUE TPM needs input to confirm user physical presence.\r
+ @retval FALSE TPM doesn't need input to confirm user physical presence.\r
+\r
+**/\r
+BOOLEAN\r
+TcgNeedUserConfirm(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation Response to OS Environment.\r
+\r
+ @param[out] MostRecentRequest Most recent operation request.\r
+ @param[out] Response Response to the most recent operation request.\r
+\r
+ @return Return Code for Return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgReturnOperationResponseToOsFunction (\r
+ OUT UINT32 *MostRecentRequest,\r
+ OUT UINT32 *Response\r
+ );\r
+\r
+/**\r
+ Check and execute the pending TPM request.\r
+\r
+ The TPM request may come from OS or BIOS. This API will display request information and wait\r
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
+ take effect.\r
+\r
+ This API should be invoked after console in and console out are all ready as they are required\r
+ to display request information and get user input to confirm the request.\r
+\r
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.\r
+**/\r
+VOID\r
+EFIAPI\r
+TcgProcessStorageRequest (\r
+ VOID\r
+ );\r
+\r
+\r
+#endif\r
+\r
--- /dev/null
+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/PhysicalPresenceData.h>\r
+#include <Guid/Tcg2PhysicalPresenceData.h>\r
+#include <Guid/TcgPhysicalPresenceStorageData.h>\r
+\r
+#include <IndustryStandard/TcgPhysicalPresence.h>\r
+\r
+#include <Protocol/VariableLock.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include <Library/TcgPhysicalPresenceStorageLib.h>\r
+\r
+#include "DxeTcgPhysicalPresenceStorage.h"\r
+#include "DxeTcg2PhysicalPresenceStorage.h"\r
+\r
+#define CONFIRM_BUFFER_SIZE 4096\r
+\r
+EFI_HII_HANDLE mTcgPpStorageStringPackHandle;\r
+\r
+/**\r
+ Get string by string id from HII Interface.\r
+\r
+ @param[in] Id String ID.\r
+\r
+ @retval CHAR16 * String from ID.\r
+ @retval NULL If error occurs.\r
+\r
+**/\r
+CHAR16 *\r
+TcgPpGetStringById (\r
+ IN EFI_STRING_ID Id\r
+ )\r
+{\r
+ return HiiGetString (mTcgPpStorageStringPackHandle, Id, NULL);\r
+}\r
+\r
+/**\r
+ Read the specified key for user confirmation.\r
+\r
+ @retval TRUE User confirmed the changes by input.\r
+ @retval FALSE User discarded the changes.\r
+**/\r
+BOOLEAN\r
+TcgPpStrageReadUserKey (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_INPUT_KEY Key;\r
+ UINT16 InputKey;\r
+\r
+ InputKey = 0;\r
+ do {\r
+ Status = gBS->CheckEvent (gST->ConIn->WaitForKey);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+ if (Key.ScanCode == SCAN_ESC) {\r
+ InputKey = Key.ScanCode;\r
+ }\r
+ if ((Key.ScanCode == SCAN_F10)) {\r
+ InputKey = Key.ScanCode;\r
+ }\r
+ }\r
+ } while (InputKey == 0);\r
+\r
+ if (InputKey != SCAN_ESC) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ Display the confirm text and get user confirmation.\r
+\r
+ @param[in] TpmPpCommand The requested TPM physical presence command.\r
+\r
+ @retval TRUE The user has confirmed the changes.\r
+ @retval FALSE The user doesn't confirm the changes.\r
+**/\r
+BOOLEAN\r
+TcgPpUserConfirm (\r
+ IN UINT8 TpmPpCommand\r
+ )\r
+{\r
+ CHAR16 *ConfirmText;\r
+ CHAR16 *TmpStr1;\r
+ CHAR16 *TmpStr2;\r
+ UINTN BufSize;\r
+ UINT16 Index;\r
+ CHAR16 DstStr[81];\r
+\r
+ TmpStr2 = NULL;\r
+ BufSize = CONFIRM_BUFFER_SIZE;\r
+ ConfirmText = AllocateZeroPool (BufSize);\r
+ ASSERT (ConfirmText != NULL);\r
+\r
+ switch (TpmPpCommand) {\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ TmpStr2 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_PP_ENABLE_BLOCK_SID));\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_HEAD_STR));\r
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
+ FreePool (TmpStr1);\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_FALSE:\r
+ TmpStr2 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_PP_ENABLE_BLOCK_SID));\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_HEAD_STR));\r
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
+ FreePool (TmpStr1);\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ TmpStr2 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_PP_DISABLE_BLOCK_SID));\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_HEAD_STR));\r
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
+ FreePool (TmpStr1);\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_FALSE:\r
+ TmpStr2 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_PP_DISABLE_BLOCK_SID));\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_HEAD_STR));\r
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
+ FreePool (TmpStr1);\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ TmpStr2 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_ENABLE_BLOCK_SID));\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_HEAD_STR));\r
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
+ FreePool (TmpStr1);\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ TmpStr2 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_DISABLE_BLOCK_SID));\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_HEAD_STR));\r
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
+ FreePool (TmpStr1);\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_ACCEPT_KEY));\r
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
+ FreePool (TmpStr1);\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_NO_PPI_INFO));\r
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
+ FreePool (TmpStr1);\r
+\r
+\r
+ TmpStr1 = TcgPpGetStringById (STRING_TOKEN (TCG_STORAGE_REJECT_KEY));\r
+ BufSize -= StrSize (ConfirmText);\r
+ UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, TmpStr2);\r
+\r
+ DstStr[80] = L'\0';\r
+ for (Index = 0; Index < StrLen (ConfirmText); Index += 80) {\r
+ StrnCpyS (DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Index, sizeof (DstStr) / sizeof (CHAR16) - 1);\r
+ Print (DstStr);\r
+ }\r
+\r
+ FreePool (TmpStr1);\r
+ FreePool (TmpStr2);\r
+ FreePool (ConfirmText);\r
+\r
+ if (TcgPpStrageReadUserKey ()) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] RequestParameter TPM physical presence operation request parameter.\r
+\r
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibSubmitRequestToPreOSFunction (\r
+ IN UINT32 OperationRequest,\r
+ IN UINT32 RequestParameter\r
+ )\r
+{\r
+ //\r
+ // Get Physical Presence command state\r
+ //\r
+ if (CompareGuid(PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) {\r
+ return TcgSubmitStorageRequest (OperationRequest, RequestParameter);\r
+ } else {\r
+ return Tcg2SubmitStorageRequest (OperationRequest, RequestParameter);\r
+ }\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation Response to OS Environment.\r
+\r
+ @param[out] MostRecentRequest Most recent operation request.\r
+ @param[out] Response Response to the most recent operation request.\r
+\r
+ @return Return Code for Return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibReturnOperationResponseToOsFunction (\r
+ OUT UINT32 *MostRecentRequest,\r
+ OUT UINT32 *Response\r
+ )\r
+{\r
+ //\r
+ // Get Physical Presence command state\r
+ //\r
+ if (CompareGuid(PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) {\r
+ return TcgReturnOperationResponseToOsFunction (MostRecentRequest, Response);\r
+ } else {\r
+ return Tcg2ReturnOperationResponseToOsFunction (MostRecentRequest, Response);\r
+ }\r
+}\r
+\r
+/**\r
+ Check if the pending TPM request needs user input to confirm.\r
+\r
+ The TPM request may come from OS. This API will check if TPM request exists and need user\r
+ input to confirmation.\r
+\r
+ @retval TRUE TPM needs input to confirm user physical presence.\r
+ @retval FALSE TPM doesn't need input to confirm user physical presence.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibNeedUserConfirm(\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Get Physical Presence command state\r
+ //\r
+ if (CompareGuid(PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) {\r
+ return TcgNeedUserConfirm ();\r
+ } else {\r
+ return Tcg2NeedUserConfirm ();\r
+ }\r
+}\r
+\r
+/**\r
+ Check and execute the pending TPM request.\r
+\r
+ The TPM request may come from OS or BIOS. This API will display request information and wait\r
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
+ take effect.\r
+\r
+ This API should be invoked after console in and console out are all ready as they are required\r
+ to display request information and get user input to confirm the request.\r
+\r
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.\r
+**/\r
+VOID\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibProcessRequest (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Get Physical Presence command state\r
+ //\r
+ if (CompareGuid(PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) {\r
+ TcgProcessStorageRequest();\r
+ } else {\r
+ Tcg2ProcessStorageRequest ();\r
+ }\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation flag variable.\r
+\r
+ @return Return Code for Return TPM Operation flag variable.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibReturnStorageFlags (\r
+ VOID\r
+ )\r
+{\r
+ UINTN DataSize;\r
+ EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS PpiFlags;\r
+ EFI_STATUS Status;\r
+\r
+\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return TCG_BIOS_STORAGE_MANAGEMENT_FLAG_DEFAULT;\r
+ }\r
+\r
+ return PpiFlags.PPFlags;\r
+}\r
+\r
+/**\r
+\r
+ Install Boot Manager Menu driver.\r
+\r
+ @param ImageHandle The image handle.\r
+ @param SystemTable The system table.\r
+\r
+ @retval EFI_SUCEESS Install Boot manager menu success.\r
+ @retval Other Return error status.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ mTcgPpStorageStringPackHandle = HiiAddPackages (&gEfiTcgPhysicalPresenceStorageGuid, gImageHandle, DxeTcgPhysicalPresenceStorageLibStrings, NULL);\r
+ ASSERT (mTcgPpStorageStringPackHandle != NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Unloads the application and its installed protocol.\r
+\r
+ @param[in] ImageHandle Handle that identifies the image to be unloaded.\r
+ @param[in] SystemTable System Table\r
+\r
+ @retval EFI_SUCCESS The image has been unloaded.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TcgPhysicalPresenceStorageLibDestructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ HiiRemovePackages (mTcgPpStorageStringPackHandle);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+## @file\r
+# Tcg PP storage library instance that does support any storage specific PPI.\r
+#\r
+# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeTcgPhysicalPresenceStorageLib\r
+ MODULE_UNI_FILE = DxeTcgPhysicalPresenceStorageLib.uni\r
+ FILE_GUID = 51924AE9-BE81-4820-94BA-7C9546E702D0\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TcgPhysicalPresenceStorageLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_DRIVER\r
+ CONSTRUCTOR = TcgPhysicalPresenceStorageLibConstructor\r
+ DESTRUCTOR = TcgPhysicalPresenceStorageLibDestructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+ DxeTcgPhysicalPresenceStorageLib.c\r
+ DxeTcgPhysicalPresenceStorageLibStrings.uni\r
+ DxeTcg2PhysicalPresenceStorage.c\r
+ DxeTcg2PhysicalPresenceStorage.h\r
+ DxeTcgPhysicalPresenceStorage.c\r
+ DxeTcgPhysicalPresenceStorage.h\r
+ DxeTcgPhysicalPresenceStorageLibInternal.h\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ SecurityPkg/SecurityPkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ MemoryAllocationLib\r
+ UefiLib\r
+ UefiBootServicesTableLib\r
+ UefiDriverEntryPoint\r
+ UefiRuntimeServicesTableLib\r
+ BaseMemoryLib\r
+ DebugLib\r
+ PrintLib\r
+ HiiLib\r
+ HobLib\r
+\r
+[Guids]\r
+ gEfiTcgPhysicalPresenceStorageGuid ## SOMETIMES_CONSUMES ## HII\r
+ gEfiTpmDeviceInstanceTpm12Guid ## SOMETIMES_CONSUMES\r
+ gEfiPhysicalPresenceGuid ## SOMETIMES_CONSUMES\r
+ gEfiTcg2PhysicalPresenceGuid ## SOMETIMES_CONSUMES\r
+\r
+[Pcd]\r
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid ## CONSUMES\r
+\r
+[Protocols]\r
+ gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES\r
--- /dev/null
+// /** @file\r
+// Tcg PP storage library instance that does support any storage specific PPI.\r
+//\r
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+//\r
+// This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution. The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// **/\r
+\r
+#string STR_MODULE_ABSTRACT #language en-US "Tcg PP Storage library instance that supports any storage specific PPI"\r
+\r
+#string STR_MODULE_DESCRIPTION #language en-US "Tcg PP Storage library instance that supports any storage specific PPI."\r
+\r
--- /dev/null
+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef _TCG_PHYSICAL_PRESENCE_STORAGE_LIB_INTENAL_H_\r
+#define _TCG_PHYSICAL_PRESENCE_STORAGE_LIB_INTENAL_H_\r
+/**\r
+ Display the confirm text and get user confirmation.\r
+\r
+ @param[in] TpmPpCommand The requested TPM physical presence command.\r
+\r
+ @retval TRUE The user has confirmed the changes.\r
+ @retval FALSE The user doesn't confirm the changes.\r
+**/\r
+BOOLEAN\r
+TcgPpUserConfirm (\r
+ IN UINT8 TpmPpCommand\r
+ );\r
+\r
+\r
+#endif\r
+\r
--- /dev/null
+/** @file\r
+ String definitions for TPM 1.2 & 2.0 physical presence storage related actions confirm text.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#langdef en-US "English"\r
+\r
+#string TCG_STORAGE_HEAD_STR #language en-US "A configuration change was requested to %s on subsequent boots\n\n"\r
+#string TCG_STORAGE_PPI_HEAD_STR #language en-US "A configuration change was requested to allow the Operating System to %s without asking for user confirmation in the future.\n\n"\r
+\r
+#string TCG_STORAGE_ACCEPT_KEY #language en-US "Press F10 "\r
+#string TCG_STORAGE_CAUTION_KEY #language en-US "Press F12 "\r
+#string TCG_STORAGE_REJECT_KEY #language en-US "to %s\nPress ESC to reject this change request and continue\n"\r
+\r
+#string TCG_STORAGE_NO_PPI_INFO #language en-US "to approve future Operating System requests "\r
+\r
+#string TCG_STORAGE_ENABLE_BLOCK_SID #language en-US "issue Block SID "\r
+#string TCG_STORAGE_DISABLE_BLOCK_SID #language en-US "disable issuing Block SID "\r
+\r
+#string TCG_STORAGE_PP_ENABLE_BLOCK_SID #language en-US "enable blocking SID authentication"\r
+#string TCG_STORAGE_PP_DISABLE_BLOCK_SID #language en-US "disable blocking SID authentication"\r
+\r
#\r
Tcg2PpVendorLib|Include/Library/TcgPpVendorLib.h\r
\r
+ ## @libraryclass Provides support for TCG Physical Presence Interface (PPI) specification\r
+ # >= 96 && < 128 Vendor Specific PPI Operation.\r
+ #\r
+ TcgPhysicalPresenceStorageLib|Include/Library/TcgPhysicalPresenceStorageLib.h\r
+\r
## @libraryclass Handle TPM 2.0 physical presence request from OS.\r
#\r
Tcg2PhysicalPresenceLib|Include/Library/Tcg2PhysicalPresenceLib.h\r
# Include/Guid/Tcg2PhysicalPresenceData.h\r
gEfiTcg2PhysicalPresenceGuid = { 0xaeb9c5c1, 0x94f1, 0x4d02, { 0xbf, 0xd9, 0x46, 0x2, 0xdb, 0x2d, 0x3c, 0x54 }}\r
\r
+ ##\r
+ # Include/Guid/Tcg2PhysicalPresenceData.h\r
+ gEfiTcgPhysicalPresenceStorageGuid = { 0x2EBE3E34, 0xB3CD, 0x471A, { 0xBF, 0x87, 0xB3, 0xC6, 0x6E, 0xE0, 0x74, 0x9A}}\r
+\r
## GUID used for form browser, password credential and provider identifier.\r
# Include/Guid/PwdCredentialProviderHii.h\r
gPwdCredentialProviderGuid = { 0x78b9ec8b, 0xc000, 0x46c5, { 0xac, 0x93, 0x24, 0xa0, 0xc1, 0xbb, 0x0, 0xce }}\r
Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf\r
Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf\r
FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf\r
+ TcgPhysicalPresenceStorageLib|SecurityPkg/Library/DxeTcgPhysicalPresenceStorageLib/DxeTcgPhysicalPresenceStorageLib.inf\r
\r
[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_SAL_DRIVER,]\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
SecurityPkg/Library/TcgStorageCoreLib/TcgStorageCoreLib.inf\r
SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalLib.inf\r
SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.inf\r
+ SecurityPkg/Library/DxeTcgPhysicalPresenceStorageLib/DxeTcgPhysicalPresenceStorageLib.inf\r
\r
#\r
# Other\r