]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
UefiCpuPkg MpInitLib: Fix typo "sCPUID" to "CPUID"
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / PeiMpLib.c
index 9ee5aca57b2bb41aa8dd85793dc9434a247fd338..791ae9db6eb09d32878fbb900f7dfc96ac35f24d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MP initialize support functions for PEI phase.\r
 \r
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, 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
@@ -75,15 +75,15 @@ SaveCpuMpData (
 **/\r
 BOOLEAN\r
 CheckOverlapWithAllocatedBuffer (\r
-  IN UINT               WakeupBufferStart,\r
-  IN UINT               WakeupBufferEnd\r
+  IN UINT64               WakeupBufferStart,\r
+  IN UINT64               WakeupBufferEnd\r
   )\r
 {\r
   EFI_PEI_HOB_POINTERS      Hob;\r
   EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r
   BOOLEAN                   Overlapped;\r
-  UINT                    MemoryStart;\r
-  UINT                    MemoryEnd;\r
+  UINT64                    MemoryStart;\r
+  UINT64                    MemoryEnd;\r
 \r
   Overlapped = FALSE;\r
   //\r
@@ -96,9 +96,8 @@ CheckOverlapWithAllocatedBuffer (
   while (!END_OF_HOB_LIST (Hob)) {\r
     if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
       MemoryHob   = Hob.MemoryAllocation;\r
-      MemoryStart = (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
-      MemoryEnd   = (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddress +\r
-                             MemoryHob->AllocDescriptor.MemoryLength);\r
+      MemoryStart = MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
+      MemoryEnd   = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;\r
       if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) {\r
         Overlapped = TRUE;\r
         break;\r
@@ -123,8 +122,8 @@ GetWakeupBuffer (
   )\r
 {\r
   EFI_PEI_HOB_POINTERS    Hob;\r
-  UINT                  WakeupBufferStart;\r
-  UINT                  WakeupBufferEnd;\r
+  UINT64                  WakeupBufferStart;\r
+  UINT64                  WakeupBufferEnd;\r
 \r
   WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1);\r
 \r
@@ -149,7 +148,7 @@ GetWakeupBuffer (
         //\r
         // Need memory under 1MB to be collected here\r
         //\r
-        WakeupBufferEnd = (UINTN) (Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength);\r
+        WakeupBufferEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength;\r
         if (WakeupBufferEnd > BASE_1MB) {\r
           //\r
           // Wakeup buffer should be under 1MB\r
@@ -174,7 +173,7 @@ GetWakeupBuffer (
           }\r
           DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r
                                WakeupBufferStart, WakeupBufferSize));\r
-          return WakeupBufferStart;\r
+          return (UINTN)WakeupBufferStart;\r
         }\r
       }\r
     }\r
@@ -188,39 +187,26 @@ GetWakeupBuffer (
 }\r
 \r
 /**\r
-  Allocate reset vector buffer.\r
+  Get available EfiBootServicesCode memory below 4GB by specified size.\r
 \r
-  @param[in, out]  CpuMpData  The pointer to CPU MP Data structure.\r
-**/\r
-VOID\r
-AllocateResetVector (\r
-  IN OUT CPU_MP_DATA          *CpuMpData\r
-  )\r
-{\r
-  UINTN           ApResetVectorSize;\r
+  This buffer is required to safely transfer AP from real address mode to\r
+  protected mode or long mode, due to the fact that the buffer returned by\r
+  GetWakeupBuffer() may be marked as non-executable.\r
 \r
-  if (CpuMpData->WakeupBuffer == (UINTN) -1) {\r
-    ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +\r
-                          sizeof (MP_CPU_EXCHANGE_INFO);\r
-\r
-    CpuMpData->WakeupBuffer      = GetWakeupBuffer (ApResetVectorSize);\r
-    CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)\r
-                    (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize);\r
-  }\r
-  BackupAndPrepareWakeupBuffer (CpuMpData);\r
-}\r
+  @param[in] BufferSize   Wakeup transition buffer size.\r
 \r
-/**\r
-  Free AP reset vector buffer.\r
-\r
-  @param[in]  CpuMpData  The pointer to CPU MP Data structure.\r
+  @retval other   Return wakeup transition buffer address below 4GB.\r
+  @retval 0       Cannot find free memory below 4GB.\r
 **/\r
-VOID\r
-FreeResetVector (\r
-  IN CPU_MP_DATA              *CpuMpData\r
+UINTN\r
+GetModeTransitionBuffer (\r
+  IN UINTN                BufferSize\r
   )\r
 {\r
-  RestoreWakeupBuffer (CpuMpData);\r
+  //\r
+  // PEI phase doesn't need to do such transition. So simply return 0.\r
+  //\r
+  return 0;\r
 }\r
 \r
 /**\r