]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Include/Library/Tpm2DeviceLib.h
SecurityPkg: Cache TPM interface type info
[mirror_edk2.git] / SecurityPkg / Include / Library / Tpm2DeviceLib.h
CommitLineData
c1d93242
JY
1/** @file\r
2 This library abstract how to access TPM2 hardware device.\r
3\r
f15cb995 4Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>\r
c1d93242
JY
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _TPM2_DEVICE_LIB_H_\r
16#define _TPM2_DEVICE_LIB_H_\r
17\r
18#include <Uefi.h>\r
19\r
f15cb995
ZC
20//\r
21// Used in PcdActiveTpmInterfaceType to identify TPM interface type\r
22//\r
23typedef enum {\r
24 Tpm2PtpInterfaceTis,\r
25 Tpm2PtpInterfaceFifo,\r
26 Tpm2PtpInterfaceCrb,\r
27 Tpm2PtpInterfaceMax,\r
28} TPM2_PTP_INTERFACE_TYPE;\r
29\r
c1d93242
JY
30/**\r
31 This service enables the sending of commands to the TPM2.\r
32\r
33 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
34 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
35 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
36 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
37\r
38 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
39 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
40 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. \r
41**/\r
42EFI_STATUS\r
43EFIAPI\r
44Tpm2SubmitCommand (\r
45 IN UINT32 InputParameterBlockSize,\r
46 IN UINT8 *InputParameterBlock,\r
47 IN OUT UINT32 *OutputParameterBlockSize,\r
48 IN UINT8 *OutputParameterBlock\r
49 );\r
50\r
51/**\r
52 This service requests use TPM2.\r
53\r
54 @retval EFI_SUCCESS Get the control of TPM2 chip.\r
55 @retval EFI_NOT_FOUND TPM2 not found.\r
56 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
57**/\r
58EFI_STATUS\r
59EFIAPI\r
60Tpm2RequestUseTpm (\r
61 VOID\r
62 );\r
63\r
64/**\r
65 This service enables the sending of commands to the TPM2.\r
66\r
67 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r
68 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r
69 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r
70 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r
71\r
72 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r
73 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r
74 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. \r
75**/\r
76typedef\r
77EFI_STATUS\r
78(EFIAPI *TPM2_SUBMIT_COMMAND) (\r
79 IN UINT32 InputParameterBlockSize,\r
80 IN UINT8 *InputParameterBlock,\r
81 IN OUT UINT32 *OutputParameterBlockSize,\r
82 IN UINT8 *OutputParameterBlock\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
92typedef\r
93EFI_STATUS\r
94(EFIAPI *TPM2_REQUEST_USE_TPM) (\r
95 VOID\r
96 );\r
97\r
98typedef struct {\r
99 EFI_GUID ProviderGuid;\r
100 TPM2_SUBMIT_COMMAND Tpm2SubmitCommand;\r
101 TPM2_REQUEST_USE_TPM Tpm2RequestUseTpm;\r
102} TPM2_DEVICE_INTERFACE;\r
103\r
104/**\r
105 This service register TPM2 device.\r
106\r
107 @param Tpm2Device TPM2 device\r
108\r
109 @retval EFI_SUCCESS This TPM2 device is registered successfully.\r
110 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.\r
111 @retval EFI_ALREADY_STARTED System already register this TPM2 device.\r
112**/\r
113EFI_STATUS\r
114EFIAPI\r
115Tpm2RegisterTpm2DeviceLib (\r
116 IN TPM2_DEVICE_INTERFACE *Tpm2Device\r
117 );\r
118\r
119#endif\r