2 The module entry point for Tcg configuration module.
4 Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "TcgConfigImpl.h"
16 #include <Guid/TpmInstance.h>
19 The entry point for Tcg configuration driver.
21 @param[in] ImageHandle The image handle of the driver.
22 @param[in] SystemTable The system table.
24 @retval EFI_ALREADY_STARTED The driver already exists in system.
25 @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.
26 @retval EFI_SUCCES All the related protocols are installed on the driver.
27 @retval Others Fail to install protocols as indicated.
32 TcgConfigDriverEntryPoint (
33 IN EFI_HANDLE ImageHandle
,
34 IN EFI_SYSTEM_TABLE
*SystemTable
38 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
39 EFI_TCG_PROTOCOL
*TcgProtocol
;
41 if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid
), &gEfiTpmDeviceInstanceTpm12Guid
)){
42 DEBUG ((EFI_D_ERROR
, "No TPM12 instance required!\n"));
43 return EFI_UNSUPPORTED
;
46 Status
= TisPcRequestUseTpm ((TIS_TPM_HANDLE
) (UINTN
) TPM_BASE_ADDRESS
);
47 if (EFI_ERROR (Status
)) {
48 DEBUG ((EFI_D_ERROR
, "TPM not detected!\n"));
52 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**) &TcgProtocol
);
53 if (EFI_ERROR (Status
)) {
57 Status
= gBS
->OpenProtocol (
63 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
65 if (!EFI_ERROR (Status
)) {
66 return EFI_ALREADY_STARTED
;
70 // Create a private data structure.
72 PrivateData
= AllocateCopyPool (sizeof (TCG_CONFIG_PRIVATE_DATA
), &mTcgConfigPrivateDateTemplate
);
73 if (PrivateData
== NULL
) {
74 return EFI_OUT_OF_RESOURCES
;
77 PrivateData
->TcgProtocol
= TcgProtocol
;
78 PrivateData
->HideTpm
= (BOOLEAN
) (PcdGetBool (PcdHideTpmSupport
) && PcdGetBool (PcdHideTpm
));
81 // Install TCG configuration form
83 Status
= InstallTcgConfigForm (PrivateData
);
84 if (EFI_ERROR (Status
)) {
89 // Install private GUID.
91 Status
= gBS
->InstallMultipleProtocolInterfaces (
98 if (EFI_ERROR (Status
)) {
105 if (PrivateData
!= NULL
) {
106 UninstallTcgConfigForm (PrivateData
);
113 Unload the Tcg configuration form.
115 @param[in] ImageHandle The driver's image handle.
117 @retval EFI_SUCCESS The Tcg configuration form is unloaded.
118 @retval Others Failed to unload the form.
123 TcgConfigDriverUnload (
124 IN EFI_HANDLE ImageHandle
128 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
130 Status
= gBS
->HandleProtocol (
133 (VOID
**) &PrivateData
135 if (EFI_ERROR (Status
)) {
139 ASSERT (PrivateData
->Signature
== TCG_CONFIG_PRIVATE_DATA_SIGNATURE
);
141 gBS
->UninstallMultipleProtocolInterfaces (
148 UninstallTcgConfigForm (PrivateData
);