Tpm2DeviceLibSeC.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*++
  2. Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. --*/
  5. #include <Uefi.h>
  6. #include <Protocol/PttPassThru.h>
  7. #include <Library/PcdLib.h>
  8. #include <Library/UefiBootServicesTableLib.h>
  9. //#include <Library/Tpm2DeviceLib.h>
  10. PTT_PASS_THRU_PROTOCOL *mPttPassThruProtocol;
  11. /**
  12. The constructor function caches the pointer to PEI services.
  13. The constructor function caches the pointer to PEI services.
  14. It will always return EFI_SUCCESS.
  15. @param FfsHeader Pointer to FFS header the loaded driver.
  16. @param PeiServices Pointer to the PEI services.
  17. @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
  18. **/
  19. EFI_STATUS
  20. EFIAPI
  21. Tpm2DeviceLibConstructor (
  22. VOID
  23. )
  24. {
  25. EFI_STATUS Status = EFI_SUCCESS;
  26. Status = gBS->LocateProtocol (&gPttPassThruProtocolGuid, NULL, (VOID **) &mPttPassThruProtocol);
  27. return Status;
  28. }
  29. /**
  30. This service enables the sending of commands to the TPM2.
  31. @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
  32. @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
  33. @param[in] OutputParameterBlockSize Size of the TPM2 output parameter block.
  34. @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
  35. @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
  36. @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
  37. @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
  38. **/
  39. EFI_STATUS
  40. EFIAPI
  41. Tpm2SubmitCommand (
  42. IN UINT32 InputParameterBlockSize,
  43. IN UINT8 *InputParameterBlock,
  44. IN OUT UINT32 *OutputParameterBlockSize,
  45. IN UINT8 *OutputParameterBlock
  46. )
  47. {
  48. EFI_STATUS Status;
  49. Status = mPttPassThruProtocol->Tpm2SubmitCommand (
  50. mPttPassThruProtocol,
  51. InputParameterBlockSize,
  52. InputParameterBlock,
  53. OutputParameterBlockSize,
  54. OutputParameterBlock
  55. );
  56. return Status;
  57. }
  58. /**
  59. This service requests use TPM2.
  60. @retval EFI_SUCCESS Get the control of TPM2 chip.
  61. @retval EFI_NOT_FOUND TPM2 not found.
  62. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  63. **/
  64. EFI_STATUS
  65. EFIAPI
  66. Tpm2RequestUseTpm (
  67. VOID
  68. )
  69. {
  70. EFI_STATUS Status;
  71. Status = mPttPassThruProtocol->Tpm2RequestUseTpm (mPttPassThruProtocol);
  72. return Status;
  73. }
  74. /**
  75. This service register TPM2 device.
  76. @Param Tpm2Device TPM2 device
  77. @retval EFI_SUCCESS This TPM2 device is registered successfully.
  78. @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
  79. @retval EFI_ALREADY_STARTED System already register this TPM2 device.
  80. **/
  81. EFI_STATUS
  82. EFIAPI
  83. Tpm2RegisterTpm2DeviceLib (
  84. IN PTT_TPM2_DEVICE_INTERFACE *Tpm2Device
  85. )
  86. {
  87. return EFI_UNSUPPORTED;
  88. }