2 This library is TPM12 TCG protocol lib.
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseLib.h>
11 #include <Library/BaseMemoryLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/UefiBootServicesTableLib.h>
14 #include <Library/Tpm12DeviceLib.h>
15 #include <Protocol/TcgService.h>
16 #include <IndustryStandard/Tpm12.h>
18 EFI_TCG_PROTOCOL
*mTcgProtocol
= NULL
;
21 This service enables the sending of commands to the TPM12.
23 @param[in] InputParameterBlockSize Size of the TPM12 input parameter block.
24 @param[in] InputParameterBlock Pointer to the TPM12 input parameter block.
25 @param[in,out] OutputParameterBlockSize Size of the TPM12 output parameter block.
26 @param[in] OutputParameterBlock Pointer to the TPM12 output parameter block.
28 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
29 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
30 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
35 IN UINT32 InputParameterBlockSize
,
36 IN UINT8
*InputParameterBlock
,
37 IN OUT UINT32
*OutputParameterBlockSize
,
38 IN UINT8
*OutputParameterBlock
42 TPM_RSP_COMMAND_HDR
*Header
;
44 if (mTcgProtocol
== NULL
) {
45 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**)&mTcgProtocol
);
46 if (EFI_ERROR (Status
)) {
48 // TCG protocol is not installed. So, TPM12 is not present.
50 DEBUG ((DEBUG_ERROR
, "Tpm12SubmitCommand - TCG - %r\n", Status
));
56 // Assume when TCG Protocol is ready, RequestUseTpm already done.
58 Status
= mTcgProtocol
->PassThroughToTpm (
60 InputParameterBlockSize
,
62 *OutputParameterBlockSize
,
65 if (EFI_ERROR (Status
)) {
69 Header
= (TPM_RSP_COMMAND_HDR
*)OutputParameterBlock
;
70 *OutputParameterBlockSize
= SwapBytes32 (Header
->paramSize
);
76 This service requests use TPM12.
78 @retval EFI_SUCCESS Get the control of TPM12 chip.
79 @retval EFI_NOT_FOUND TPM12 not found.
80 @retval EFI_DEVICE_ERROR Unexpected device behavior.
90 if (mTcgProtocol
== NULL
) {
91 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**)&mTcgProtocol
);
92 if (EFI_ERROR (Status
)) {
94 // TCG protocol is not installed. So, TPM12 is not present.
96 DEBUG ((DEBUG_ERROR
, "Tpm12RequestUseTpm - TCG - %r\n", Status
));
102 // Assume when TCG Protocol is ready, RequestUseTpm already done.