2 The module entry point for TrEE configuration module.
4 Copyright (c) 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 "TrEEConfigImpl.h"
17 extern TPM_INSTANCE_ID mTpmInstanceId
[TPM_DEVICE_MAX
+ 1];
20 The entry point for TrEE 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 TrEEConfigDriverEntryPoint (
34 IN EFI_HANDLE ImageHandle
,
35 IN EFI_SYSTEM_TABLE
*SystemTable
39 TREE_CONFIG_PRIVATE_DATA
*PrivateData
;
40 TREE_CONFIGURATION TrEEConfiguration
;
44 Status
= gBS
->OpenProtocol (
50 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
52 if (!EFI_ERROR (Status
)) {
53 return EFI_ALREADY_STARTED
;
57 // Create a private data structure.
59 PrivateData
= AllocateCopyPool (sizeof (TREE_CONFIG_PRIVATE_DATA
), &mTrEEConfigPrivateDateTemplate
);
60 ASSERT (PrivateData
!= NULL
);
63 // Install private GUID.
65 Status
= gBS
->InstallMultipleProtocolInterfaces (
71 ASSERT_EFI_ERROR (Status
);
73 DataSize
= sizeof(TrEEConfiguration
);
74 Status
= gRT
->GetVariable (
76 &gTrEEConfigFormSetGuid
,
81 if (EFI_ERROR (Status
)) {
84 // We should always reinit PP request.
86 TrEEConfiguration
.Tpm2Operation
= TREE_PHYSICAL_PRESENCE_NO_ACTION
;
89 // Sync data from PCD to variable, so that we do not need detect again in S3 phase.
93 // Get data from PCD to make sure data consistant - platform driver is suppose to construct this PCD accroding to Variable
95 for (Index
= 0; Index
< sizeof(mTpmInstanceId
)/sizeof(mTpmInstanceId
[0]); Index
++) {
96 if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid
), &mTpmInstanceId
[Index
].TpmInstanceGuid
)) {
97 TrEEConfiguration
.TpmDevice
= mTpmInstanceId
[Index
].TpmDevice
;
103 // Save to variable so platform driver can get it.
105 Status
= gRT
->SetVariable (
107 &gTrEEConfigFormSetGuid
,
108 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
109 sizeof(TrEEConfiguration
),
112 ASSERT_EFI_ERROR (Status
);
115 // Install TrEE configuration form
117 Status
= InstallTrEEConfigForm (PrivateData
);
118 if (EFI_ERROR (Status
)) {
125 if (PrivateData
!= NULL
) {
126 UninstallTrEEConfigForm (PrivateData
);
133 Unload the TrEE configuration form.
135 @param[in] ImageHandle The driver's image handle.
137 @retval EFI_SUCCESS The TrEE configuration form is unloaded.
138 @retval Others Failed to unload the form.
143 TrEEConfigDriverUnload (
144 IN EFI_HANDLE ImageHandle
148 TREE_CONFIG_PRIVATE_DATA
*PrivateData
;
150 Status
= gBS
->HandleProtocol (
153 (VOID
**) &PrivateData
155 if (EFI_ERROR (Status
)) {
159 ASSERT (PrivateData
->Signature
== TREE_CONFIG_PRIVATE_DATA_SIGNATURE
);
161 gBS
->UninstallMultipleProtocolInterfaces (
168 UninstallTrEEConfigForm (PrivateData
);