]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeCorePerformanceLib: use AllocatePeiAccessiblePages
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 22 May 2018 13:36:16 +0000 (15:36 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 29 May 2018 08:47:18 +0000 (10:47 +0200)
Replace the call to and implementation of the function
FpdtAllocateReservedMemoryBelow4G() with a call to
AllocatePeiAccessiblePages, which boils down to the same on X64,
but does not crash non-X64 systems that lack memory below 4 GB.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c

index 71d624fc9ce90e9f8f49158117befdae0417436d..68b29ac5a9e291493060ec913bb9468f8652342a 100644 (file)
@@ -165,46 +165,6 @@ IsKnownID (
   }\r
 }\r
 \r
-/**\r
-  Allocate EfiReservedMemoryType below 4G memory address.\r
-\r
-  This function allocates EfiReservedMemoryType below 4G memory address.\r
-\r
-  @param[in]  Size   Size of memory to allocate.\r
-\r
-  @return Allocated address for output.\r
-\r
-**/\r
-VOID *\r
-FpdtAllocateReservedMemoryBelow4G (\r
-  IN UINTN       Size\r
-  )\r
-{\r
-  UINTN                 Pages;\r
-  EFI_PHYSICAL_ADDRESS  Address;\r
-  EFI_STATUS            Status;\r
-  VOID                  *Buffer;\r
-\r
-  Buffer  = NULL;\r
-  Pages   = EFI_SIZE_TO_PAGES (Size);\r
-  Address = 0xffffffff;\r
-\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiReservedMemoryType,\r
-                  Pages,\r
-                  &Address\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    Buffer = (VOID *) (UINTN) Address;\r
-    ZeroMem (Buffer, Size);\r
-  }\r
-\r
-  return Buffer;\r
-}\r
-\r
 /**\r
   Allocate buffer for Boot Performance table.\r
 \r
@@ -348,7 +308,13 @@ AllocateBootPerformanceTable (
     //\r
     // Fail to allocate at specified address, continue to allocate at any address.\r
     //\r
-    mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize);\r
+    mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) AllocatePeiAccessiblePages (\r
+                                                             EfiReservedMemoryType,\r
+                                                             EFI_SIZE_TO_PAGES (BootPerformanceDataSize)\r
+                                                             );\r
+    if (mAcpiBootPerformanceTable != NULL) {\r
+      ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize);\r
+    }\r
   }\r
   DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));\r
 \r