From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 761E6210C0F4C for ; Mon, 30 Jul 2018 00:01:06 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2018 00:01:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,422,1526367600"; d="scan'208";a="60864501" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 30 Jul 2018 00:01:04 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Dmitry Antipov , Michael D Kinney , Liming Gao , Star Zeng Date: Mon, 30 Jul 2018 15:00:16 +0800 Message-Id: <20180730070016.10396-3-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180730070016.10396-1-dandan.bi@intel.com> References: <20180730070016.10396-1-dandan.bi@intel.com> Subject: [patch 2/2] MdeModulePkg: Implement/use Boot Performance Table protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 07:01:06 -0000 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 Cc: Michael D Kinney Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../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 #include #include +#include #include #include #include #include #include @@ -49,10 +50,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include #include +/** + 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 #include #include #include +#include + #include #include #include #include @@ -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