]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
SecurityPkg: Add TPM PTP support in TPM2 device lib.
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2InstanceLibDTpm.c
CommitLineData
c1d93242
JY
1/** @file\r
2 Ihis library is TPM2 DTPM instance.\r
3 It can be registered to Tpm2 Device router, to be active TPM2 engine,\r
4 based on platform setting.\r
5\r
79e748cf 6Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. <BR>\r
c1d93242
JY
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <Library/BaseLib.h>\r
18#include <Library/BaseMemoryLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/Tpm2DeviceLib.h>\r
21\r
22#include <Guid/TpmInstance.h>\r
23\r
79e748cf
JY
24/**\r
25 Dump PTP register information.\r
26\r
27 @param[in] Register Pointer to PTP register.\r
28**/\r
29VOID\r
30DumpPtpInfo (\r
31 IN VOID *Register\r
32 );\r
33\r
c1d93242
JY
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
68TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device = {\r
69 TPM_DEVICE_INTERFACE_TPM20_DTPM,\r
70 DTpm2SubmitCommand,\r
71 DTpm2RequestUseTpm,\r
72};\r
73\r
74/**\r
75 The function register DTPM2.0 instance.\r
76 \r
77 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance\r
78**/\r
79EFI_STATUS\r
80EFIAPI\r
81Tpm2InstanceLibDTpmConstructor (\r
82 VOID\r
83 )\r
84{\r
85 EFI_STATUS Status;\r
86\r
87 Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device);\r
88 if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {\r
89 //\r
90 // Unsupported means platform policy does not need this instance enabled.\r
91 //\r
79e748cf
JY
92 if (Status == EFI_SUCCESS) {\r
93 DumpPtpInfo ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r
94 }\r
c1d93242
JY
95 return EFI_SUCCESS;\r
96 }\r
97 return Status;\r
98}\r