--- /dev/null
+/** @file\r
+ Dispatch Block to Aps in Pei phase for parallelhash algorithm.\r
+\r
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "CryptParallelHash.h"\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <PiPei.h>\r
+#include <Ppi/MpServices.h>\r
+#include <Library/PeiServicesLib.h>\r
+\r
+/**\r
+ Dispatch the block task to each AP in PEI phase.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DispatchBlockToAp (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ CONST EFI_PEI_SERVICES **PeiServices;\r
+ EFI_PEI_MP_SERVICES_PPI *MpServicesPpi;\r
+\r
+ PeiServices = GetPeiServicesTablePointer ();\r
+ Status = (*PeiServices)->LocatePpi (\r
+ PeiServices,\r
+ &gEfiPeiMpServicesPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&MpServicesPpi\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Failed to locate MpServices Ppi, do parallel hash by one core.\r
+ //\r
+ DEBUG ((DEBUG_ERROR, "[DispatchBlockToApPei] Failed to locate MpServices Ppi. Status = %r\n", Status));\r
+ return;\r
+ }\r
+\r
+ Status = MpServicesPpi->StartupAllAPs (\r
+ (CONST EFI_PEI_SERVICES **)PeiServices,\r
+ MpServicesPpi,\r
+ ParallelHashApExecute,\r
+ FALSE,\r
+ 0,\r
+ NULL\r
+ );\r
+ return;\r
+}\r