+}\r
+\r
+/**\r
+ The constructor function of HashLibBaseCryptoRouterPei.\r
+\r
+ @param FileHandle The handle of FFS header the loaded driver.\r
+ @param PeiServices The pointer to the PEI services.\r
+\r
+ @retval EFI_SUCCESS The constructor executes successfully.\r
+ @retval EFI_OUT_OF_RESOURCES There is no enough resource for the constructor.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HashLibBaseCryptoRouterPeiConstructor (\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ IN CONST EFI_PEI_SERVICES **PeiServices\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ HASH_INTERFACE_HOB *HashInterfaceHob;\r
+\r
+ HashInterfaceHob = InternalGetHashInterfaceHob (&gZeroGuid);\r
+ if (HashInterfaceHob == NULL) {\r
+ //\r
+ // No HOB with gZeroGuid Identifier has been created,\r
+ // this is FIRST module which consumes HashLib.\r
+ // Create the HOB with gZeroGuid Identifier.\r
+ //\r
+ HashInterfaceHob = InternalCreateHashInterfaceHob (&gZeroGuid);\r
+ if (HashInterfaceHob == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ } else {\r
+ //\r
+ // Record hash algorithm bitmap of LAST module which also consumes HashLib.\r
+ //\r
+ HashInterfaceHob->SupportedHashMask = PcdGet32 (PcdTcg2HashAlgorithmBitmap);\r
+ }\r
+\r
+ HashInterfaceHob = InternalGetHashInterfaceHob (&gEfiCallerIdGuid);\r
+ if (HashInterfaceHob != NULL) {\r
+ //\r
+ // In PEI phase, some modules may call RegisterForShadow and will be\r
+ // shadowed and executed again after memory is discovered.\r
+ // This is the second execution of this module, clear the hash interface\r
+ // information registered at its first execution.\r
+ //\r
+ ZeroMem (&HashInterfaceHob->HashInterface, sizeof (*HashInterfaceHob) - sizeof (EFI_GUID));\r
+ }\r
+\r
+ //\r
+ // Set PcdTcg2HashAlgorithmBitmap to 0 in CONSTRUCTOR for CURRENT module.\r
+ //\r
+ Status = PcdSet32S (PcdTcg2HashAlgorithmBitmap, 0);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r