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.100; helo=mga07.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 C9C89210C42BA for ; Mon, 30 Jul 2018 00:00:01 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jul 2018 23:59:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,421,1526367600"; d="scan'208";a="60863793" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 29 Jul 2018 23:59:31 -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 14:59:04 +0800 Message-Id: <20180730065905.9152-3-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180730065905.9152-1-dandan.bi@intel.com> References: <20180730065905.9152-1-dandan.bi@intel.com> Subject: [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi 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:00:02 -0000 Enhance the PeiPerformanceLib to produce the Performance Measurement PPI. 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 --- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 81 ++++++++++++++++++++++ .../PeiPerformanceLib/PeiPerformanceLib.inf | 1 + 2 files changed, 82 insertions(+) diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 808a63501e..528bf12303 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -30,14 +30,52 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include #include #include +#include #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) #define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE) +/** + 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. + @param String - Pointer to a string describing the measurement. + @param TimeStamp - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to the measurement. + @param Identifier - Performance identifier describing the type of measurement. + @param Attribute - The attribute of the measurement. According to attribute can create a start + record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX, + or a general record for other Perf macros. + + @retval EFI_SUCCESS - Successfully created performance record. + @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records. + @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL + pointer or invalid PerfId. +**/ +EFI_STATUS +EFIAPI +CreatePerformanceMeasurementPpi ( + IN CONST VOID *CallerIdentifier, + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 TimeStamp, + IN UINT64 Address, OPTIONAL + IN UINT32 Identifier, + IN PERF_MEASUREMENT_ATTRIBUTE Attribute + ); + +EDKII_PERFORMANCE_MEASUREMENT_PPI mPerformancePpi = {CreatePerformanceMeasurementPpi}; + +EFI_PEI_PPI_DESCRIPTOR mPerformancePpiDesc = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEdkiiPerformanceMeasurementPpiGuid, + &mPerformancePpi +}; /** Return the pointer to the FPDT record in the allocated memory. @param RecordSize The size of FPDT record. @@ -56,10 +94,12 @@ GetFpdtRecordPtr ( { UINT16 PeiPerformanceLogEntries; UINTN PeiPerformanceSize; UINT8 *PeiFirmwarePerformance; EFI_HOB_GUID_TYPE *GuidHob; + EFI_HOB_GUID_TYPE *FirstGuidHob; + EFI_STATUS Status; // // Get the number of PeiPerformanceLogEntries form PCD. // PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ? @@ -68,10 +108,11 @@ GetFpdtRecordPtr ( // // Create GUID HOB Data. // GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); + FirstGuidHob = GuidHob; PeiFirmwarePerformance = NULL; while (GuidHob != NULL) { // // PEI Performance HOB was found, then return the existing one. // @@ -89,10 +130,16 @@ GetFpdtRecordPtr ( // GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob)); } if (GuidHob == NULL) { + if (FirstGuidHob == NULL) { + Status = PeiServicesInstallPpi(&mPerformancePpiDesc); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "PeiCorePerformanceLib - %a - InstallPpi returned %r!\n", __FUNCTION__, Status)); + } + } // // PEI Performance HOB was not found, then build one. // PeiPerformanceSize = sizeof (FPDT_PEI_EXT_PERF_HEADER) + PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries; @@ -513,10 +560,44 @@ InsertFpdtRecord ( PeiPerformanceLogHeader->SizeOfAllEntries += FpdtRecordPtr.RecordHeader->Length; return EFI_SUCCESS; } +/** + 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. + @param String - Pointer to a string describing the measurement. + @param TimeStamp - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to the measurement. + @param Identifier - Performance identifier describing the type of measurement. + @param Attribute - The attribute of the measurement. According to attribute can create a start + record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX, + or a general record for other Perf macros. + + @retval EFI_SUCCESS - Successfully created performance record. + @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records. + @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL + pointer or invalid PerfId. +**/ +EFI_STATUS +EFIAPI +CreatePerformanceMeasurementPpi ( + IN CONST VOID *CallerIdentifier, + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 TimeStamp, + IN UINT64 Address, OPTIONAL + IN UINT32 Identifier, + IN PERF_MEASUREMENT_ATTRIBUTE Attribute + ) +{ + return InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute); + +} + /** Creates a record for the beginning of a performance measurement. If TimeStamp is zero, then this function reads the current time stamp and adds that time stamp value to the record as the start time. diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf index cad3a120a2..9b40af0738 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf @@ -52,10 +52,11 @@ [Guids] ## PRODUCES ## HOB ## CONSUMES ## HOB gEdkiiFpdtExtendedFirmwarePerformanceGuid + gEdkiiPerformanceMeasurementPpiGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries16 ## CONSUMES gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES -- 2.14.3.windows.1