From nobody Mon Sep 16 20:33:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1532934003950868.449428139838; Mon, 30 Jul 2018 00:00:03 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EC3B9210C5154; Mon, 30 Jul 2018 00:00:02 -0700 (PDT) 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) 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 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 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,421,1526367600"; d="scan'208";a="60863793" From: Dandan Bi To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Michael D Kinney , Dmitry Antipov , Star Zeng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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/M= deModulePkg/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, EITH= ER EXPRESS OR IMPLIED. #include #include #include #include #include +#include =20 #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * si= zeof (CHAR8)) #define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECOR= D) + STRING_SIZE) =20 +/** + 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 measuremen= t. + @param TimeStamp - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to t= he measurement. + @param Identifier - Performance identifier describing the type of= measurement. + @param Attribute - The attribute of the measurement. According t= o 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 - N= ULL + 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 =3D {CreatePerformanceMe= asurementPpi}; + +EFI_PEI_PPI_DESCRIPTOR mPerformancePpiDesc =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEdkiiPerformanceMeasurementPpiGuid, + &mPerformancePpi +}; =20 /** Return the pointer to the FPDT record in the allocated memory. =20 @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; =20 // // Get the number of PeiPerformanceLogEntries form PCD. // PeiPerformanceLogEntries =3D (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLog= Entries16) !=3D 0 ? @@ -68,10 +108,11 @@ GetFpdtRecordPtr ( =20 // // Create GUID HOB Data. // GuidHob =3D GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); + FirstGuidHob =3D GuidHob; PeiFirmwarePerformance =3D NULL; while (GuidHob !=3D NULL) { // // PEI Performance HOB was found, then return the existing one. // @@ -89,10 +130,16 @@ GetFpdtRecordPtr ( // GuidHob =3D GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid= , GET_NEXT_HOB (GuidHob)); } =20 if (GuidHob =3D=3D NULL) { + if (FirstGuidHob =3D=3D NULL) { + Status =3D PeiServicesInstallPpi(&mPerformancePpiDesc); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "PeiCorePerformanceLib - %a - InstallPpi retur= ned %r!\n", __FUNCTION__, Status)); + } + } // // PEI Performance HOB was not found, then build one. // PeiPerformanceSize =3D sizeof (FPDT_PEI_EXT_PERF_HEADER) + PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntri= es; @@ -513,10 +560,44 @@ InsertFpdtRecord ( PeiPerformanceLogHeader->SizeOfAllEntries +=3D FpdtRecordPtr.RecordHeade= r->Length; =20 return EFI_SUCCESS; } =20 +/** + 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 measuremen= t. + @param TimeStamp - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to t= he measurement. + @param Identifier - Performance identifier describing the type of= measurement. + @param Attribute - The attribute of the measurement. According t= o 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 - N= ULL + 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, Addr= ess, (UINT16)Identifier, Attribute); + +} + /** Creates a record for the beginning of a performance measurement. =20 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 @@ =20 [Guids] ## PRODUCES ## HOB ## CONSUMES ## HOB gEdkiiFpdtExtendedFirmwarePerformanceGuid + gEdkiiPerformanceMeasurementPpiGuid =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries ## CON= SUMES gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries16 ## CON= SUMES gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CON= SUMES --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel