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