+++ /dev/null
-/*++\r
-\r
-Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved\r
- \r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
- \r
-\r
---*/\r
-\r
-#include <Uefi.h>\r
-#include <PiPei.h>\r
-#include <Ppi/PttPassThruPpi.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-\r
-\r
-\r
-\r
-\r
-PTT_PASS_THRU_PPI *SecPttPassThruPpi = NULL;\r
-\r
-/**\r
- The constructor function caches the pointer to PEI services.\r
-\r
- The constructor function caches the pointer to PEI services.\r
- It will always return EFI_SUCCESS.\r
-\r
- @param FfsHeader Pointer to FFS header the loaded driver.\r
- @param PeiServices Pointer to the PEI services.\r
-\r
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Tpm2DeviceLibConstructor (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
- \r
- Status = PeiServicesLocatePpi (&gPttPassThruPpiGuid, 0, NULL, (VOID **) &SecPttPassThruPpi);\r
- if (EFI_ERROR (Status)) {\r
- // Locate the PPI failed\r
- SecPttPassThruPpi = NULL;\r
- }\r
- return Status;\r
-}\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] 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
-Tpm2SubmitCommand (\r
- IN UINT32 InputParameterBlockSize,\r
- IN UINT8 *InputParameterBlock,\r
- IN OUT UINT32 *OutputParameterBlockSize,\r
- IN UINT8 *OutputParameterBlock\r
- )\r
-{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
-\r
- if(NULL == InputParameterBlock || NULL == OutputParameterBlock || 0 == InputParameterBlockSize) {\r
- DEBUG ((EFI_D_ERROR, "Buffer == NULL or InputParameterBlockSize == 0\n"));\r
- Status = EFI_INVALID_PARAMETER;\r
- return Status;\r
- }\r
-\r
- if (NULL == SecPttPassThruPpi) {\r
- // Don't locate PPI by calling Tpm2DeviceLibConstructor() function??\r
- Status = EFI_DEVICE_ERROR;\r
- return Status;\r
- }\r
-\r
- Status = SecPttPassThruPpi->Tpm2SubmitCommand (\r
- SecPttPassThruPpi, \r
- InputParameterBlockSize, \r
- InputParameterBlock, \r
- OutputParameterBlockSize, \r
- OutputParameterBlock\r
- );\r
- \r
- return Status;\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
-Tpm2RequestUseTpm (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
-\r
- if (NULL == SecPttPassThruPpi) {\r
- // Don't locate PPI by calling Tpm2DeviceLibConstructor() function??\r
- Status = EFI_DEVICE_ERROR;\r
- return Status;\r
- }\r
-\r
- Status = SecPttPassThruPpi->Tpm2RequestUseTpm (SecPttPassThruPpi);\r
- \r
- return Status;\r
-}\r
-\r
-/**\r
- This service register TPM2 device.\r
-\r
- @Param Tpm2Device TPM2 device\r
-\r
- @retval EFI_SUCCESS This TPM2 device is registered successfully.\r
- @retval EFI_UNSUPPORTED System does not support register this TPM2 device.\r
- @retval EFI_ALREADY_STARTED System already register this TPM2 device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Tpm2RegisterTpm2DeviceLib (\r
- IN PTT_TPM2_DEVICE_INTERFACE *Tpm2Device\r
- )\r
-{\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r