]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
SecurityPkg: Apply uncrustify changes
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2InstanceLibDTpm.c
... / ...
CommitLineData
1/** @file\r
2 This 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
6Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>\r
7SPDX-License-Identifier: BSD-2-Clause-Patent\r
8\r
9**/\r
10\r
11#include <Library/BaseLib.h>\r
12#include <Library/BaseMemoryLib.h>\r
13#include <Library/DebugLib.h>\r
14#include <Library/Tpm2DeviceLib.h>\r
15#include <Library/PcdLib.h>\r
16\r
17#include <Guid/TpmInstance.h>\r
18\r
19#include "Tpm2DeviceLibDTpm.h"\r
20\r
21/**\r
22 Dump PTP register information.\r
23\r
24 @param[in] Register Pointer to PTP register.\r
25**/\r
26VOID\r
27DumpPtpInfo (\r
28 IN VOID *Register\r
29 );\r
30\r
31/**\r
32 This service enables the sending of commands to the TPM2.\r
33\r
34 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
35 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
36 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
37 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
38\r
39 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
40 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
41 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.\r
42**/\r
43EFI_STATUS\r
44EFIAPI\r
45DTpm2SubmitCommand (\r
46 IN UINT32 InputParameterBlockSize,\r
47 IN UINT8 *InputParameterBlock,\r
48 IN OUT UINT32 *OutputParameterBlockSize,\r
49 IN UINT8 *OutputParameterBlock\r
50 );\r
51\r
52/**\r
53 This service requests use TPM2.\r
54\r
55 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
56 @retval EFI_NOT_FOUND TPM2 not found.\r
57 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
58**/\r
59EFI_STATUS\r
60EFIAPI\r
61DTpm2RequestUseTpm (\r
62 VOID\r
63 );\r
64\r
65TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device = {\r
66 TPM_DEVICE_INTERFACE_TPM20_DTPM,\r
67 DTpm2SubmitCommand,\r
68 DTpm2RequestUseTpm,\r
69};\r
70\r
71/**\r
72 The function register DTPM2.0 instance and caches current active TPM interface type.\r
73\r
74 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance\r
75**/\r
76EFI_STATUS\r
77EFIAPI\r
78Tpm2InstanceLibDTpmConstructor (\r
79 VOID\r
80 )\r
81{\r
82 EFI_STATUS Status;\r
83\r
84 Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device);\r
85 if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {\r
86 //\r
87 // Unsupported means platform policy does not need this instance enabled.\r
88 //\r
89 if (Status == EFI_SUCCESS) {\r
90 Status = InternalTpm2DeviceLibDTpmCommonConstructor ();\r
91 DumpPtpInfo ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));\r
92 }\r
93\r
94 return EFI_SUCCESS;\r
95 }\r
96\r
97 return Status;\r
98}\r