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