]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
MdeModulePkg/FirmwarePerformanceDataTableDxe: use AllocatePeiAccessiblePages
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / FirmwarePerformanceDataTableDxe / FirmwarePerformanceDxe.c
index e5a38121e9deedabe625f5a746b30e9e59373ec4..ded817f3730118f20a8be312c40eabd7a1dc8f73 100644 (file)
@@ -32,6 +32,7 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/DxeServicesLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
@@ -179,46 +180,6 @@ FpdtAcpiTableChecksum (
   Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Size);\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
   Callback function upon VariableArchProtocol and LockBoxProtocol\r
   to allocate S3 performance table memory and save the pointer to LockBox.\r
@@ -287,7 +248,10 @@ FpdtAllocateS3PerformanceTableMemory (
         //\r
         // Fail to allocate at specified address, continue to allocate at any address.\r
         //\r
-        mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (sizeof (S3_PERFORMANCE_TABLE));\r
+        mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) AllocatePeiAccessiblePages (\r
+                                                             EfiReservedMemoryType,\r
+                                                             EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE))\r
+                                                             );\r
       }\r
       DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));\r
       if (mAcpiS3PerformanceTable != NULL) {\r
@@ -368,7 +332,10 @@ InstallFirmwarePerformanceDataTable (
       //\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
     }\r
     DEBUG ((DEBUG_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));\r
     if (mAcpiBootPerformanceTable == NULL) {\r
@@ -554,6 +521,9 @@ FpdtStatusCodeListenerDxe (
     // Get the Boot performance table and then install it to ACPI table.\r
     //\r
     CopyMem (&mReceivedAcpiBootPerformanceTable, Data + 1, Data->Size);\r
+  } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) {\r
+    DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));\r
+    Status = EFI_UNSUPPORTED;\r
   } else {\r
     //\r
     // Ignore else progress code.\r