/** @file\r
The module entry point for TrEE configuration module.\r
\r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
#include <Library/PcdLib.h>\r
\r
#include <Ppi/ReadOnlyVariable2.h>\r
+#include <Ppi/TpmInitialized.h>\r
#include <Protocol/TrEEProtocol.h>\r
\r
#include "TrEEConfigNvData.h"\r
NULL\r
};\r
\r
+EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {\r
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+ &gPeiTpmInitializationDonePpiGuid,\r
+ NULL\r
+};\r
+\r
/**\r
This routine check both SetupVariable and real TPM device, and return final TpmDevice configuration.\r
\r
{\r
UINTN Size;\r
EFI_STATUS Status;\r
+ EFI_STATUS Status2;\r
EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi;\r
TREE_CONFIGURATION TrEEConfiguration;\r
UINTN Index;\r
//\r
// Validation\r
//\r
- if (TrEEConfiguration.TpmDevice > TPM_DEVICE_MAX) {\r
- TrEEConfiguration.TpmDevice = TPM_DEVICE_DEFAULT;\r
+ if ((TrEEConfiguration.TpmDevice > TPM_DEVICE_MAX) || (TrEEConfiguration.TpmDevice < TPM_DEVICE_MIN)) {\r
+ TrEEConfiguration.TpmDevice = TPM_DEVICE_DEFAULT;\r
}\r
\r
//\r
// Although we have SetupVariable info, we still need detect TPM device manually.\r
//\r
- DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice from Setup: %x\n", TrEEConfiguration.TpmDevice));\r
+ DEBUG ((EFI_D_INFO, "TrEEConfiguration.TpmDevice from Setup: %x\n", TrEEConfiguration.TpmDevice));\r
\r
if (PcdGetBool (PcdTpmAutoDetection)) {\r
TpmDevice = DetectTpmDevice (TrEEConfiguration.TpmDevice);\r
- DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice final: %x\n", TpmDevice));\r
- TrEEConfiguration.TpmDevice = TpmDevice;\r
+ DEBUG ((EFI_D_INFO, "TpmDevice final: %x\n", TpmDevice));\r
+ if (TpmDevice != TPM_DEVICE_NULL) {\r
+ TrEEConfiguration.TpmDevice = TpmDevice;\r
+ }\r
+ } else {\r
+ TpmDevice = TrEEConfiguration.TpmDevice;\r
}\r
\r
//\r
// This is work-around because there is no gurantee DynamicHiiPcd can return correct value in DXE phase.\r
// Using DynamicPcd instead.\r
//\r
+ // NOTE: TrEEConfiguration variable contains the desired TpmDevice type,\r
+ // while PcdTpmInstanceGuid PCD contains the real detected TpmDevice type\r
+ //\r
for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {\r
- if (TrEEConfiguration.TpmDevice == mTpmInstanceId[Index].TpmDevice) {\r
+ if (TpmDevice == mTpmInstanceId[Index].TpmDevice) {\r
Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid);\r
- PcdSetPtr (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);\r
- DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid));\r
+ Status = PcdSetPtrS (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);\r
+ ASSERT_EFI_ERROR (Status);\r
+ DEBUG ((EFI_D_INFO, "TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid));\r
break;\r
}\r
}\r
Status = PeiServicesInstallPpi (&gTpmSelectedPpi);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ //\r
+ // Even if no TPM is selected or detected, we still need intall TpmInitializationDonePpi.\r
+ // Because TcgPei or TrEEPei will not run, but we still need a way to notify other driver.\r
+ // Other driver can know TPM initialization state by TpmInitializedPpi.\r
+ //\r
+ if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid)) {\r
+ Status2 = PeiServicesInstallPpi (&mTpmInitializationDonePpiList);\r
+ ASSERT_EFI_ERROR (Status2);\r
+ }\r
+\r
return Status;\r
}\r