]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Hash/CryptDispatchApDxe.c
CryptPkg: Enable CryptoPkg BaseCryptLib ParallelHash for PEI and DXE
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Hash / CryptDispatchApDxe.c
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptDispatchApDxe.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptDispatchApDxe.c
new file mode 100644 (file)
index 0000000..607aa7c
--- /dev/null
@@ -0,0 +1,49 @@
+/** @file\r
+  Dispatch Block to Aps in Dxe 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/UefiBootServicesTableLib.h>\r
+#include <Protocol/MpService.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
+  EFI_MP_SERVICES_PROTOCOL  *MpServices;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiMpServiceProtocolGuid,\r
+                  NULL,\r
+                  (VOID **)&MpServices\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Failed to locate MpServices Protocol, do parallel hash by one core.\r
+    //\r
+    DEBUG ((DEBUG_ERROR, "[DispatchBlockToApDxe] Failed to locate MpServices Protocol. Status = %r\n", Status));\r
+    return;\r
+  }\r
+\r
+  Status = MpServices->StartupAllAPs (\r
+                         MpServices,\r
+                         ParallelHashApExecute,\r
+                         FALSE,\r
+                         NULL,\r
+                         0,\r
+                         NULL,\r
+                         NULL\r
+                         );\r
+  return;\r
+}\r