]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2DeviceLibDTpm.c
CommitLineData
c1d93242 1/** @file\r
07309c3d 2 This library is TPM2 DTPM device lib.\r
c1d93242
JY
3 Choosing this library means platform uses and only uses DTPM device as TPM2 engine.\r
4\r
f15cb995 5Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>\r
289b714b 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
c1d93242
JY
7\r
8**/\r
9\r
10#include <Library/BaseLib.h>\r
11#include <Library/BaseMemoryLib.h>\r
12#include <Library/DebugLib.h>\r
13#include <Library/Tpm2DeviceLib.h>\r
f15cb995
ZC
14#include <Library/PcdLib.h>\r
15\r
7a56650e 16#include "Tpm2DeviceLibDTpm.h"\r
63197670 17\r
c1d93242
JY
18/**\r
19 This service enables the sending of commands to the TPM2.\r
20\r
21 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
22 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
23 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
24 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
25\r
26 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
27 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
b3548d32 28 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.\r
c1d93242
JY
29**/\r
30EFI_STATUS\r
31EFIAPI\r
32DTpm2SubmitCommand (\r
c411b485
MK
33 IN UINT32 InputParameterBlockSize,\r
34 IN UINT8 *InputParameterBlock,\r
35 IN OUT UINT32 *OutputParameterBlockSize,\r
36 IN UINT8 *OutputParameterBlock\r
c1d93242
JY
37 );\r
38\r
39/**\r
40 This service requests use TPM2.\r
41\r
42 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
43 @retval EFI_NOT_FOUND TPM2 not found.\r
44 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
45**/\r
46EFI_STATUS\r
47EFIAPI\r
48DTpm2RequestUseTpm (\r
49 VOID\r
50 );\r
51\r
52/**\r
53 This service enables the sending of commands to the TPM2.\r
54\r
55 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
56 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
57 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
58 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
59\r
60 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
61 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
b3548d32 62 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.\r
c1d93242
JY
63**/\r
64EFI_STATUS\r
65EFIAPI\r
66Tpm2SubmitCommand (\r
c411b485
MK
67 IN UINT32 InputParameterBlockSize,\r
68 IN UINT8 *InputParameterBlock,\r
69 IN OUT UINT32 *OutputParameterBlockSize,\r
70 IN UINT8 *OutputParameterBlock\r
c1d93242
JY
71 )\r
72{\r
73 return DTpm2SubmitCommand (\r
74 InputParameterBlockSize,\r
75 InputParameterBlock,\r
76 OutputParameterBlockSize,\r
77 OutputParameterBlock\r
78 );\r
79}\r
80\r
81/**\r
82 This service requests use TPM2.\r
83\r
84 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
85 @retval EFI_NOT_FOUND TPM2 not found.\r
86 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
87**/\r
88EFI_STATUS\r
89EFIAPI\r
90Tpm2RequestUseTpm (\r
91 VOID\r
92 )\r
93{\r
94 return DTpm2RequestUseTpm ();\r
95}\r
96\r
97/**\r
98 This service register TPM2 device.\r
99\r
100 @param Tpm2Device TPM2 device\r
101\r
102 @retval EFI_SUCCESS This TPM2 device is registered successfully.\r
103 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.\r
104 @retval EFI_ALREADY_STARTED System already register this TPM2 device.\r
105**/\r
106EFI_STATUS\r
107EFIAPI\r
108Tpm2RegisterTpm2DeviceLib (\r
c411b485 109 IN TPM2_DEVICE_INTERFACE *Tpm2Device\r
c1d93242
JY
110 )\r
111{\r
112 return EFI_UNSUPPORTED;\r
113}\r
f15cb995
ZC
114\r
115/**\r
116 The function caches current active TPM interface type.\r
b3548d32 117\r
d6b926e7 118 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance\r
f15cb995
ZC
119**/\r
120EFI_STATUS\r
121EFIAPI\r
122Tpm2DeviceLibConstructor (\r
123 VOID\r
124 )\r
125{\r
7a56650e 126 return InternalTpm2DeviceLibDTpmCommonConstructor ();\r
f15cb995 127}\r