From nobody Tue Apr 30 02:05:52 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 1532933970914630.3403487833467; Sun, 29 Jul 2018 23:59:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AF7A2210C5149; Sun, 29 Jul 2018 23:59:29 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 B53482098EA8C for ; Sun, 29 Jul 2018 23:59:28 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jul 2018 23:59:28 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 29 Jul 2018 23:59:27 -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=192.55.52.115; helo=mga14.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="60863778" From: Dandan Bi To: edk2-devel@lists.01.org Date: Mon, 30 Jul 2018 14:59:03 +0800 Message-Id: <20180730065905.9152-2-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 1/3] MdeModulePkg: Add the definition of performance measurement PPI 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" 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 --- MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 14 ++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 1 + 2 files changed, 15 insertions(+) diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h b/MdeModule= Pkg/Include/Guid/PerformanceMeasurement.h index 0c3eb593a0..099504c6d6 100644 --- a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h +++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h @@ -73,6 +73,20 @@ struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL { }; =20 extern EFI_GUID gEdkiiPerformanceMeasurementProtocolGuid; extern EFI_GUID gEdkiiSmmPerformanceMeasurementProtocolGuid; =20 +// +// Performance measurement PPI. +// +#define PERFORMANCE_MEASUREMENT_PPI_GUID \ + { 0x0eca9ae3, 0xa792, 0x418c, {0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59,= 0xfc } } + +typedef struct _EDKII_PERFORMANCE_MEASUREMENT_PPI EDKII_PERFORMANCE_MEASUR= EMENT_PPI; + +struct _EDKII_PERFORMANCE_MEASUREMENT_PPI { + CREATE_PERFORMANCE_MEASUREMENT CreatePerformanceMeasurementPpi; +}; + +extern EFI_GUID gEdkiiPerformanceMeasurementPpiGuid; + #endif // _PERFORMANCE_MEASUREMENT_H_ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 6a6d9660ed..3db97f536e 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -261,10 +261,11 @@ gPerformanceExProtocolGuid =3D { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2,= 0x1, 0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } } gSmmPerformanceExProtocolGuid =3D { 0x931fc048, 0xc71d, 0x4455, { 0x89,= 0x30, 0x47, 0x6, 0x30, 0xe3, 0xe, 0xe5 } } # Include/Guid/PerformanceMeasurement.h gEdkiiPerformanceMeasurementProtocolGuid =3D { 0xc85d06be, 0x5f75, = 0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } } gEdkiiSmmPerformanceMeasurementProtocolGuid =3D { 0xd56b6d73, 0x1a7b, = 0x4015, { 0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 0x24 } } + gEdkiiPerformanceMeasurementPpiGuid =3D { 0x0eca9ae3, 0xa792, = 0x418c, { 0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59, 0xfc } } =20 ## Guid is defined for CRC32 encapsulation scheme. # Include/Guid/Crc32GuidedSectionExtraction.h gEfiCrc32GuidedSectionExtractionGuid =3D { 0xFC1BCDB0, 0x7D31, 0x49aa, {= 0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } } =20 --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue Apr 30 02:05:52 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 From nobody Tue Apr 30 02:05:52 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 1532934005332820.0756990790865; Mon, 30 Jul 2018 00:00:05 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 28085210C5158; Mon, 30 Jul 2018 00:00:03 -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 DF436210C4DA1 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:55 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 29 Jul 2018 23:59:34 -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="60863811" From: Dandan Bi To: edk2-devel@lists.01.org Date: Mon, 30 Jul 2018 14:59:05 +0800 Message-Id: <20180730065905.9152-4-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 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib 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" Add a new "thin" PerformanceLib instance PeiPerformancePpiLib which will locate a Performance measurement Ppi to log performance data. Platform can link the "thin" PeiPerformancePpiLib to log the performance data for PEIMs. It also can link the PeiPerformanceLib in PEI phase to keep the compatibility. 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 --- .../PeiPerformancePpiLib/PeiPerformancePpiLib.c | 420 +++++++++++++++++= ++++ .../PeiPerformancePpiLib/PeiPerformancePpiLib.inf | 49 +++ .../PeiPerformancePpiLib/PeiPerformancePpiLib.uni | 23 ++ MdeModulePkg/MdeModulePkg.dsc | 1 + 4 files changed, 493 insertions(+) create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformanc= ePpiLib.c create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformanc= ePpiLib.inf create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformanc= ePpiLib.uni diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib= .c b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c new file mode 100644 index 0000000000..e1ac6b6b61 --- /dev/null +++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c @@ -0,0 +1,420 @@ +/** @file +Performance library instance used for PEIMs + +This library provides the performance measurement interfaces in PEI phase,= It locates +performance measurement PPI to log the performance data. + +Copyright (c) 2018, Intel Corporation. All rights reserved.
+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 + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. + +**/ + +#include + +#include + +#include +#include +#include +#include + +/** + Create performance record with event description and a timestamp. + This function locates the Performance PPI and calls it with the same par= ameters. + + @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. +**/ +RETURN_STATUS +CreatePerformanceMeasurement ( + IN CONST VOID *CallerIdentifier, OPTIONAL + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 TimeStamp,OPTIONAL + IN UINT64 Address, OPTIONAL + IN UINT32 Identifier, + IN PERF_MEASUREMENT_ATTRIBUTE Attribute + ) +{ + EFI_STATUS Status; + EDKII_PERFORMANCE_MEASUREMENT_PPI *PerformancePpi; + + Status =3D PeiServicesLocatePpi ( + &gEdkiiPerformanceMeasurementPpiGuid, + 0, + NULL, + (VOID **) &PerformancePpi + ); + + if (!EFI_ERROR(Status)) { + return (RETURN_STATUS) PerformancePpi->CreatePerformanceMeasurementPpi= (CallerIdentifier, Guid, String, TimeStamp, Address, Identifier, Attribute); + } else { + return RETURN_NOT_READY; + } +} + +/** + 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. + + If TimeStamp is one, then this function reads 0 as the start time. + + If TimeStamp is other value, then TimeStamp is added to the record as th= e start time. + + @param Handle Pointer to environment specific context = used + to identify the component being measured. + @param Token Pointer to a Null-terminated ASCII string + that identifies the component being meas= ured. + @param Module Pointer to a Null-terminated ASCII string + that identifies the module being measure= d. + @param TimeStamp 64-bit time stamp. + @param Identifier 32-bit identifier. If the value is 0, th= e created record + is same as the one created by StartPerfo= rmanceMeasurement. + + @retval RETURN_SUCCESS The start of the measurement was recorde= d. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record= the measurement. + +**/ +RETURN_STATUS +EFIAPI +StartPerformanceMeasurementEx ( + IN CONST VOID *Handle, OPTIONAL + IN CONST CHAR8 *Token, OPTIONAL + IN CONST CHAR8 *Module, OPTIONAL + IN UINT64 TimeStamp, + IN UINT32 Identifier + ) +{ + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0,= Identifier, PerfStartEntry); + +} + +/** + + Creates a record for the end of a performance measurement. + + If the TimeStamp is not zero or one, then TimeStamp is added to the reco= rd as the end time. + If the TimeStamp is zero, then this function reads the current time stam= p and adds that time stamp value to the record as the end time. + If the TimeStamp is one, then this function reads 0 as the end time. + + @param Handle Pointer to environment specific context = used + to identify the component being measured. + @param Token Pointer to a Null-terminated ASCII string + that identifies the component being meas= ured. + @param Module Pointer to a Null-terminated ASCII string + that identifies the module being measure= d. + @param TimeStamp 64-bit time stamp. + @param Identifier 32-bit identifier. If the value is 0, th= e found record + is same as the one found by EndPerforman= ceMeasurement. + + @retval RETURN_SUCCESS The end of the measurement was recorded. + @retval RETURN_NOT_FOUND The specified measurement record could n= ot be found. + +**/ +RETURN_STATUS +EFIAPI +EndPerformanceMeasurementEx ( + IN CONST VOID *Handle, OPTIONAL + IN CONST CHAR8 *Token, OPTIONAL + IN CONST CHAR8 *Module, OPTIONAL + IN UINT64 TimeStamp, + IN UINT32 Identifier + ) +{ + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0,= Identifier, PerfEndEntry); +} + +/** + Attempts to retrieve a performance measurement log entry from the perfor= mance measurement log. + It can also retrieve the log created by StartPerformanceMeasurement and = EndPerformanceMeasurement, + and then assign the Identifier with 0. + + Attempts to retrieve the performance log entry specified by LogEntryKey.= If LogEntryKey is + zero on entry, then an attempt is made to retrieve the first entry from = the performance log, + and the key for the second entry in the log is returned. If the perform= ance log is empty, + then no entry is retrieved and zero is returned. If LogEntryKey is not = zero, then the performance + log entry associated with LogEntryKey is retrieved, and the key for the = next entry in the log is + returned. If LogEntryKey is the key for the last entry in the log, then= the last log entry is + retrieved and an implementation specific non-zero key value that specifi= es the end of the performance + log is returned. If LogEntryKey is equal this implementation specific n= on-zero key value, then no entry + is retrieved and zero is returned. In the cases where a performance log= entry can be returned, + the log entry is returned in Handle, Token, Module, StartTimeStamp, EndT= imeStamp and Identifier. + If LogEntryKey is not a valid log entry key for the performance measurem= ent log, then ASSERT(). + If Handle is NULL, then ASSERT(). + If Token is NULL, then ASSERT(). + If Module is NULL, then ASSERT(). + If StartTimeStamp is NULL, then ASSERT(). + If EndTimeStamp is NULL, then ASSERT(). + If Identifier is NULL, then ASSERT(). + + !!!NOT Support yet!!! + + @param LogEntryKey On entry, the key of the performance mea= surement log entry to retrieve. + 0, then the first performance measuremen= t log entry is retrieved. + On exit, the key of the next performance= of entry entry. + @param Handle Pointer to environment specific context = used to identify the component + being measured. + @param Token Pointer to a Null-terminated ASCII strin= g that identifies the component + being measured. + @param Module Pointer to a Null-terminated ASCII strin= g that identifies the module + being measured. + @param StartTimeStamp Pointer to the 64-bit time stamp that wa= s recorded when the measurement + was started. + @param EndTimeStamp Pointer to the 64-bit time stamp that wa= s recorded when the measurement + was ended. + @param Identifier Pointer to the 32-bit identifier that wa= s recorded. + + @return The key for the next performance log entry (in general case). + +**/ +UINTN +EFIAPI +GetPerformanceMeasurementEx ( + IN UINTN LogEntryKey, + OUT CONST VOID **Handle, + OUT CONST CHAR8 **Token, + OUT CONST CHAR8 **Module, + OUT UINT64 *StartTimeStamp, + OUT UINT64 *EndTimeStamp, + OUT UINT32 *Identifier + ) +{ + return 0; +} + +/** + 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. + + If TimeStamp is one, then this function reads 0 as the start time. + + If TimeStamp is other value, then TimeStamp is added to the record as th= e start time. + + @param Handle Pointer to environment specific context = used + to identify the component being measured. + @param Token Pointer to a Null-terminated ASCII string + that identifies the component being meas= ured. + @param Module Pointer to a Null-terminated ASCII string + that identifies the module being measure= d. + @param TimeStamp 64-bit time stamp. + + @retval RETURN_SUCCESS The start of the measurement was recorde= d. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record= the measurement. + +**/ +RETURN_STATUS +EFIAPI +StartPerformanceMeasurement ( + IN CONST VOID *Handle, OPTIONAL + IN CONST CHAR8 *Token, OPTIONAL + IN CONST CHAR8 *Module, OPTIONAL + IN UINT64 TimeStamp + ) +{ + return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, = 0); +} + +/** + + Creates a record for the end of a performance measurement. + + If the TimeStamp is not zero or one, then TimeStamp is added to the reco= rd as the end time. + If the TimeStamp is zero, then this function reads the current time stam= p and adds that time stamp value to the record as the end time. + If the TimeStamp is one, then this function reads 0 as the end time. + + @param Handle Pointer to environment specific context = used + to identify the component being measured. + @param Token Pointer to a Null-terminated ASCII string + that identifies the component being meas= ured. + @param Module Pointer to a Null-terminated ASCII string + that identifies the module being measure= d. + @param TimeStamp 64-bit time stamp. + + @retval RETURN_SUCCESS The end of the measurement was recorded. + @retval RETURN_NOT_FOUND The specified measurement record could n= ot be found. + +**/ +RETURN_STATUS +EFIAPI +EndPerformanceMeasurement ( + IN CONST VOID *Handle, OPTIONAL + IN CONST CHAR8 *Token, OPTIONAL + IN CONST CHAR8 *Module, OPTIONAL + IN UINT64 TimeStamp + ) +{ + return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0); +} + +/** + Attempts to retrieve a performance measurement log entry from the perfor= mance measurement log. + It can also retrieve the log created by StartPerformanceMeasurementEx an= d EndPerformanceMeasurementEx, + and then eliminate the Identifier. + + Attempts to retrieve the performance log entry specified by LogEntryKey.= If LogEntryKey is + zero on entry, then an attempt is made to retrieve the first entry from = the performance log, + and the key for the second entry in the log is returned. If the perform= ance log is empty, + then no entry is retrieved and zero is returned. If LogEntryKey is not = zero, then the performance + log entry associated with LogEntryKey is retrieved, and the key for the = next entry in the log is + returned. If LogEntryKey is the key for the last entry in the log, then= the last log entry is + retrieved and an implementation specific non-zero key value that specifi= es the end of the performance + log is returned. If LogEntryKey is equal this implementation specific n= on-zero key value, then no entry + is retrieved and zero is returned. In the cases where a performance log= entry can be returned, + the log entry is returned in Handle, Token, Module, StartTimeStamp, and = EndTimeStamp. + If LogEntryKey is not a valid log entry key for the performance measurem= ent log, then ASSERT(). + If Handle is NULL, then ASSERT(). + If Token is NULL, then ASSERT(). + If Module is NULL, then ASSERT(). + If StartTimeStamp is NULL, then ASSERT(). + If EndTimeStamp is NULL, then ASSERT(). + + NOT Support yet. + + @param LogEntryKey On entry, the key of the performance mea= surement log entry to retrieve. + 0, then the first performance measuremen= t log entry is retrieved. + On exit, the key of the next performance= of entry entry. + @param Handle Pointer to environment specific context = used to identify the component + being measured. + @param Token Pointer to a Null-terminated ASCII strin= g that identifies the component + being measured. + @param Module Pointer to a Null-terminated ASCII strin= g that identifies the module + being measured. + @param StartTimeStamp Pointer to the 64-bit time stamp that wa= s recorded when the measurement + was started. + @param EndTimeStamp Pointer to the 64-bit time stamp that wa= s recorded when the measurement + was ended. + + @return The key for the next performance log entry (in general case). + +**/ +UINTN +EFIAPI +GetPerformanceMeasurement ( + IN UINTN LogEntryKey, + OUT CONST VOID **Handle, + OUT CONST CHAR8 **Token, + OUT CONST CHAR8 **Module, + OUT UINT64 *StartTimeStamp, + OUT UINT64 *EndTimeStamp + ) +{ + return 0; +} + +/** + Returns TRUE if the performance measurement macros are enabled. + + This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREME= NT_ENABLED bit of + PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASURE= MENT_ENABLED bit of + PcdPerformanceLibraryPropertyMask is set. + @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASURE= MENT_ENABLED bit of + PcdPerformanceLibraryPropertyMask is cle= ar. + +**/ +BOOLEAN +EFIAPI +PerformanceMeasurementEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMA= NCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D 0); +} + +/** + 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 Address - Pointer to a location in memory relevant to t= he measurement + @param Identifier - Performance identifier describing the type of= measurement + + @retval RETURN_SUCCESS - Successfully created performance reco= rd + @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records + @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function = - NULL + pointer or invalid PerfId + +**/ +RETURN_STATUS +EFIAPI +LogPerformanceMeasurement ( + IN CONST VOID *CallerIdentifier, + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 Address, OPTIONAL + IN UINT32 Identifier + ) +{ + return (RETURN_STATUS)CreatePerformanceMeasurement (CallerIdentifier, Gu= id, String, 0, Address, (UINT16)Identifier, PerfEntry); +} + +/** + Check whether the specified performance measurement can be logged. + + This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASURE= MENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set + and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set. + + @param Type - Type of the performance measurement entry. + + @retval TRUE The performance measurement can be logged. + @retval FALSE The performance measurement can NOT be logged. + +**/ +BOOLEAN +EFIAPI +LogPerformanceMeasurementEnabled ( + IN CONST UINTN Type + ) +{ + // + // When Performance measurement is enabled and the type is not filtered,= the performance can be logged. + // + if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPr= opertyMask) & Type) =3D=3D 0) { + return TRUE; + } + return FALSE; +} diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib= .inf b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf new file mode 100644 index 0000000000..c1e2599453 --- /dev/null +++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf @@ -0,0 +1,49 @@ +## @file +# Performance library instance used for PEIMs. +# +# This library provides the performance measurement interfaces in PEI pha= se, it locates +# performance measurement PPI to log the performance data. +# +# Copyright (c) 2018, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiPerformancePpiLib + MODULE_UNI_FILE =3D PeiPerformancePpiLib.uni + FILE_GUID =3D 9B94A34B-7B29-4358-9AB1-09960806FB9A + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PerformanceLib|PEIM SEC + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC (EBC is for build only) +# + +[Sources] + PeiPerformancePpiLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + PcdLib + DebugLib + PeiServicesLib + +[Guids] + gEdkiiPerformanceMeasurementPpiGuid + +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CO= NSUMES diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib= .uni b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni new file mode 100644 index 0000000000..081f3767e1 --- /dev/null +++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni @@ -0,0 +1,23 @@ +// /** @file +// Performance library instance used for PEIMs. +// +// This library provides the performance measurement interfaces in PEI pha= se, it locates +// performance measurement PPI to log the performance data. +// +// Copyright (c) 2018, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Performance libra= ry instance used for PEIMs" + +#string STR_MODULE_DESCRIPTION #language en-US "This library prov= ides the performance measurement interfaces in the PEI phase, it locates pe= rformance measurement PPI to log the performance data." + diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index bb7744894a..ef7b46fedc 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -288,10 +288,11 @@ MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol= .inf MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSecti= onExtractLib.inf MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf + MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel