TianoCore EDK2 master
Loading...
Searching...
No Matches
Tpm2DeviceLibTcg2.c
Go to the documentation of this file.
1
9#include <Library/BaseLib.h>
11#include <Library/DebugLib.h>
16
17STATIC EFI_TCG2_PROTOCOL *mTcg2Protocol = NULL;
18
32EFIAPI
34 IN UINT32 InputParameterBlockSize,
35 IN UINT8 *InputParameterBlock,
36 IN OUT UINT32 *OutputParameterBlockSize,
37 IN UINT8 *OutputParameterBlock
38 )
39{
40 EFI_STATUS Status;
42
43 if (mTcg2Protocol == NULL) {
44 Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&mTcg2Protocol);
45 if (EFI_ERROR (Status)) {
46 //
47 // Tcg2 protocol is not installed. So, TPM2 is not present.
48 //
49 DEBUG ((DEBUG_ERROR, "Tpm2SubmitCommand - Tcg2 - %r\n", Status));
50 return EFI_NOT_FOUND;
51 }
52 }
53
54 //
55 // Assume when Tcg2 Protocol is ready, RequestUseTpm already done.
56 //
57 Status = mTcg2Protocol->SubmitCommand (
58 mTcg2Protocol,
59 InputParameterBlockSize,
60 InputParameterBlock,
61 *OutputParameterBlockSize,
62 OutputParameterBlock
63 );
64 if (EFI_ERROR (Status)) {
65 return Status;
66 }
67
68 Header = (TPM2_RESPONSE_HEADER *)OutputParameterBlock;
69 *OutputParameterBlockSize = SwapBytes32 (Header->paramSize);
70
71 return EFI_SUCCESS;
72}
73
82EFIAPI
84 VOID
85 )
86{
87 EFI_STATUS Status;
88
89 if (mTcg2Protocol == NULL) {
90 Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&mTcg2Protocol);
91 if (EFI_ERROR (Status)) {
92 //
93 // Tcg2 protocol is not installed. So, TPM2 is not present.
94 //
95 DEBUG ((DEBUG_ERROR, "Tpm2RequestUseTpm - Tcg2 - %r\n", Status));
96 return EFI_NOT_FOUND;
97 }
98 }
99
100 //
101 // Assume when Tcg2 Protocol is ready, RequestUseTpm already done.
102 //
103 return EFI_SUCCESS;
104}
105
116EFIAPI
118 IN TPM2_DEVICE_INTERFACE *Tpm2Device
119 )
120{
121 return EFI_UNSUPPORTED;
122}
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition: SwapBytes32.c:25
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI Tpm2RegisterTpm2DeviceLib(IN TPM2_DEVICE_INTERFACE *Tpm2Device)
EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
EFI_STATUS EFIAPI Tpm2RequestUseTpm(VOID)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS