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"
17 EFI_GUID gTcgConfigPrivateGuid
= TCG_CONFIG_PRIVATE_GUID
;
20 The entry point for Tcg configuration driver.
22 @param[in] ImageHandle The image handle of the driver.
23 @param[in] SystemTable The system table.
25 @retval EFI_ALREADY_STARTED The driver already exists in system.
26 @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.
27 @retval EFI_SUCCES All the related protocols are installed on the driver.
28 @retval Others Fail to install protocols as indicated.
33 TcgConfigDriverEntryPoint (
34 IN EFI_HANDLE ImageHandle
,
35 IN EFI_SYSTEM_TABLE
*SystemTable
39 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
40 EFI_TCG_PROTOCOL
*TcgProtocol
;
42 Status
= TisPcRequestUseTpm ((TIS_TPM_HANDLE
) (UINTN
) TPM_BASE_ADDRESS
);
43 if (EFI_ERROR (Status
)) {
44 DEBUG ((EFI_D_ERROR
, "TPM not detected!\n"));
48 Status
= gBS
->LocateProtocol (&gEfiTcgProtocolGuid
, NULL
, (VOID
**) &TcgProtocol
);
49 if (EFI_ERROR (Status
)) {
53 Status
= gBS
->OpenProtocol (
55 &gTcgConfigPrivateGuid
,
59 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
61 if (!EFI_ERROR (Status
)) {
62 return EFI_ALREADY_STARTED
;
66 // Create a private data structure.
68 PrivateData
= AllocateCopyPool (sizeof (TCG_CONFIG_PRIVATE_DATA
), &mTcgConfigPrivateDateTemplate
);
69 if (PrivateData
== NULL
) {
70 return EFI_OUT_OF_RESOURCES
;
73 PrivateData
->TcgProtocol
= TcgProtocol
;
74 PrivateData
->HideTpm
= (BOOLEAN
) (PcdGetBool (PcdHideTpmSupport
) && PcdGetBool (PcdHideTpm
));
77 // Install TCG configuration form
79 Status
= InstallTcgConfigForm (PrivateData
);
80 if (EFI_ERROR (Status
)) {
85 // Install private GUID.
87 Status
= gBS
->InstallMultipleProtocolInterfaces (
89 &gTcgConfigPrivateGuid
,
94 if (EFI_ERROR (Status
)) {
101 if (PrivateData
!= NULL
) {
102 UninstallTcgConfigForm (PrivateData
);
109 Unload the Tcg configuration form.
111 @param[in] ImageHandle The driver's image handle.
113 @retval EFI_SUCCESS The Tcg configuration form is unloaded.
114 @retval Others Failed to unload the form.
119 TcgConfigDriverUnload (
120 IN EFI_HANDLE ImageHandle
124 TCG_CONFIG_PRIVATE_DATA
*PrivateData
;
126 Status
= gBS
->HandleProtocol (
128 &gTcgConfigPrivateGuid
,
129 (VOID
**) &PrivateData
131 if (EFI_ERROR (Status
)) {
135 ASSERT (PrivateData
->Signature
== TCG_CONFIG_PRIVATE_DATA_SIGNATURE
);
137 gBS
->UninstallMultipleProtocolInterfaces (
139 &gTcgConfigPrivateGuid
,
144 UninstallTcgConfigForm (PrivateData
);