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: Dmitry Antipov <dmanti@microsoft.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Star Zeng <star.zeng@intel.com>
Subject: [patch 2/2] MdeModulePkg: Implement/use Boot Performance Table protocol
Date: Mon, 30 Jul 2018 15:00:16 +0800	[thread overview]
Message-ID: <20180730070016.10396-3-dandan.bi@intel.com> (raw)
In-Reply-To: <20180730070016.10396-1-dandan.bi@intel.com>

1.Update DxeCorePerformanceLib to implement the Firmware
Boot performance Table protocol.

2. Update FirmwarePerformanceDxe to use Boot performance
Table protocol get Performance data from DxeCorePerformanceLib

Cc: Dmitry Antipov <dmanti@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
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>
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c  | 74 ++++++----------------
 .../DxeCorePerformanceLib.inf                      |  6 +-
 .../DxeCorePerformanceLibInternal.h                | 15 +++++
 .../FirmwarePerformanceDxe.c                       | 71 ++++++++++++++++-----
 .../FirmwarePerformanceDxe.inf                     |  5 +-
 5 files changed, 93 insertions(+), 78 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 5798c89fff..7a46be5304 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -88,10 +88,17 @@ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *mDevicePathToText = NULL;
 //
 EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
   CreatePerformanceMeasurement,
   };
 
+//
+// Interfaces for Firmware Boot Performance Table Protocol.
+//
+EDKII_FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL mBootPerformanceProtocolInterface = {
+  GetFirmwareBootPerformanceTable,
+  };
+
 PERFORMANCE_PROPERTY  mPerformanceProperty;
 
 /**
   Return the pointer to the FPDT record in the allocated memory.
 
@@ -209,17 +216,21 @@ IsKnownID (
     return FALSE;
   }
 }
 
 /**
-  Allocate buffer for Boot Performance table.
+  Get the address of the Firmware Boot Performance Table.
 
-  @return Status code.
+  @param BootPerformanceTable   - Pointer to the address of firmware boot performance table.
 
+  @retval EFI_SUCCESS           - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
 **/
 EFI_STATUS
