--- /dev/null
+/** @file\r
+ Platform specific TPM2 component for configuring the Platform Hierarchy.\r
+\r
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/TpmPlatformHierarchyLib.h>\r
+#include <Protocol/DxeSmmReadyToLock.h>\r
+\r
+/**\r
+ This callback function will run at the SmmReadyToLock event.\r
+\r
+ Configuration of the TPM's Platform Hierarchy Authorization Value (platformAuth)\r
+ and Platform Hierarchy Authorization Policy (platformPolicy) can be defined through this function.\r
+\r
+ @param Event Pointer to this event\r
+ @param Context Event hanlder private data\r
+ **/\r
+VOID\r
+EFIAPI\r
+SmmReadyToLockEventCallBack (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Interface;\r
+\r
+ //\r
+ // Try to locate it because EfiCreateProtocolNotifyEvent will trigger it once when registration.\r
+ // Just return if it is not found.\r
+ //\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiDxeSmmReadyToLockProtocolGuid,\r
+ NULL,\r
+ &Interface\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return ;\r
+ }\r
+\r
+ ConfigureTpmPlatformHierarchy ();\r
+\r
+ gBS->CloseEvent (Event);\r
+}\r
+\r
+/**\r
+ The driver's entry point. Will register a function for callback during SmmReadyToLock event to\r
+ configure the TPM's platform authorization.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcg2PlatformDxeEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ VOID *Registration;\r
+ EFI_EVENT Event;\r
+\r
+ Event = EfiCreateProtocolNotifyEvent (\r
+ &gEfiDxeSmmReadyToLockProtocolGuid,\r
+ TPL_CALLBACK,\r
+ SmmReadyToLockEventCallBack,\r
+ NULL,\r
+ &Registration\r
+ );\r
+\r
+ ASSERT (Event != NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r