]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/Library/Tpm2DeviceLibSeCDxe/Tpm2DeviceLibSeC.c
ArmPlatformPkg: PL061 - rewrite the hardware interaction
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / Tpm2DeviceLibSeCDxe / Tpm2DeviceLibSeC.c
CommitLineData
f4e7aa05
TH
1/*++\r
2\r
3Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved\r
4 \r
5 This program and the accompanying materials are licensed and made available under\r
6 the terms and conditions of the BSD License that accompanies this distribution. \r
7 The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php. \r
9 \r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12 \r
13--*/\r
14\r
15#include <Uefi.h>\r
16#include <Protocol/PttPassThru.h>\r
17#include <Library/PcdLib.h>\r
18#include <Library/UefiBootServicesTableLib.h>\r
19//#include <Library/Tpm2DeviceLib.h>\r
20\r
21\r
22PTT_PASS_THRU_PROTOCOL *mPttPassThruProtocol;\r
23\r
24\r
25/**\r
26 The constructor function caches the pointer to PEI services.\r
27\r
28 The constructor function caches the pointer to PEI services.\r
29 It will always return EFI_SUCCESS.\r
30\r
31 @param FfsHeader Pointer to FFS header the loaded driver.\r
32 @param PeiServices Pointer to the PEI services.\r
33\r
34 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
35\r
36**/\r
37\r
38EFI_STATUS\r
39EFIAPI\r
40Tpm2DeviceLibConstructor (\r
41 VOID\r
42 )\r
43{\r
44 EFI_STATUS Status = EFI_SUCCESS;\r
45 \r
46 Status = gBS->LocateProtocol (&gPttPassThruProtocolGuid, NULL, (VOID **) &mPttPassThruProtocol);\r
47 \r
48 return Status;\r
49}\r
50\r
51/**\r
52 This service enables the sending of commands to the TPM2.\r
53\r
54 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
55 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
56 @param[in] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
57 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
58\r
59 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
60 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
61 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.\r
62**/\r
63EFI_STATUS\r
64EFIAPI\r
65Tpm2SubmitCommand (\r
66 IN UINT32 InputParameterBlockSize,\r
67 IN UINT8 *InputParameterBlock,\r
68 IN OUT UINT32 *OutputParameterBlockSize,\r
69 IN UINT8 *OutputParameterBlock\r
70 )\r
71{\r
72 EFI_STATUS Status;\r
73 \r
74 Status = mPttPassThruProtocol->Tpm2SubmitCommand (\r
75 mPttPassThruProtocol,\r
76 InputParameterBlockSize,\r
77 InputParameterBlock,\r
78 OutputParameterBlockSize,\r
79 OutputParameterBlock\r
80 );\r
81\r
82 return Status;\r
83}\r
84\r
85/**\r
86 This service requests use TPM2.\r
87\r
88 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
89 @retval EFI_NOT_FOUND TPM2 not found.\r
90 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
91**/\r
92EFI_STATUS\r
93EFIAPI\r
94Tpm2RequestUseTpm (\r
95 VOID\r
96 )\r
97{\r
98 EFI_STATUS Status;\r
99 \r
100 Status = mPttPassThruProtocol->Tpm2RequestUseTpm (mPttPassThruProtocol);\r
101 \r
102 return Status;\r
103}\r
104\r
105/**\r
106 This service register TPM2 device.\r
107\r
108 @Param Tpm2Device TPM2 device\r
109\r
110 @retval EFI_SUCCESS This TPM2 device is registered successfully.\r
111 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.\r
112 @retval EFI_ALREADY_STARTED System already register this TPM2 device.\r
113**/\r
114EFI_STATUS\r
115EFIAPI\r
116Tpm2RegisterTpm2DeviceLib (\r
117 IN PTT_TPM2_DEVICE_INTERFACE *Tpm2Device\r
118 )\r
119{\r
120 return EFI_UNSUPPORTED;\r
121}\r
122\r
123\r