Tpm2DeviceLib.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /** @file
  2. This library abstract how to access TPM2 hardware device.
  3. Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _TPM2_DEVICE_LIB_H_
  7. #define _TPM2_DEVICE_LIB_H_
  8. #include <Uefi.h>
  9. //
  10. // Used in PcdActiveTpmInterfaceType to identify TPM interface type
  11. //
  12. typedef enum {
  13. Tpm2PtpInterfaceTis,
  14. Tpm2PtpInterfaceFifo,
  15. Tpm2PtpInterfaceCrb,
  16. Tpm2PtpInterfaceMax,
  17. } TPM2_PTP_INTERFACE_TYPE;
  18. /**
  19. This service enables the sending of commands to the TPM2.
  20. @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
  21. @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
  22. @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
  23. @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
  24. @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
  25. @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
  26. @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
  27. **/
  28. EFI_STATUS
  29. EFIAPI
  30. Tpm2SubmitCommand (
  31. IN UINT32 InputParameterBlockSize,
  32. IN UINT8 *InputParameterBlock,
  33. IN OUT UINT32 *OutputParameterBlockSize,
  34. IN UINT8 *OutputParameterBlock
  35. );
  36. /**
  37. This service requests use TPM2.
  38. @retval EFI_SUCCESS Get the control of TPM2 chip.
  39. @retval EFI_NOT_FOUND TPM2 not found.
  40. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  41. **/
  42. EFI_STATUS
  43. EFIAPI
  44. Tpm2RequestUseTpm (
  45. VOID
  46. );
  47. /**
  48. This service enables the sending of commands to the TPM2.
  49. @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
  50. @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
  51. @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
  52. @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
  53. @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
  54. @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
  55. @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
  56. **/
  57. typedef
  58. EFI_STATUS
  59. (EFIAPI *TPM2_SUBMIT_COMMAND) (
  60. IN UINT32 InputParameterBlockSize,
  61. IN UINT8 *InputParameterBlock,
  62. IN OUT UINT32 *OutputParameterBlockSize,
  63. IN UINT8 *OutputParameterBlock
  64. );
  65. /**
  66. This service requests use TPM2.
  67. @retval EFI_SUCCESS Get the control of TPM2 chip.
  68. @retval EFI_NOT_FOUND TPM2 not found.
  69. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  70. **/
  71. typedef
  72. EFI_STATUS
  73. (EFIAPI *TPM2_REQUEST_USE_TPM) (
  74. VOID
  75. );
  76. typedef struct {
  77. EFI_GUID ProviderGuid;
  78. TPM2_SUBMIT_COMMAND Tpm2SubmitCommand;
  79. TPM2_REQUEST_USE_TPM Tpm2RequestUseTpm;
  80. } TPM2_DEVICE_INTERFACE;
  81. /**
  82. This service register TPM2 device.
  83. @param Tpm2Device TPM2 device
  84. @retval EFI_SUCCESS This TPM2 device is registered successfully.
  85. @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
  86. @retval EFI_ALREADY_STARTED System already register this TPM2 device.
  87. **/
  88. EFI_STATUS
  89. EFIAPI
  90. Tpm2RegisterTpm2DeviceLib (
  91. IN TPM2_DEVICE_INTERFACE *Tpm2Device
  92. );
  93. #endif