2 The module entry point for Tcg configuration module.
4 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "TcgConfigImpl.h"
10 #include <Guid/TpmInstance.h>
13 The entry point for Tcg configuration driver.
15 @param[in] ImageHandle The image handle of the driver.
16 @param[in] SystemTable The system table.
18 @retval EFI_ALREADY_STARTED The driver already exists in system.
19 @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.
20 @retval EFI_SUCCESS All the related protocols are installed on the driver.
21 @retval Others Fail to install protocols as indicated.
26 TcgConfigDriverEntryPoint (
27 IN EFI_HANDLE ImageHandle
,
28 IN EFI_SYSTEM_TABLE
*SystemTable
32 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
33 EFI_TCG_PROTOCOL
*TcgProtocol
;
35 if (!CompareGuid (PcdGetPtr (PcdTpmInstanceGuid
), &gEfiTpmDeviceInstanceTpm12Guid
)) {
36 DEBUG ((DEBUG_ERROR
, "No TPM12 instance required!\n"));
37 return EFI_UNSUPPORTED
;
40 Status
= Tpm12RequestUseTpm ();
41 if (EFI_ERROR (Status
)) {
42 DEBUG ((DEBUG_ERROR
, "TPM not detected!\n"));
46 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**)&TcgProtocol
);
47 if (EFI_ERROR (Status
)) {
51 Status
= gBS
->OpenProtocol (
57 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
59 if (!EFI_ERROR (Status
)) {
60 return EFI_ALREADY_STARTED
;
64 // Create a private data structure.
66 PrivateData
= AllocateCopyPool (sizeof (TCG_CONFIG_PRIVATE_DATA
), &mTcgConfigPrivateDateTemplate
);
67 if (PrivateData
== NULL
) {
68 return EFI_OUT_OF_RESOURCES
;
71 PrivateData
->Configuration
= AllocatePool (sizeof (TCG_CONFIGURATION
));
72 if (PrivateData
->Configuration
== NULL
) {
73 Status
= EFI_OUT_OF_RESOURCES
;
77 PrivateData
->TcgProtocol
= TcgProtocol
;
80 // Install TCG configuration form
82 Status
= InstallTcgConfigForm (PrivateData
);
83 if (EFI_ERROR (Status
)) {
88 // Install private GUID.
90 Status
= gBS
->InstallMultipleProtocolInterfaces (
97 if (EFI_ERROR (Status
)) {
104 if (PrivateData
!= NULL
) {
105 UninstallTcgConfigForm (PrivateData
);
112 Unload the Tcg configuration form.
114 @param[in] ImageHandle The driver's image handle.
116 @retval EFI_SUCCESS The Tcg configuration form is unloaded.
117 @retval Others Failed to unload the form.
122 TcgConfigDriverUnload (
123 IN EFI_HANDLE ImageHandle
127 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
129 Status
= gBS
->HandleProtocol (
132 (VOID
**)&PrivateData
134 if (EFI_ERROR (Status
)) {
138 ASSERT (PrivateData
->Signature
== TCG_CONFIG_PRIVATE_DATA_SIGNATURE
);
140 gBS
->UninstallMultipleProtocolInterfaces (
147 UninstallTcgConfigForm (PrivateData
);