]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2DeviceLibDTpm.c
1 /** @file
2 This library is TPM2 DTPM device lib.
3 Choosing this library means platform uses and only uses DTPM device as TPM2 engine.
4
5 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <Library/BaseLib.h>
11 #include <Library/BaseMemoryLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/Tpm2DeviceLib.h>
14 #include <Library/PcdLib.h>
15
16 #include "Tpm2DeviceLibDTpm.h"
17
18 /**
19 This service enables the sending of commands to the TPM2.
20
21 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
22 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
23 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
24 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
25
26 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
27 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
28 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
29 **/
30 EFI_STATUS
31 EFIAPI
32 DTpm2SubmitCommand (
33 IN UINT32 InputParameterBlockSize,
34 IN UINT8 *InputParameterBlock,
35 IN OUT UINT32 *OutputParameterBlockSize,
36 IN UINT8 *OutputParameterBlock
37 );
38
39 /**
40 This service requests use TPM2.
41
42 @retval EFI_SUCCESS Get the control of TPM2 chip.
43 @retval EFI_NOT_FOUND TPM2 not found.
44 @retval EFI_DEVICE_ERROR Unexpected device behavior.
45 **/
46 EFI_STATUS
47 EFIAPI
48 DTpm2RequestUseTpm (
49 VOID
50 );
51
52 /**
53 This service enables the sending of commands to the TPM2.
54
55 @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
56 @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
57 @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
58 @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
59
60 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
61 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
62 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
63 **/
64 EFI_STATUS
65 EFIAPI
66 Tpm2SubmitCommand (
67 IN UINT32 InputParameterBlockSize,
68 IN UINT8 *InputParameterBlock,
69 IN OUT UINT32 *OutputParameterBlockSize,
70 IN UINT8 *OutputParameterBlock
71 )
72 {
73 return DTpm2SubmitCommand (
74 InputParameterBlockSize,
75 InputParameterBlock,
76 OutputParameterBlockSize,
77 OutputParameterBlock
78 );
79 }
80
81 /**
82 This service requests use TPM2.
83
84 @retval EFI_SUCCESS Get the control of TPM2 chip.
85 @retval EFI_NOT_FOUND TPM2 not found.
86 @retval EFI_DEVICE_ERROR Unexpected device behavior.
87 **/
88 EFI_STATUS
89 EFIAPI
90 Tpm2RequestUseTpm (
91 VOID
92 )
93 {
94 return DTpm2RequestUseTpm ();
95 }
96
97 /**
98 This service register TPM2 device.
99
100 @param Tpm2Device TPM2 device
101
102 @retval EFI_SUCCESS This TPM2 device is registered successfully.
103 @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
104 @retval EFI_ALREADY_STARTED System already register this TPM2 device.
105 **/
106 EFI_STATUS
107 EFIAPI
108 Tpm2RegisterTpm2DeviceLib (
109 IN TPM2_DEVICE_INTERFACE *Tpm2Device
110 )
111 {
112 return EFI_UNSUPPORTED;
113 }
114
115 /**
116 The function caches current active TPM interface type.
117
118 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance
119 **/
120 EFI_STATUS
121 EFIAPI
122 Tpm2DeviceLibConstructor (
123 VOID
124 )
125 {
126 return InternalTpm2DeviceLibDTpmCommonConstructor ();
127 }