TianoCore EDK2 master
Loading...
Searching...
No Matches
Tpm12DeviceLibTcg.c
Go to the documentation of this file.
1
9#include <Uefi.h>
10#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
15#include <Protocol/TcgService.h>
17
18EFI_TCG_PROTOCOL *mTcgProtocol = NULL;
19
33EFIAPI
35 IN UINT32 InputParameterBlockSize,
36 IN UINT8 *InputParameterBlock,
37 IN OUT UINT32 *OutputParameterBlockSize,
38 IN UINT8 *OutputParameterBlock
39 )
40{
41 EFI_STATUS Status;
42 TPM_RSP_COMMAND_HDR *Header;
43
44 if (mTcgProtocol == NULL) {
45 Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&mTcgProtocol);
46 if (EFI_ERROR (Status)) {
47 //
48 // TCG protocol is not installed. So, TPM12 is not present.
49 //
50 DEBUG ((DEBUG_ERROR, "Tpm12SubmitCommand - TCG - %r\n", Status));
51 return EFI_NOT_FOUND;
52 }
53 }
54
55 //
56 // Assume when TCG Protocol is ready, RequestUseTpm already done.
57 //
58 Status = mTcgProtocol->PassThroughToTpm (
59 mTcgProtocol,
60 InputParameterBlockSize,
61 InputParameterBlock,
62 *OutputParameterBlockSize,
63 OutputParameterBlock
64 );
65 if (EFI_ERROR (Status)) {
66 return Status;
67 }
68
69 Header = (TPM_RSP_COMMAND_HDR *)OutputParameterBlock;
70 *OutputParameterBlockSize = SwapBytes32 (Header->paramSize);
71
72 return EFI_SUCCESS;
73}
74
83EFIAPI
85 VOID
86 )
87{
88 EFI_STATUS Status;
89
90 if (mTcgProtocol == NULL) {
91 Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&mTcgProtocol);
92 if (EFI_ERROR (Status)) {
93 //
94 // TCG protocol is not installed. So, TPM12 is not present.
95 //
96 DEBUG ((DEBUG_ERROR, "Tpm12RequestUseTpm - TCG - %r\n", Status));
97 return EFI_NOT_FOUND;
98 }
99 }
100
101 //
102 // Assume when TCG Protocol is ready, RequestUseTpm already done.
103 //
104 return EFI_SUCCESS;
105}
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition: SwapBytes32.c:25
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI Tpm12RequestUseTpm(VOID)
EFI_STATUS EFIAPI Tpm12SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS