]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Include/Library/Tpm2DeviceLib.h
24fdb5b514a121c78b0e5d969ec8778b00d2245b
[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 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _TPM2_DEVICE_LIB_H_
10 #define _TPM2_DEVICE_LIB_H_
11
12 #include <Uefi.h>
13
14 //
15 // Used in PcdActiveTpmInterfaceType to identify TPM interface type
16 //
17 typedef enum {
18 Tpm2PtpInterfaceTis,
19 Tpm2PtpInterfaceFifo,
20 Tpm2PtpInterfaceCrb,
21 Tpm2PtpInterfaceMax,
22 } TPM2_PTP_INTERFACE_TYPE;
23
24 /**
25 This service enables the sending of commands to the TPM2.
26
27 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
28 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
29 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
30 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
31
32 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
33 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
34 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
35 **/
36 EFI_STATUS
37 EFIAPI
38 Tpm2SubmitCommand (
39 IN UINT32 InputParameterBlockSize,
40 IN UINT8 *InputParameterBlock,
41 IN OUT UINT32 *OutputParameterBlockSize,
42 IN UINT8 *OutputParameterBlock
43 );
44
45 /**
46 This service requests use TPM2.
47
48 @retval EFI_SUCCESS Get the control of TPM2 chip.
49 @retval EFI_NOT_FOUND TPM2 not found.
50 @retval EFI_DEVICE_ERROR Unexpected device behavior.
51 **/
52 EFI_STATUS
53 EFIAPI
54 Tpm2RequestUseTpm (
55 VOID
56 );
57
58 /**
59 This service enables the sending of commands to the TPM2.
60
61 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
62 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
63 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
64 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
65
66 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
67 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
68 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
69 **/
70 typedef
71 EFI_STATUS
72 (EFIAPI *TPM2_SUBMIT_COMMAND) (
73 IN UINT32 InputParameterBlockSize,
74 IN UINT8 *InputParameterBlock,
75 IN OUT UINT32 *OutputParameterBlockSize,
76 IN UINT8 *OutputParameterBlock
77 );
78
79 /**
80 This service requests use TPM2.
81
82 @retval EFI_SUCCESS Get the control of TPM2 chip.
83 @retval EFI_NOT_FOUND TPM2 not found.
84 @retval EFI_DEVICE_ERROR Unexpected device behavior.
85 **/
86 typedef
87 EFI_STATUS
88 (EFIAPI *TPM2_REQUEST_USE_TPM) (
89 VOID
90 );
91
92 typedef struct {
93 EFI_GUID ProviderGuid;
94 TPM2_SUBMIT_COMMAND Tpm2SubmitCommand;
95 TPM2_REQUEST_USE_TPM Tpm2RequestUseTpm;
96 } TPM2_DEVICE_INTERFACE;
97
98 /**
99 This service register TPM2 device.
100
101 @param Tpm2Device TPM2 device
102
103 @retval EFI_SUCCESS This TPM2 device is registered successfully.
104 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
105 @retval EFI_ALREADY_STARTED System already register this TPM2 device.
106 **/
107 EFI_STATUS
108 EFIAPI
109 Tpm2RegisterTpm2DeviceLib (
110 IN TPM2_DEVICE_INTERFACE *Tpm2Device
111 );
112
113 #endif