public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [patch 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
Date: Tue, 23 Jan 2018 11:47:33 +0800	[thread overview]
Message-ID: <1516679255-12328-7-git-send-email-dandan.bi@intel.com> (raw)
In-Reply-To: <1516679255-12328-1-git-send-email-dandan.bi@intel.com>

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



  parent reply	other threads:[~2018-01-23  3:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23  3:47 [patch 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table Dandan Bi
2018-01-23  3:47 ` [patch 1/8] MdeModulePkg:Add definitions for new Performance infrastructure Dandan Bi
2018-01-23  3:47 ` [patch 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase Dandan Bi
2018-01-23  3:47 ` [patch 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase Dandan Bi
2018-01-23  3:47 ` [patch 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase Dandan Bi
2018-01-23  3:47 ` [patch 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase Dandan Bi
2018-01-23  3:47 ` Dandan Bi [this message]
2018-01-23  3:47 ` [patch 7/8] MdeModulePkg/FirmwarePerfSmm: Add check for collecting SMM records Dandan Bi
2018-01-23  3:47 ` [patch 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table Dandan Bi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516679255-12328-7-git-send-email-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox