2 This library is TPM2 DTPM instance.
3 It can be registered to Tpm2 Device router, to be active TPM2 engine,
4 based on platform setting.
6 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/BaseLib.h>
12 #include <Library/BaseMemoryLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/Tpm2DeviceLib.h>
15 #include <Library/PcdLib.h>
17 #include <Guid/TpmInstance.h>
20 Return PTP interface type.
22 @param[in] Register Pointer to PTP register.
24 @return PTP interface type.
26 TPM2_PTP_INTERFACE_TYPE
32 Return PTP CRB interface IdleByPass state.
34 @param[in] Register Pointer to PTP register.
36 @return PTP CRB interface IdleByPass state.
44 Dump PTP register information.
46 @param[in] Register Pointer to PTP register.
54 This service enables the sending of commands to the TPM2.
56 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
57 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
58 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
59 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
61 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
62 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
63 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
68 IN UINT32 InputParameterBlockSize
,
69 IN UINT8
*InputParameterBlock
,
70 IN OUT UINT32
*OutputParameterBlockSize
,
71 IN UINT8
*OutputParameterBlock
75 This service requests use TPM2.
77 @retval EFI_SUCCESS Get the control of TPM2 chip.
78 @retval EFI_NOT_FOUND TPM2 not found.
79 @retval EFI_DEVICE_ERROR Unexpected device behavior.
87 TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device
= {
88 TPM_DEVICE_INTERFACE_TPM20_DTPM
,
94 The function register DTPM2.0 instance and caches current active TPM interface type.
96 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance
100 Tpm2InstanceLibDTpmConstructor (
105 TPM2_PTP_INTERFACE_TYPE PtpInterface
;
108 Status
= Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device
);
109 if ((Status
== EFI_SUCCESS
) || (Status
== EFI_UNSUPPORTED
)) {
111 // Unsupported means platform policy does not need this instance enabled.
113 if (Status
== EFI_SUCCESS
) {
115 // Cache current active TpmInterfaceType only when needed
117 if (PcdGet8(PcdActiveTpmInterfaceType
) == 0xFF) {
118 PtpInterface
= Tpm2GetPtpInterface ((VOID
*) (UINTN
) PcdGet64 (PcdTpmBaseAddress
));
119 PcdSet8S(PcdActiveTpmInterfaceType
, PtpInterface
);
122 if (PcdGet8(PcdActiveTpmInterfaceType
) == Tpm2PtpInterfaceCrb
&& PcdGet8(PcdCRBIdleByPass
) == 0xFF) {
123 IdleByPass
= Tpm2GetIdleByPass((VOID
*) (UINTN
) PcdGet64 (PcdTpmBaseAddress
));
124 PcdSet8S(PcdCRBIdleByPass
, IdleByPass
);
127 DumpPtpInfo ((VOID
*) (UINTN
) PcdGet64 (PcdTpmBaseAddress
));