2 This library is TPM2 DTPM device lib.
3 Choosing this library means platform uses and only uses DTPM device as TPM2 engine.
5 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/BaseLib.h>
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/Tpm2DeviceLib.h>
20 #include <Library/PcdLib.h>
23 Return PTP interface type.
25 @param[in] Register Pointer to PTP register.
27 @return PTP interface type.
29 TPM2_PTP_INTERFACE_TYPE
35 This service enables the sending of commands to the TPM2.
37 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
38 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
39 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
40 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
42 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
43 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
44 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
49 IN UINT32 InputParameterBlockSize
,
50 IN UINT8
*InputParameterBlock
,
51 IN OUT UINT32
*OutputParameterBlockSize
,
52 IN UINT8
*OutputParameterBlock
56 This service requests use TPM2.
58 @retval EFI_SUCCESS Get the control of TPM2 chip.
59 @retval EFI_NOT_FOUND TPM2 not found.
60 @retval EFI_DEVICE_ERROR Unexpected device behavior.
69 This service enables the sending of commands to the TPM2.
71 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
72 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
73 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
74 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
76 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
77 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
78 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
83 IN UINT32 InputParameterBlockSize
,
84 IN UINT8
*InputParameterBlock
,
85 IN OUT UINT32
*OutputParameterBlockSize
,
86 IN UINT8
*OutputParameterBlock
89 return DTpm2SubmitCommand (
90 InputParameterBlockSize
,
92 OutputParameterBlockSize
,
98 This service requests use TPM2.
100 @retval EFI_SUCCESS Get the control of TPM2 chip.
101 @retval EFI_NOT_FOUND TPM2 not found.
102 @retval EFI_DEVICE_ERROR Unexpected device behavior.
110 return DTpm2RequestUseTpm ();
114 This service register TPM2 device.
116 @param Tpm2Device TPM2 device
118 @retval EFI_SUCCESS This TPM2 device is registered successfully.
119 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
120 @retval EFI_ALREADY_STARTED System already register this TPM2 device.
124 Tpm2RegisterTpm2DeviceLib (
125 IN TPM2_DEVICE_INTERFACE
*Tpm2Device
128 return EFI_UNSUPPORTED
;
132 The function caches current active TPM interface type.
134 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance
138 Tpm2DeviceLibConstructor (
142 TPM2_PTP_INTERFACE_TYPE PtpInterface
;
145 // Cache current active TpmInterfaceType only when needed
147 if (PcdGet8(PcdActiveTpmInterfaceType
) == 0xFF) {
148 PtpInterface
= Tpm2GetPtpInterface ((VOID
*) (UINTN
) PcdGet64 (PcdTpmBaseAddress
));
149 PcdSet8S(PcdActiveTpmInterfaceType
, PtpInterface
);