TianoCore EDK2 master
Loading...
Searching...
No Matches
Tpm2DeviceLibRouterPei.c
Go to the documentation of this file.
1
11#include <Library/BaseLib.h>
13#include <Library/HobLib.h>
14#include <Library/DebugLib.h>
15#include <Library/PcdLib.h>
17
18EFI_GUID mInternalTpm2DeviceInterfaceGuid = {
19 0x349cf818, 0xc0ba, 0x4c43, { 0x92, 0x9a, 0xc8, 0xa1, 0xb1, 0xb3, 0xd2, 0x55 }
20};
21
29 VOID
30 )
31{
33
34 Hob = GetFirstGuidHob (&mInternalTpm2DeviceInterfaceGuid);
35 if (Hob == NULL) {
36 return NULL;
37 }
38
39 return (TPM2_DEVICE_INTERFACE *)(Hob + 1);
40}
41
55EFIAPI
57 IN UINT32 InputParameterBlockSize,
58 IN UINT8 *InputParameterBlock,
59 IN OUT UINT32 *OutputParameterBlockSize,
60 IN UINT8 *OutputParameterBlock
61 )
62{
63 TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface;
64
65 Tpm2DeviceInterface = InternalGetTpm2DeviceInterface ();
66 if (Tpm2DeviceInterface == NULL) {
67 return EFI_UNSUPPORTED;
68 }
69
70 return Tpm2DeviceInterface->Tpm2SubmitCommand (
71 InputParameterBlockSize,
72 InputParameterBlock,
73 OutputParameterBlockSize,
74 OutputParameterBlock
75 );
76}
77
86EFIAPI
88 VOID
89 )
90{
91 TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface;
92
93 Tpm2DeviceInterface = InternalGetTpm2DeviceInterface ();
94 if (Tpm2DeviceInterface == NULL) {
95 return EFI_UNSUPPORTED;
96 }
97
98 return Tpm2DeviceInterface->Tpm2RequestUseTpm ();
99}
100
111EFIAPI
113 IN TPM2_DEVICE_INTERFACE *Tpm2Device
114 )
115{
116 TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface;
117
118 if (!CompareGuid (PcdGetPtr (PcdTpmInstanceGuid), &Tpm2Device->ProviderGuid)) {
119 DEBUG ((DEBUG_WARN, "WARNING: Tpm2RegisterTpm2DeviceLib - does not support %g registration\n", &Tpm2Device->ProviderGuid));
120 return EFI_UNSUPPORTED;
121 }
122
123 Tpm2DeviceInterface = InternalGetTpm2DeviceInterface ();
124 if (Tpm2DeviceInterface != NULL) {
125 //
126 // In PEI phase, there will be shadow driver dispatched again.
127 //
128 DEBUG ((DEBUG_INFO, "Tpm2RegisterTpm2DeviceLib - Override\n"));
129 CopyMem (Tpm2DeviceInterface, Tpm2Device, sizeof (*Tpm2Device));
130 return EFI_SUCCESS;
131 } else {
132 Tpm2Device = BuildGuidDataHob (&mInternalTpm2DeviceInterfaceGuid, Tpm2Device, sizeof (*Tpm2Device));
133 if (Tpm2Device != NULL) {
134 return EFI_SUCCESS;
135 } else {
136 return EFI_OUT_OF_RESOURCES;
137 }
138 }
139}
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
Definition: HobLib.c:375
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
#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
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
TPM2_DEVICE_INTERFACE * InternalGetTpm2DeviceInterface(VOID)
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
Definition: Base.h:213