--- /dev/null
+/** @file\r
+ Ihis library is TPM2 DTPM instance.\r
+ It can be registered to Tpm2 Device router, to be active TPM2 engine,\r
+ based on platform setting.\r
+\r
+Copyright (c) 2013, 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
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/Tpm2DeviceLib.h>\r
+\r
+#include <Guid/TpmInstance.h>\r
+\r
+/**\r
+ This service enables the sending of commands to the TPM2.\r
+\r
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
+\r
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DTpm2SubmitCommand (\r
+ IN UINT32 InputParameterBlockSize,\r
+ IN UINT8 *InputParameterBlock,\r
+ IN OUT UINT32 *OutputParameterBlockSize,\r
+ IN UINT8 *OutputParameterBlock\r
+ );\r
+\r
+/**\r
+ This service requests use TPM2.\r
+\r
+ @retval EFI_SUCCESS Get the control of TPM2 chip.\r
+ @retval EFI_NOT_FOUND TPM2 not found.\r
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DTpm2RequestUseTpm (\r
+ VOID\r
+ );\r
+\r
+TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device = {\r
+ TPM_DEVICE_INTERFACE_TPM20_DTPM,\r
+ DTpm2SubmitCommand,\r
+ DTpm2RequestUseTpm,\r
+};\r
+\r
+/**\r
+ The function register DTPM2.0 instance.\r
+ \r
+ @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tpm2InstanceLibDTpmConstructor (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device);\r
+ if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {\r
+ //\r
+ // Unsupported means platform policy does not need this instance enabled.\r
+ //\r
+ return EFI_SUCCESS;\r
+ }\r
+ return Status;\r
+}\r