-AllocateBootPerformanceTable (
+EFIAPI
+GetFirmwareBootPerformanceTable (
+  OUT VOID                   **BootPerformanceTable
   )
 {
   EFI_STATUS                              Status;
   UINTN                                   Size;
   UINT8                                   *SmmBootRecordCommBuffer;
@@ -403,10 +414,12 @@ AllocateBootPerformanceTable (
 
   mBootRecordBuffer  = (UINT8 *) mAcpiBootPerformanceTable;
   mBootRecordSize    = mAcpiBootPerformanceTable->Header.Length;
   mBootRecordMaxSize = mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);
 
+  mFpdtBufferIsReported = TRUE;
+  *BootPerformanceTable = mAcpiBootPerformanceTable;
   return EFI_SUCCESS;
 }
 
 /**
   Get a human readable module name and module guid for the given image handle.
@@ -1302,48 +1315,10 @@ InternalGetPeiPerformance (
     //
     GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
   }
 }
 
-/**
-  Report Boot Perforamnce table address as report status code.
-
-  @param  Event    The event of notify protocol.
-  @param  Context  Notify event context.
-
-**/
-VOID
-EFIAPI
-ReportFpdtRecordBuffer (
-  IN EFI_EVENT     Event,
-  IN VOID          *Context
-  )
-{
-  EFI_STATUS      Status;
-  UINT64          BPDTAddr;
-
-  if (!mFpdtBufferIsReported) {
-    Status = AllocateBootPerformanceTable ();
-    if (!EFI_ERROR(Status)) {
-      BPDTAddr = (UINT64)(UINTN)mAcpiBootPerformanceTable;
-      REPORT_STATUS_CODE_EX (
-          EFI_PROGRESS_CODE,
-          EFI_SOFTWARE_DXE_BS_DRIVER,
-          0,
-          NULL,
-          &gEdkiiFpdtExtendedFirmwarePerformanceGuid,
-          &BPDTAddr,
-          sizeof (UINT64)
-          );
-    }
-    //
-    // Set FPDT report state to TRUE.
-    //
-    mFpdtBufferIsReported = TRUE;
-  }
-}
-
 /**
   The constructor function initializes Performance infrastructure for DXE phase.
 
   The constructor function publishes Performance and PerformanceEx protocol, allocates memory to log DXE performance
   and merges PEI performance data to DXE performance log.
@@ -1362,11 +1337,10 @@ DxeCorePerformanceLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
   EFI_STATUS                Status;
   EFI_HANDLE                Handle;
-  EFI_EVENT                 ReadyToBootEvent;
   PERFORMANCE_PROPERTY      *PerformanceProperty;
 
   if (!PerformanceMeasurementEnabled ()) {
     //
     // Do not initialize performance infrastructure if not required.
@@ -1385,28 +1359,16 @@ DxeCorePerformanceLibConstructor (
   Handle = NULL;
   Status = gBS->InstallMultipleProtocolInterfaces (
                   &Handle,
                   &gEdkiiPerformanceMeasurementProtocolGuid,
                   &mPerformanceMeasurementInterface,
+                  &gEdkiiFirmwareBootPerformanceTableProtocolGuid,
+                  &mBootPerformanceProtocolInterface,
                   NULL
                   );
   ASSERT_EFI_ERROR (Status);
 
-  //
-  // Register ReadyToBoot event to report StatusCode data
-  //
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
-                  TPL_CALLBACK,
-                  ReportFpdtRecordBuffer,
-                  NULL,
-                  &gEfiEventReadyToBootGuid,
-                  &ReadyToBootEvent
-                  );
-
-  ASSERT_EFI_ERROR (Status);
-
   Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
   if (EFI_ERROR (Status)) {
     //
     // Install configuration table for performance property.
     //
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
index 8fab47ff02..85963263f3 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
@@ -71,13 +71,13 @@
   ## PRODUCES             ## SystemTable
   gPerformanceProtocolGuid
   gZeroGuid                                     ## SOMETIMES_CONSUMES ## GUID
   gEfiFirmwarePerformanceGuid                   ## SOMETIMES_PRODUCES ## UNDEFINED # StatusCode Data
   gEdkiiFpdtExtendedFirmwarePerformanceGuid     ## SOMETIMES_CONSUMES ## HOB # StatusCode Data
-  gEfiEventReadyToBootGuid                      ## CONSUMES           ## Event
-  gEdkiiPiSmmCommunicationRegionTableGuid       ## SOMETIMES_CONSUMES    ## SystemTable
-  gEdkiiPerformanceMeasurementProtocolGuid      ## PRODUCES           ## UNDEFINED # Install protocol
+  gEdkiiPiSmmCommunicationRegionTableGuid           ## SOMETIMES_CONSUMES    ## SystemTable
+  gEdkiiPerformanceMeasurementProtocolGuid          ## PRODUCES              ## UNDEFINED # Install protocol
+  gEdkiiFirmwareBootPerformanceTableProtocolGuid    ## PRODUCES              ## UNDEFINED # Install protocol
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask         ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize         ## CONSUMES
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
index 2b214e2e57..767c0f7888 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
@@ -21,10 +21,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 #include <PiDxe.h>
 
 #include <Guid/Performance.h>
 #include <Guid/PerformanceMeasurement.h>
+#include <Guid/FirmwareBootPerformanceTable.h>
 #include <Guid/ExtendedFirmwarePerformance.h>
 #include <Guid/ZeroGuid.h>
 #include <Guid/EventGroup.h>
 #include <Guid/FirmwarePerformance.h>
 #include <Guid/PiSmmCommunicationRegionTable.h>
@@ -49,10 +50,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiLib.h>
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/DxeServicesLib.h>
 #include <Library/PeCoffGetEntryPointLib.h>
 
+/**
+  Get the address of the Firmware Boot Performance Table.
+
+  @param BootPerformanceTable   - Pointer to the address of firmware boot performance table.
+
+  @retval EFI_SUCCESS           - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+**/
+EFI_STATUS
+EFIAPI
+GetFirmwareBootPerformanceTable (
+  OUT VOID                   **BootPerformanceTable
+  );
+
 /**
   Create performance record with event description and a timestamp.
 
   @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
   @param Guid              - Pointer to a GUID.
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
index 3d8e83250e..1f924fbb37 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
@@ -23,10 +23,12 @@
 #include <Protocol/LockBox.h>
 #include <Protocol/Variable.h>
 
 #include <Guid/Acpi.h>
 #include <Guid/FirmwarePerformance.h>
+#include <Guid/FirmwareBootPerformanceTable.h>
+
 #include <Guid/EventGroup.h>
 #include <Guid/EventLegacyBios.h>
 
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>
@@ -284,15 +286,27 @@ FpdtAllocateS3PerformanceTableMemory (
 EFI_STATUS
 InstallFirmwarePerformanceDataTable (
   VOID
   )
 {
-  EFI_STATUS                    Status;
-  EFI_ACPI_TABLE_PROTOCOL       *AcpiTableProtocol;
-  UINTN                         BootPerformanceDataSize;
-  FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
-  UINTN                         Size;
+  EFI_STATUS                                       Status;
+  EFI_ACPI_TABLE_PROTOCOL                          *AcpiTableProtocol;
+  UINTN                                            BootPerformanceDataSize;
+  FIRMWARE_PERFORMANCE_VARIABLE                    PerformanceVariable;
+  UINTN                                            Size;
+  EDKII_FIRMWARE_BOOT_PERFORMANCE_TABLE_PROTOCOL   *FirmwareBootPerformanceTableProtocol;
+
+  //
+  // Locate FirmwareBootPerformanceTable protocol.
+  //
+  Status =  gBS->LocateProtocol (&gEdkiiFirmwareBootPerformanceTableProtocolGuid, NULL, (VOID **) &FirmwareBootPerformanceTableProtocol);
+  if (!EFI_ERROR (Status)) {
+     Status =FirmwareBootPerformanceTableProtocol->GetFirmwareBootPerformanceTable((VOID **)&mReceivedAcpiBootPerformanceTable);
+  }
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
 
   //
   // Get AcpiTable Protocol.
   //
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
@@ -507,22 +521,10 @@ 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, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) {
-    //
-    // Get the Boot performance table and then install it to ACPI table.
-    //
-    CopyMem (&mReceivedAcpiBootPerformanceTable, Data + 1, Data->Size);
   } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) {
     DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
     Status = EFI_UNSUPPORTED;
   } else {
     //
@@ -532,10 +534,32 @@ FpdtStatusCodeListenerDxe (
   }
 
   return Status;
 }
 
+/**
+  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 ();
+  }
+}
 
 /**
   Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
   performance data for ExitBootServicesEntry in FPDT.
 
@@ -639,10 +663,23 @@ FirmwarePerformanceDxeEntryPoint (
                   &gEfiEventExitBootServicesGuid,
                   &mExitBootServicesEvent
                   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Register the notify function to install firmware performance table.
+  //
+  Status = gBS->CreateEventEx (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_CALLBACK,
+                  FpdtReadyToBootEventNotify,
+                  NULL,
+                  &gEfiEventReadyToBootGuid,
+                  &mReadyToBootEvent
+                  );
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Retrieve GUID HOB data that contains the ResetEnd.
   //
   GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid);
   if (GuidHob != NULL) {
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
index 843cda7021..6f4e8e85fe 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
@@ -67,12 +67,13 @@
   ## SOMETIMES_CONSUMES   ## Variable:L"FirmwarePerformance"
   ## PRODUCES             ## Variable:L"FirmwarePerformance"
   ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
   ## SOMETIMES_CONSUMES ## UNDEFINED # StatusCode Data
   gEfiFirmwarePerformanceGuid
-  gEdkiiFpdtExtendedFirmwarePerformanceGuid     ## SOMETIMES_CONSUMES ## UNDEFINED # StatusCode Data
-  gFirmwarePerformanceS3PointerGuid             ## PRODUCES ## UNDEFINED # SaveLockBox
+  gEdkiiFpdtExtendedFirmwarePerformanceGuid       ## SOMETIMES_CONSUMES ## UNDEFINED # StatusCode Data
+  gFirmwarePerformanceS3PointerGuid               ## PRODUCES ## UNDEFINED # SaveLockBox
+  gEdkiiFirmwareBootPerformanceTableProtocolGuid  ## CONSUMES # Loacte protocol
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad    ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart   ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize    ## CONSUMES
-- 
2.14.3.windows.1



  parent reply	other threads:[~2018-07-30  7:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30  7:00 [patch 0/2] Enahnce Perf data transfer between Dxe Perf Lib and driver Dandan Bi
2018-07-30  7:00 ` [patch 1/2] MdeModulePkg: Add definition of Boot Performance Table protocol Dandan Bi
2018-07-30  7:00 ` Dandan Bi [this message]
2018-08-03  9:39 ` [patch 0/2] Enahnce Perf data transfer between Dxe Perf Lib and driver Gao, Liming

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=20180730070016.10396-3-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