]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / FirmwarePerformanceDataTableDxe / FirmwarePerformanceDxe.c
index e719e9e482cb2d280ce8852cd3ed298be85ba64c..9713048f1f0393f160c3827e3ab31be19a4921ba 100644 (file)
@@ -2,17 +2,11 @@
   This module install ACPI Firmware Performance Data Table (FPDT).\r
 \r
   This module register report status code listener to collect performance data\r
-  for Firmware Basic Boot Performance Record and other boot performance records, \r
+  for Firmware Basic Boot Performance Record and other boot performance records,\r
   and install FPDT to ACPI table.\r
 \r
   Copyright (c) 2011 - 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 \r
 #include <Guid/Acpi.h>\r
 #include <Guid/FirmwarePerformance.h>\r
-#include <Guid/EventGroup.h>\r
-#include <Guid/EventLegacyBios.h>\r
 \r
 #include <Library/UefiBootServicesTableLib.h>\r
 #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 +172,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 +240,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 +324,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
@@ -471,7 +430,7 @@ FpdtStatusCodeListenerDxe (
   if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {\r
     return EFI_UNSUPPORTED;\r
   }\r
-  \r
+\r
   if (Value == (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)) {\r
     //\r
     // DxeCore ReportStatusCode Enable so that the capability can be supported.\r
@@ -585,7 +544,7 @@ FpdtExitBootServicesEventNotify (
 {\r
   if (!mDxeCoreReportStatusCodeEnable) {\r
     //\r
-    // When DxeCore Report Status Code is disabled, \r
+    // When DxeCore Report Status Code is disabled,\r
     // Unregister boot time report status code listener at ExitBootService Event.\r
     //\r
     mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);\r