2 The module entry point for Tcg configuration module.
4 Copyright (c) 2011, 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"
18 The entry point for Tcg configuration driver.
20 @param[in] ImageHandle The image handle of the driver.
21 @param[in] SystemTable The system table.
23 @retval EFI_ALREADY_STARTED The driver already exists in system.
24 @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.
25 @retval EFI_SUCCES All the related protocols are installed on the driver.
26 @retval Others Fail to install protocols as indicated.
31 TcgConfigDriverEntryPoint (
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
37 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
38 EFI_TCG_PROTOCOL
*TcgProtocol
;
40 Status
= TisPcRequestUseTpm ((TIS_TPM_HANDLE
) (UINTN
) TPM_BASE_ADDRESS
);
41 if (EFI_ERROR (Status
)) {
42 DEBUG ((EFI_D_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
->TcgProtocol
= TcgProtocol
;
72 PrivateData
->HideTpm
= (BOOLEAN
) (PcdGetBool (PcdHideTpmSupport
) && PcdGetBool (PcdHideTpm
));
75 // Install TCG configuration form
77 Status
= InstallTcgConfigForm (PrivateData
);
78 if (EFI_ERROR (Status
)) {
83 // Install private GUID.
85 Status
= gBS
->InstallMultipleProtocolInterfaces (
92 if (EFI_ERROR (Status
)) {
99 if (PrivateData
!= NULL
) {
100 UninstallTcgConfigForm (PrivateData
);
107 Unload the Tcg configuration form.
109 @param[in] ImageHandle The driver's image handle.
111 @retval EFI_SUCCESS The Tcg configuration form is unloaded.
112 @retval Others Failed to unload the form.
117 TcgConfigDriverUnload (
118 IN EFI_HANDLE ImageHandle
122 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
124 Status
= gBS
->HandleProtocol (
127 (VOID
**) &PrivateData
129 if (EFI_ERROR (Status
)) {
133 ASSERT (PrivateData
->Signature
== TCG_CONFIG_PRIVATE_DATA_SIGNATURE
);
135 gBS
->UninstallMultipleProtocolInterfaces (
142 UninstallTcgConfigForm (PrivateData
);