3 Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 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.
18 #include <Ppi/PttPassThruPpi.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/IoLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/PeiServicesLib.h>
24 #include <Library/PcdLib.h>
31 PTT_PASS_THRU_PPI
*SecPttPassThruPpi
= NULL
;
34 The constructor function caches the pointer to PEI services.
36 The constructor function caches the pointer to PEI services.
37 It will always return EFI_SUCCESS.
39 @param FfsHeader Pointer to FFS header the loaded driver.
40 @param PeiServices Pointer to the PEI services.
42 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
47 Tpm2DeviceLibConstructor (
51 EFI_STATUS Status
= EFI_SUCCESS
;
53 Status
= PeiServicesLocatePpi (&gPttPassThruPpiGuid
, 0, NULL
, (VOID
**) &SecPttPassThruPpi
);
54 if (EFI_ERROR (Status
)) {
55 // Locate the PPI failed
56 SecPttPassThruPpi
= NULL
;
62 This service enables the sending of commands to the TPM2.
64 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
65 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
66 @param[in] OutputParameterBlockSize Size of the TPM2 output parameter block.
67 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
69 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
70 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
71 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
76 IN UINT32 InputParameterBlockSize
,
77 IN UINT8
*InputParameterBlock
,
78 IN OUT UINT32
*OutputParameterBlockSize
,
79 IN UINT8
*OutputParameterBlock
82 EFI_STATUS Status
= EFI_SUCCESS
;
84 if(NULL
== InputParameterBlock
|| NULL
== OutputParameterBlock
|| 0 == InputParameterBlockSize
) {
85 DEBUG ((EFI_D_ERROR
, "Buffer == NULL or InputParameterBlockSize == 0\n"));
86 Status
= EFI_INVALID_PARAMETER
;
90 if (NULL
== SecPttPassThruPpi
) {
91 // Don't locate PPI by calling Tpm2DeviceLibConstructor() function??
92 Status
= EFI_DEVICE_ERROR
;
96 Status
= SecPttPassThruPpi
->Tpm2SubmitCommand (
98 InputParameterBlockSize
,
100 OutputParameterBlockSize
,
108 This service requests use TPM2.
110 @retval EFI_SUCCESS Get the control of TPM2 chip.
111 @retval EFI_NOT_FOUND TPM2 not found.
112 @retval EFI_DEVICE_ERROR Unexpected device behavior.
120 EFI_STATUS Status
= EFI_SUCCESS
;
122 if (NULL
== SecPttPassThruPpi
) {
123 // Don't locate PPI by calling Tpm2DeviceLibConstructor() function??
124 Status
= EFI_DEVICE_ERROR
;
128 Status
= SecPttPassThruPpi
->Tpm2RequestUseTpm (SecPttPassThruPpi
);
134 This service register TPM2 device.
136 @Param Tpm2Device TPM2 device
138 @retval EFI_SUCCESS This TPM2 device is registered successfully.
139 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
140 @retval EFI_ALREADY_STARTED System already register this TPM2 device.
144 Tpm2RegisterTpm2DeviceLib (
145 IN PTT_TPM2_DEVICE_INTERFACE
*Tpm2Device
148 return EFI_UNSUPPORTED
;