]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuDxe.c
OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuDxe.c
index f165e17c5934942bec6b14884efc6268cdf69a1a..f6d0a67dba137ced0b21cc68e2c66c596edecf27 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  CPU DXE Module.\r
+  CPU DXE Module to produce CPU ARCH Protocol.\r
 \r
-  Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2016, 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
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include "CpuDxe.h"\r
+#include "CpuMp.h"\r
 \r
 //\r
 // Global Variables\r
@@ -312,6 +313,21 @@ CpuGetTimerValue (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to\r
+  EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure.\r
+\r
+  @param[in] Buffer  Pointer to an MTRR_SETTINGS object, to be passed to\r
+                     MtrrSetAllMtrrs().\r
+**/\r
+VOID\r
+EFIAPI\r
+SetMtrrsFromBuffer (\r
+  IN VOID *Buffer\r
+  )\r
+{\r
+  MtrrSetAllMtrrs (Buffer);\r
+}\r
 \r
 /**\r
   Implementation of SetMemoryAttributes() service of CPU Architecture Protocol.\r
@@ -349,6 +365,9 @@ CpuSetMemoryAttributes (
 {\r
   RETURN_STATUS             Status;\r
   MTRR_MEMORY_CACHE_TYPE    CacheType;\r
+  EFI_STATUS                MpStatus;\r
+  EFI_MP_SERVICES_PROTOCOL  *MpService;\r
+  MTRR_SETTINGS             MtrrSettings;\r
 \r
   if (!IsMtrrSupported ()) {\r
     return EFI_UNSUPPORTED;\r
@@ -404,6 +423,29 @@ CpuSetMemoryAttributes (
              CacheType\r
              );\r
 \r
+  if (!RETURN_ERROR (Status)) {\r
+    MpStatus = gBS->LocateProtocol (\r
+                      &gEfiMpServiceProtocolGuid,\r
+                      NULL,\r
+                      (VOID **)&MpService\r
+                      );\r
+    //\r
+    // Synchronize the update with all APs\r
+    //\r
+    if (!EFI_ERROR (MpStatus)) {\r
+      MtrrGetAllMtrrs (&MtrrSettings);\r
+      MpStatus = MpService->StartupAllAPs (\r
+                              MpService,          // This\r
+                              SetMtrrsFromBuffer, // Procedure\r
+                              FALSE,              // SingleThread\r
+                              NULL,               // WaitEvent\r
+                              0,                  // TimeoutInMicrosecsond\r
+                              &MtrrSettings,      // ProcedureArgument\r
+                              NULL                // FailedCpuList\r
+                              );\r
+      ASSERT (MpStatus == EFI_SUCCESS || MpStatus == EFI_NOT_STARTED);\r
+    }\r
+  }\r
   return (EFI_STATUS) Status;\r
 }\r
 \r
@@ -897,6 +939,8 @@ InitializeCpu (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  InitializeMpSupport ();\r
+\r
   return Status;\r
 }\r
 \r