[edk2] [patch 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure

Dandan Bi posted 8 patches 6 years, 11 months ago
There is a newer version of this series
[edk2] [patch 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
Posted by Dandan Bi 6 years, 11 months ago
1. Remove the macro EXTENSION_RECORD_SIZE, since the extension
size can be got through PcdExtFpdtBootRecordPadSize.
2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table
3. Copy SMM record according to the allocated size

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../FirmwarePerformanceDxe.c                       | 58 ++++++----------------
 1 file changed, 16 insertions(+), 42 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
index b004cac..0de6bfa 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
@@ -3,11 +3,11 @@
 
   This module register report status code listener to collect performance data
   for Firmware Basic Boot Performance Record and other boot performance records, 
   and install FPDT to ACPI table.
 
-  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -40,12 +40,11 @@
 #include <Library/PcdLib.h>
 #include <Library/HobLib.h>
 #include <Library/LockBoxLib.h>
 #include <Library/UefiLib.h>
 
-#define EXTENSION_RECORD_SIZE     0x10000
-#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)
+#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
 
 EFI_RSC_HANDLER_PROTOCOL    *mRscHandlerProtocol = NULL;
 
 BOOLEAN                     mLockBoxReady = FALSE;
 EFI_EVENT                   mReadyToBootEvent;
@@ -419,11 +418,15 @@ InstallFirmwarePerformanceDataTable (
           SmmCommData->BootRecordSize   = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
           while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) {
             Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
             ASSERT_EFI_ERROR (Status);
             ASSERT_EFI_ERROR(SmmCommData->ReturnStatus);
-            CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
+            if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
+              CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset);
+            } else {
+              CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
+            }
             SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize;
           }
         }
       }
     }
@@ -567,33 +570,10 @@ InstallFirmwarePerformanceDataTable (
   
   return EFI_SUCCESS;
 }
 
 /**
-  Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to
-  install the Firmware Performance Data Table.
-
-  @param[in]  Event   The Event that is being processed.
-  @param[in]  Context The Event Context.
-
-**/
-VOID
-EFIAPI
-FpdtReadyToBootEventNotify (
-  IN EFI_EVENT        Event,
-  IN VOID             *Context
-  )
-{
-  if (mAcpiBootPerformanceTable == NULL) {
-    //
-    // ACPI Firmware Performance Data Table not installed yet, install it now.
-    //
-    InstallFirmwarePerformanceDataTable ();
-  }
-}
-
-/**
   Report status code listener of FPDT. This is used to collect performance data
   for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
 
   @param[in]  CodeType            Indicates the type of status code being reported.
   @param[in]  Value               Describes the current status of a hardware or software entity.
@@ -697,22 +677,29 @@ FpdtStatusCodeListenerDxe (
     DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd                = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));
     DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart  = 0\n"));
     DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));
     DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry   = 0\n"));
     DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesExit    = 0\n"));
+  } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) {
+    if (mAcpiBootPerformanceTable == NULL) {
+      //
+      // ACPI Firmware Performance Data Table not installed yet, install it now.
+      //
+      InstallFirmwarePerformanceDataTable ();
+    }
   } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) {
     //
     // Append one or more Boot records
     //
     if (mAcpiBootPerformanceTable == NULL) {
       //
       // Append Boot records before FPDT ACPI table is installed. 
       //
       if (mBootRecordSize + Data->Size > mBootRecordMaxSize) {
-        mBootRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer);
+        mBootRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + PcdGet32 (PcdExtFpdtBootRecordPadSize), mBootRecordBuffer);
         ASSERT (mBootRecordBuffer != NULL);
-        mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE;
+        mBootRecordMaxSize = mBootRecordSize + Data->Size + PcdGet32 (PcdExtFpdtBootRecordPadSize);
       }
       //
       // Save boot record into the temp memory space.
       //
       CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size);
@@ -851,23 +838,10 @@ FirmwarePerformanceDxeEntryPoint (
                   &mExitBootServicesEvent
                   );
   ASSERT_EFI_ERROR (Status);
 
   //
-  // Create ready to boot event to install ACPI FPDT table.
-  //
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
-                  TPL_NOTIFY,
-                  FpdtReadyToBootEventNotify,
-                  NULL,
-                  &gEfiEventReadyToBootGuid,
-                  &mReadyToBootEvent
-                  );
-  ASSERT_EFI_ERROR (Status);
-
-  //
   // Retrieve GUID HOB data that contains the ResetEnd.
   //
   GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid);
   if (GuidHob != NULL) {
     Performance = (FIRMWARE_SEC_PERFORMANCE *) GET_GUID_HOB_DATA (GuidHob);
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel