]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
MdePkg: TpmPtp: Add CapCRBIdleBypass definition
[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
c1d93242
JY
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <Library/BaseLib.h>\r
17#include <Library/BaseMemoryLib.h>\r
18#include <Library/DebugLib.h>\r
19#include <Library/Tpm2DeviceLib.h>\r
f15cb995
ZC
20#include <Library/PcdLib.h>\r
21\r
22/**\r
23 Return PTP interface type.\r
24\r
25 @param[in] Register Pointer to PTP register.\r
26\r
27 @return PTP interface type.\r
28**/\r
29TPM2_PTP_INTERFACE_TYPE\r
30Tpm2GetPtpInterface (\r
31 IN VOID *Register\r
32 );\r
c1d93242
JY
33\r
34/**\r
35 This service enables the sending of commands to the TPM2.\r
36\r
37 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
38 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
39 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
40 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
41\r
42 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
43 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
44 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. \r
45**/\r
46EFI_STATUS\r
47EFIAPI\r
48DTpm2SubmitCommand (\r
49 IN UINT32 InputParameterBlockSize,\r
50 IN UINT8 *InputParameterBlock,\r
51 IN OUT UINT32 *OutputParameterBlockSize,\r
52 IN UINT8 *OutputParameterBlock\r
53 );\r
54\r
55/**\r
56 This service requests use TPM2.\r
57\r
58 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
59 @retval EFI_NOT_FOUND TPM2 not found.\r
60 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
61**/\r
62EFI_STATUS\r
63EFIAPI\r
64DTpm2RequestUseTpm (\r
65 VOID\r
66 );\r
67\r
68/**\r
69 This service enables the sending of commands to the TPM2.\r
70\r
71 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
72 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
73 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
74 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
75\r
76 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
77 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
78 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. \r
79**/\r
80EFI_STATUS\r
81EFIAPI\r
82Tpm2SubmitCommand (\r
83 IN UINT32 InputParameterBlockSize,\r
84 IN UINT8 *InputParameterBlock,\r
85 IN OUT UINT32 *OutputParameterBlockSize,\r
86 IN UINT8 *OutputParameterBlock\r
87 )\r
88{\r
89 return DTpm2SubmitCommand (\r
90 InputParameterBlockSize,\r
91 InputParameterBlock,\r
92 OutputParameterBlockSize,\r
93 OutputParameterBlock\r
94 );\r
95}\r
96\r
97/**\r
98 This service requests use TPM2.\r
99\r
100 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
101 @retval EFI_NOT_FOUND TPM2 not found.\r
102 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
103**/\r
104EFI_STATUS\r
105EFIAPI\r
106Tpm2RequestUseTpm (\r
107 VOID\r
108 )\r
109{\r
110 return DTpm2RequestUseTpm ();\r
111}\r
112\r
113/**\r
114 This service register TPM2 device.\r
115\r
116 @param Tpm2Device TPM2 device\r
117\r
118 @retval EFI_SUCCESS This TPM2 device is registered successfully.\r
119 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.\r
120 @retval EFI_ALREADY_STARTED System already register this TPM2 device.\r
121**/\r
122EFI_STATUS\r
123EFIAPI\r
124Tpm2RegisterTpm2DeviceLib (\r
125 IN TPM2_DEVICE_INTERFACE *Tpm2Device\r
126 )\r
127{\r
128 return EFI_UNSUPPORTED;\r
129}\r
f15cb995
ZC
130\r
131/**\r
132 The function caches current active TPM interface type.\r
133 \r
134 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance\r
135**/\r
136EFI_STATUS\r
137EFIAPI\r
138Tpm2DeviceLibConstructor (\r
139 VOID\r
140 )\r
141{\r
142 TPM2_PTP_INTERFACE_TYPE PtpInterface;\r
143\r
144 //\r
145 // Cache current active TpmInterfaceType only when needed\r
146 //\r
147 if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) {\r
148 PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r
149 PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface);\r
150 }\r
151 return EFI_SUCCESS;\r
152}\r