TianoCore EDK2 master
Loading...
Searching...
No Matches
TcgConfigDriver.c
Go to the documentation of this file.
1
9#include "TcgConfigImpl.h"
10#include <Guid/TpmInstance.h>
11
25EFIAPI
27 IN EFI_HANDLE ImageHandle,
28 IN EFI_SYSTEM_TABLE *SystemTable
29 )
30{
31 EFI_STATUS Status;
32 TCG_CONFIG_PRIVATE_DATA *PrivateData;
33 EFI_TCG_PROTOCOL *TcgProtocol;
34
35 if (!CompareGuid (PcdGetPtr (PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) {
36 DEBUG ((DEBUG_ERROR, "No TPM12 instance required!\n"));
37 return EFI_UNSUPPORTED;
38 }
39
40 Status = Tpm12RequestUseTpm ();
41 if (EFI_ERROR (Status)) {
42 DEBUG ((DEBUG_ERROR, "TPM not detected!\n"));
43 return Status;
44 }
45
46 Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&TcgProtocol);
47 if (EFI_ERROR (Status)) {
48 TcgProtocol = NULL;
49 }
50
51 Status = gBS->OpenProtocol (
52 ImageHandle,
53 &gEfiCallerIdGuid,
54 NULL,
55 ImageHandle,
56 ImageHandle,
57 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
58 );
59 if (!EFI_ERROR (Status)) {
60 return EFI_ALREADY_STARTED;
61 }
62
63 //
64 // Create a private data structure.
65 //
66 PrivateData = AllocateCopyPool (sizeof (TCG_CONFIG_PRIVATE_DATA), &mTcgConfigPrivateDateTemplate);
67 if (PrivateData == NULL) {
68 return EFI_OUT_OF_RESOURCES;
69 }
70
71 PrivateData->Configuration = AllocatePool (sizeof (TCG_CONFIGURATION));
72 if (PrivateData->Configuration == NULL) {
73 Status = EFI_OUT_OF_RESOURCES;
74 goto ErrorExit;
75 }
76
77 PrivateData->TcgProtocol = TcgProtocol;
78
79 //
80 // Install TCG configuration form
81 //
82 Status = InstallTcgConfigForm (PrivateData);
83 if (EFI_ERROR (Status)) {
84 goto ErrorExit;
85 }
86
87 //
88 // Install private GUID.
89 //
90 Status = gBS->InstallMultipleProtocolInterfaces (
91 &ImageHandle,
92 &gEfiCallerIdGuid,
93 PrivateData,
94 NULL
95 );
96
97 if (EFI_ERROR (Status)) {
98 goto ErrorExit;
99 }
100
101 return EFI_SUCCESS;
102
103ErrorExit:
104 if (PrivateData != NULL) {
105 UninstallTcgConfigForm (PrivateData);
106 }
107
108 return Status;
109}
110
121EFIAPI
123 IN EFI_HANDLE ImageHandle
124 )
125{
126 EFI_STATUS Status;
127 TCG_CONFIG_PRIVATE_DATA *PrivateData;
128
129 Status = gBS->HandleProtocol (
130 ImageHandle,
131 &gEfiCallerIdGuid,
132 (VOID **)&PrivateData
133 );
134 if (EFI_ERROR (Status)) {
135 return Status;
136 }
137
138 ASSERT (PrivateData->Signature == TCG_CONFIG_PRIVATE_DATA_SIGNATURE);
139
140 gBS->UninstallMultipleProtocolInterfaces (
141 ImageHandle,
142 &gEfiCallerIdGuid,
143 PrivateData,
144 NULL
145 );
146
147 UninstallTcgConfigForm (PrivateData);
148
149 return EFI_SUCCESS;
150}
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI TcgConfigDriverUnload(IN EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI TcgConfigDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS InstallTcgConfigForm(IN OUT TCG_CONFIG_PRIVATE_DATA *PrivateData)
VOID UninstallTcgConfigForm(IN OUT TCG_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS EFIAPI Tpm12RequestUseTpm(VOID)
Definition: Tpm12Tis.c:555
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS