]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/Tpm2DeviceLibSeCDxe/Tpm2DeviceLibSeC.c
Sync the branch changes to trunk.
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / Tpm2DeviceLibSeCDxe / Tpm2DeviceLibSeC.c
1 /*++
2
3 Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved
4
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.
9
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.
12
13 --*/
14
15 #include <Uefi.h>
16 #include <Protocol/PttPassThru.h>
17 #include <Library/PcdLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
19 //#include <Library/Tpm2DeviceLib.h>
20
21
22 PTT_PASS_THRU_PROTOCOL *mPttPassThruProtocol;
23
24
25 /**
26 The constructor function caches the pointer to PEI services.
27
28 The constructor function caches the pointer to PEI services.
29 It will always return EFI_SUCCESS.
30
31 @param FfsHeader Pointer to FFS header the loaded driver.
32 @param PeiServices Pointer to the PEI services.
33
34 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
35
36 **/
37
38 EFI_STATUS
39 EFIAPI
40 Tpm2DeviceLibConstructor (
41 VOID
42 )
43 {
44 EFI_STATUS Status = EFI_SUCCESS;
45
46 Status = gBS->LocateProtocol (&gPttPassThruProtocolGuid, NULL, (VOID **) &mPttPassThruProtocol);
47
48 return Status;
49 }
50
51 /**
52 This service enables the sending of commands to the TPM2.
53
54 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
55 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
56 @param[in] OutputParameterBlockSize Size of the TPM2 output parameter block.
57 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
58
59 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
60 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
61 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
62 **/
63 EFI_STATUS
64 EFIAPI
65 Tpm2SubmitCommand (
66 IN UINT32 InputParameterBlockSize,
67 IN UINT8 *InputParameterBlock,
68 IN OUT UINT32 *OutputParameterBlockSize,
69 IN UINT8 *OutputParameterBlock
70 )
71 {
72 EFI_STATUS Status;
73
74 Status = mPttPassThruProtocol->Tpm2SubmitCommand (
75 mPttPassThruProtocol,
76 InputParameterBlockSize,
77 InputParameterBlock,
78 OutputParameterBlockSize,
79 OutputParameterBlock
80 );
81
82 return Status;
83 }
84
85 /**
86 This service requests use TPM2.
87
88 @retval EFI_SUCCESS Get the control of TPM2 chip.
89 @retval EFI_NOT_FOUND TPM2 not found.
90 @retval EFI_DEVICE_ERROR Unexpected device behavior.
91 **/
92 EFI_STATUS
93 EFIAPI
94 Tpm2RequestUseTpm (
95 VOID
96 )
97 {
98 EFI_STATUS Status;
99
100 Status = mPttPassThruProtocol->Tpm2RequestUseTpm (mPttPassThruProtocol);
101
102 return Status;
103 }
104
105 /**
106 This service register TPM2 device.
107
108 @Param Tpm2Device TPM2 device
109
110 @retval EFI_SUCCESS This TPM2 device is registered successfully.
111 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
112 @retval EFI_ALREADY_STARTED System already register this TPM2 device.
113 **/
114 EFI_STATUS
115 EFIAPI
116 Tpm2RegisterTpm2DeviceLib (
117 IN PTT_TPM2_DEVICE_INTERFACE *Tpm2Device
118 )
119 {
120 return EFI_UNSUPPORTED;
121 }
122
123