2 This library is TPM12 TCG protocol lib.
4 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 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/UefiBootServicesTableLib.h>
20 #include <Library/Tpm12DeviceLib.h>
21 #include <Protocol/TcgService.h>
22 #include <IndustryStandard/Tpm12.h>
24 EFI_TCG_PROTOCOL
*mTcgProtocol
= NULL
;
27 This service enables the sending of commands to the TPM12.
29 @param[in] InputParameterBlockSize Size of the TPM12 input parameter block.
30 @param[in] InputParameterBlock Pointer to the TPM12 input parameter block.
31 @param[in,out] OutputParameterBlockSize Size of the TPM12 output parameter block.
32 @param[in] OutputParameterBlock Pointer to the TPM12 output parameter block.
34 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
35 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
36 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
41 IN UINT32 InputParameterBlockSize
,
42 IN UINT8
*InputParameterBlock
,
43 IN OUT UINT32
*OutputParameterBlockSize
,
44 IN UINT8
*OutputParameterBlock
48 TPM_RSP_COMMAND_HDR
*Header
;
50 if (mTcgProtocol
== NULL
) {
51 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**) &mTcgProtocol
);
52 if (EFI_ERROR (Status
)) {
54 // TCG protocol is not installed. So, TPM12 is not present.
56 DEBUG ((EFI_D_ERROR
, "Tpm12SubmitCommand - TCG - %r\n", Status
));
61 // Assume when TCG Protocol is ready, RequestUseTpm already done.
63 Status
= mTcgProtocol
->PassThroughToTpm (
65 InputParameterBlockSize
,
67 *OutputParameterBlockSize
,
70 if (EFI_ERROR (Status
)) {
73 Header
= (TPM_RSP_COMMAND_HDR
*)OutputParameterBlock
;
74 *OutputParameterBlockSize
= SwapBytes32 (Header
->paramSize
);
80 This service requests use TPM12.
82 @retval EFI_SUCCESS Get the control of TPM12 chip.
83 @retval EFI_NOT_FOUND TPM12 not found.
84 @retval EFI_DEVICE_ERROR Unexpected device behavior.
94 if (mTcgProtocol
== NULL
) {
95 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**) &mTcgProtocol
);
96 if (EFI_ERROR (Status
)) {
98 // TCG protocol is not installed. So, TPM12 is not present.
100 DEBUG ((EFI_D_ERROR
, "Tpm12RequestUseTpm - TCG - %r\n", Status
));
101 return EFI_NOT_FOUND
;
105 // Assume when TCG Protocol is ready, RequestUseTpm already done.