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 ((EFI_D_ERROR
, "Tpm12SubmitCommand - TCG - %r\n", Status
));
55 // Assume when TCG Protocol is ready, RequestUseTpm already done.
57 Status
= mTcgProtocol
->PassThroughToTpm (
59 InputParameterBlockSize
,
61 *OutputParameterBlockSize
,
64 if (EFI_ERROR (Status
)) {
67 Header
= (TPM_RSP_COMMAND_HDR
*)OutputParameterBlock
;
68 *OutputParameterBlockSize
= SwapBytes32 (Header
->paramSize
);
74 This service requests use TPM12.
76 @retval EFI_SUCCESS Get the control of TPM12 chip.
77 @retval EFI_NOT_FOUND TPM12 not found.
78 @retval EFI_DEVICE_ERROR Unexpected device behavior.
88 if (mTcgProtocol
== NULL
) {
89 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**) &mTcgProtocol
);
90 if (EFI_ERROR (Status
)) {
92 // TCG protocol is not installed. So, TPM12 is not present.
94 DEBUG ((EFI_D_ERROR
, "Tpm12RequestUseTpm - TCG - %r\n", Status
));
99 // Assume when TCG Protocol is ready, RequestUseTpm already done.