From nobody Sat Dec 21 14:37:02 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 1529657811002935.1392025201172; Fri, 22 Jun 2018 01:56:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C1B4E210D226C; Fri, 22 Jun 2018 01:56:49 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 DB08F210C4DC7 for ; Fri, 22 Jun 2018 01:56:48 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:56:39 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:56:38 -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.88; helo=mga01.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,256,1526367600"; d="scan'208";a="65390299" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:15 +0800 Message-Id: <20180622085623.154924-2-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 1/9] MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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 PerformanceMeasurement protocol to log performance info. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 91 ++++++++++++++++++= ++++ MdeModulePkg/MdeModulePkg.dec | 3 + 2 files changed, 94 insertions(+) create mode 100644 MdeModulePkg/Include/Guid/PerformanceMeasurement.h diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h b/MdeModule= Pkg/Include/Guid/PerformanceMeasurement.h new file mode 100644 index 00000000000..f2955c73589 --- /dev/null +++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h @@ -0,0 +1,91 @@ +/** @file + +Copyright (c) 2017, Microsoft Corporation +Copyright (c) 2018, Intel Corporation. All rights reserved.
+ +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notic= e, +this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS= " AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPL= IED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS= CLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY D= IRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUD= ING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF U= SE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEO= RY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLI= GENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Performance measurement protocol, allows logging performance data. + +**/ + +#ifndef _PERFORMANCE_MEASUREMENT_H_ +#define _PERFORMANCE_MEASUREMENT_H_ + +// +// GUID for Performance measurement Protocol +// +#define PERFORMANCE_MEASUREMENT_PROTOCOL_GUID \ + { 0xc85d06be, 0x5f75, 0x48ce, {0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87,= 0xb1 } } + +#define SMM_PERFORMANCE_MEASUREMENT_PROTOCOL_GUID \ + { 0xd56b6d73, 0x1a7b, 0x4015, {0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed,= 0x24 } } + +typedef struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL EDKII_PERFORMANCE_M= EASUREMENT_PROTOCOL; + +typedef enum { + PerfStartEntry, // used in StartPerformanceMeasur= ement()/StartPerformanceMeasurementEx() + // (map to PERF_START/PERF_START_= EX) + PerfEndEntry, // used in EndPerformanceMeasurem= ent()/EndPerformanceMeasurementEx() + // (map to PERF_END/PERF_END_EX) + PerfEntry // used in LogPerformanceMeasurem= ent() + // (map to other Perf macros exce= pt above 4 macros) +} PERF_MEASUREMENT_ATTRIBUTE; + +/** + 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. + +**/ +typedef +EFI_STATUS +(EFIAPI *CREATE_PERFORMANCE_MEASUREMENT)( + 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 + ); + +struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL { + CREATE_PERFORMANCE_MEASUREMENT CreatePerformanceMeasurement; +}; + +extern EFI_GUID gEdkiiPerformanceMeasurementProtocolGuid; +extern EFI_GUID gEdkiiSmmPerformanceMeasurementProtocolGuid; + +#endif // _PERFORMANCE_MEASUREMENT_H_ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 3802b6e0b86..108accc2c29 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -258,10 +258,13 @@ # Include/Guid/Performance.h gPerformanceProtocolGuid =3D { 0x76B6BDFA, 0x2ACD, 0x4462, { 0x9E,= 0x3F, 0xCB, 0x58, 0xC9, 0x69, 0xD9, 0x37 } } gSmmPerformanceProtocolGuid =3D { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9,= 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } } 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 } } =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 Sat Dec 21 14:37:02 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 1529657809453386.4115073347633; Fri, 22 Jun 2018 01:56:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 972FF210D1EF6; Fri, 22 Jun 2018 01:56:48 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 8B64E210C4DC7 for ; Fri, 22 Jun 2018 01:56:46 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:56:46 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:56:45 -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.43; helo=mga05.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,256,1526367600"; d="scan'208";a="65390314" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:16 +0800 Message-Id: <20180622085623.154924-3-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 2/9] MdeModulePkg: Update Performance instances to use new protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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" Update Performance instances in MdeModulePkg to use new PerformanceMeasurement protocol. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 325 +++++------------= --- .../DxeCorePerformanceLib.inf | 6 +- .../DxeCorePerformanceLibInternal.h | 216 ++------------ .../Library/DxePerformanceLib/DxePerformanceLib.c | 125 +++----- .../DxePerformanceLib/DxePerformanceLib.inf | 5 +- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 327 +++++------------= ---- .../SmmCorePerformanceLib.inf | 7 +- .../SmmCorePerformanceLibInternal.h | 215 ++------------ .../Library/SmmPerformanceLib/SmmPerformanceLib.c | 130 +++----- .../SmmPerformanceLib/SmmPerformanceLib.inf | 5 +- 10 files changed, 283 insertions(+), 1078 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceL= ib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 68b29ac5a9e..79820605184 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -80,25 +80,14 @@ UINT8 *mBootRecordBuffer =3D NULL; BOOLEAN mLockInsertRecord =3D FALSE; =20 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText =3D NULL; =20 // -// Interfaces for Performance Protocol. +// Interfaces for PerformanceMeasurement Protocol. // -PERFORMANCE_PROTOCOL mPerformanceInterface =3D { - StartGauge, - EndGauge, - GetGauge - }; - -// -// Interfaces for PerformanceEx Protocol. -// -PERFORMANCE_EX_PROTOCOL mPerformanceExInterface =3D { - StartGaugeEx, - EndGaugeEx, - GetGaugeEx +EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = =3D { + CreatePerformanceMeasurement, }; =20 PERFORMANCE_PROPERTY mPerformanceProperty; =20 /** @@ -797,22 +786,15 @@ InsertFpdtMeasurement ( =20 StringPtr =3D NULL; UseModuleName =3D FALSE; ZeroMem (ModuleName, sizeof (ModuleName)); =20 - if (mLockInsertRecord) { - return EFI_UNSUPPORTED; - } - - mLockInsertRecord =3D TRUE; - // // Get record info (type, size, ProgressID and Module Guid). // Status =3D GetFpdtRecordInfo (IsStart, Handle, Token, Module, &RecordInf= o, &UseModuleName); if (EFI_ERROR (Status)) { - mLockInsertRecord =3D FALSE; return Status; } =20 // // If PERF_START()/PERF_END() have specified the ProgressID,it has high = priority. @@ -822,11 +804,10 @@ InsertFpdtMeasurement ( // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. // if ((Identifier !=3D 0) && (IsKnownID (Identifier)) && (!IsKnownTokens (= Token))) { - mLockInsertRecord =3D FALSE; return EFI_UNSUPPORTED; } else if ((Identifier !=3D 0) && (!IsKnownID (Identifier)) && (!IsKnown= Tokens (Token))) { if (IsStart && ((Identifier & 0x000F) !=3D 0)) { Identifier &=3D 0xFFF0; } else if ((!IsStart) && ((Identifier & 0x000F) =3D=3D 0)) { @@ -842,11 +823,10 @@ InsertFpdtMeasurement ( if (mBootRecordSize + RecordInfo.RecordSize > mBootRecordMaxSize) { if (!mLackSpaceIsReported) { DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to sav= e boot records\n")); mLackSpaceIsReported =3D TRUE; } - mLockInsertRecord =3D FALSE; return EFI_OUT_OF_RESOURCES; } else { // // Save boot record into BootPerformance table // @@ -864,11 +844,10 @@ InsertFpdtMeasurement ( mPerformanceLength + RecordInfo.RecordSize += FIRMWARE_RECORD_BUFFER, mPerformancePointer ); =20 if (mPerformancePointer =3D=3D NULL) { - mLockInsertRecord =3D FALSE; return EFI_OUT_OF_RESOURCES; } mMaxPerformanceLength =3D mPerformanceLength + RecordInfo.RecordSize= + FIRMWARE_RECORD_BUFFER; } // @@ -961,15 +940,13 @@ InsertFpdtMeasurement ( =20 default: // // Record is not supported in current DXE phase, return EFI_ABORTED // - mLockInsertRecord =3D FALSE; return EFI_UNSUPPORTED; } =20 - mLockInsertRecord =3D FALSE; return EFI_SUCCESS; } =20 /** Dumps all the PEI performance. @@ -1061,223 +1038,10 @@ ReportFpdtRecordBuffer ( // mFpdtBufferIsReported =3D TRUE; } } =20 -/** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, Module and Identifier. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 StartGauge= of PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier - ) -{ - return InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, Id= entifier); -} - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, Module and Identifier a= nd has an end time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EndGauge of = PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier - ) -{ - return InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, I= dentifier); -} - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGauge and EndGauge of PERFO= RMANCE_PROTOCOL, - and then assign the Identifier with 0. - - !!! Not support!!! - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntryEx stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntryEx The indirect pointer to the extended gau= ge data entry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntryEx is successfully fou= nd based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGaugeEx ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, and Module. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ) -{ - return StartGaugeEx (Handle, Token, Module, TimeStamp, 0); -} - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, and Module and has an e= nd time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ) -{ - return EndGaugeEx (Handle, Token, Module, TimeStamp, 0); -} - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGaugeEx and EndGaugeEx of P= ERFORMANCE_EX_PROTOCOL, - and then eliminate the Identifier. - - !!! Not support!!! - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntry stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntry The indirect pointer to the gauge data e= ntry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntry is successfully found= based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGauge ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY **GaugeDataEntry - ) -{ - return EFI_UNSUPPORTED; -} - - /** The constructor function initializes Performance infrastructure for DXE = phase. =20 The constructor function publishes Performance and PerformanceEx protoco= l, allocates memory to log DXE performance and merges PEI performance data to DXE performance log. @@ -1317,14 +1081,12 @@ DxeCorePerformanceLibConstructor ( // Install the protocol interfaces for DXE performance library instance. // Handle =3D NULL; Status =3D gBS->InstallMultipleProtocolInterfaces ( &Handle, - &gPerformanceProtocolGuid, - &mPerformanceInterface, - &gPerformanceExProtocolGuid, - &mPerformanceExInterface, + &gEdkiiPerformanceMeasurementProtocolGuid, + &mPerformanceMeasurementInterface, NULL ); ASSERT_EFI_ERROR (Status); =20 // @@ -1357,10 +1119,59 @@ DxeCorePerformanceLibConstructor ( } =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 +CreatePerformanceMeasurement ( + 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 + ) +{ + EFI_STATUS Status; + + Status =3D EFI_SUCCESS; + + if (mLockInsertRecord) { + return EFI_INVALID_PARAMETER; + } + mLockInsertRecord =3D TRUE; + + if (Attribute =3D=3D PerfStartEntry) { + Status =3D InsertFpdtMeasurement (TRUE, CallerIdentifier, String, Stri= ng, TimeStamp, Identifier); + } else if (Attribute =3D=3D PerfEndEntry) { + Status =3D InsertFpdtMeasurement (FALSE, CallerIdentifier, String, Str= ing, TimeStamp, Identifier); + } + mLockInsertRecord =3D FALSE; + + return Status; +} + /** Adds a record at the end of the performance measurement log that records the start time of a performance measurement. =20 Adds a record to the end of the performance measurement log @@ -1392,11 +1203,21 @@ StartPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - return InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, Id= entifier); + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String= , TimeStamp, 0, Identifier, PerfStartEntry); } =20 /** Searches the performance measurement log from the beginning of the log for the first matching record that contains a zero end time and fills in= a valid end time. @@ -1431,11 +1252,21 @@ EndPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - return InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, I= dentifier); + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String= , TimeStamp, 0, Identifier, PerfEndEntry); } =20 /** 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, @@ -1525,11 +1356,11 @@ StartPerformanceMeasurement ( IN CONST CHAR8 *Token, OPTIONAL IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp ) { - return InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, 0); + return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, = 0); } =20 /** Searches the performance measurement log from the beginning of the log for the first matching record that contains a zero end time and fills in= a valid end time. @@ -1561,11 +1392,11 @@ EndPerformanceMeasurement ( IN CONST CHAR8 *Token, OPTIONAL IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp ) { - return InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, 0= ); + return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0); } =20 /** 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, diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceL= ib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.i= nf index e752a93d837..68cd76da5b3 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf @@ -65,22 +65,18 @@ [Protocols] gEfiSmmCommunicationProtocolGuid ## SOMETIMES_CONSUMES =20 =20 [Guids] - ## SOMETIMES_CONSUMES ## HOB - ## PRODUCES ## UNDEFINED # Install protocol ## PRODUCES ## SystemTable gPerformanceProtocolGuid - ## SOMETIMES_CONSUMES ## HOB - ## PRODUCES ## UNDEFINED # Install protocol - gPerformanceExProtocolGuid gZeroGuid ## SOMETIMES_CONSUMES ## G= UID gEfiFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## U= NDEFINED # StatusCode Data gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_CONSUMES ## H= OB # StatusCode Data gEfiEventReadyToBootGuid ## CONSUMES ## E= vent gEdkiiPiSmmCommunicationRegionTableGuid ## SOMETIMES_CONSUMES #= # SystemTable + gEdkiiPerformanceMeasurementProtocolGuid ## PRODUCES ## U= NDEFINED # Install protocol =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CO= NSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly ## CO= NSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize ## CO= NSUMES diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceL= ibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanc= eLibInternal.h index 7e79675f940..f9800e34941 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInter= nal.h +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInter= nal.h @@ -20,10 +20,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 =20 #include =20 #include +#include #include #include #include #include #include @@ -47,203 +48,36 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EIT= HER EXPRESS OR IMPLIED. #include #include #include #include =20 -// -// Interface declarations for PerformanceEx Protocol. -// /** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, Module and Identifier. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 StartGauge= of PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier - ); - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, Module and Identifier a= nd has an end time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EndGauge of = PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - + 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 -EndGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier +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 ); =20 -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGauge and EndGauge of PERFO= RMANCE_PROTOCOL, - and then assign the Identifier with 0. - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntryEx stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntryEx The indirect pointer to the extended gau= ge data entry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntryEx is successfully fou= nd based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGaugeEx ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx - ); - -// -// Interface declarations for Performance Protocol. -// -/** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, and Module. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ); - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, and Module and has an e= nd time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ); - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGaugeEx and EndGaugeEx of P= ERFORMANCE_EX_PROTOCOL, - and then eliminate the Identifier. - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntry stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntry The indirect pointer to the gauge data e= ntry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntry is successfully found= based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGauge ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY **GaugeDataEntry - ); - - #endif diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/M= deModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c index cb62d522f3d..9ed50d22b8d 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c @@ -18,22 +18,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. **/ =20 =20 #include =20 -#include +#include =20 #include #include #include #include =20 // // The cached Performance Protocol and PerformanceEx Protocol interface. // -PERFORMANCE_PROTOCOL *mPerformance =3D NULL; -PERFORMANCE_EX_PROTOCOL *mPerformanceEx =3D NULL; +EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement =3D N= ULL; =20 /** The function caches the pointers to PerformanceEx protocol and Performan= ce Protocol. =20 The function locates PerformanceEx protocol and Performance Protocol fro= m protocol database. @@ -41,39 +40,28 @@ PERFORMANCE_EX_PROTOCOL *mPerformanceEx =3D NULL; @retval EFI_SUCCESS PerformanceEx protocol or Performance Protocol i= s successfully located. @retval EFI_NOT_FOUND Both PerformanceEx protocol and Performance Prot= ocol are not located to log performance. =20 **/ EFI_STATUS -GetPerformanceProtocol ( +GetPerformanceMeasurementProtocol ( VOID ) { EFI_STATUS Status; - PERFORMANCE_PROTOCOL *Performance; - PERFORMANCE_EX_PROTOCOL *PerformanceEx; + EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement; =20 - if (mPerformanceEx !=3D NULL || mPerformance !=3D NULL) { + if (mPerformanceMeasurement !=3D NULL) { return EFI_SUCCESS; } =20 - Status =3D gBS->LocateProtocol (&gPerformanceExProtocolGuid, NULL, (VOID= **) &PerformanceEx); + Status =3D gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGui= d, NULL, (VOID **) &PerformanceMeasurement); if (!EFI_ERROR (Status)) { - ASSERT (PerformanceEx !=3D NULL); + ASSERT (PerformanceMeasurement !=3D NULL); // - // Cache PerformanceEx Protocol. + // Cache PerformanceMeasurement Protocol. // - mPerformanceEx =3D PerformanceEx; - return EFI_SUCCESS; - } - - Status =3D gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID *= *) &Performance); - if (!EFI_ERROR (Status)) { - ASSERT (Performance !=3D NULL); - // - // Cache performance protocol. - // - mPerformance =3D Performance; + mPerformanceMeasurement =3D PerformanceMeasurement; return EFI_SUCCESS; } =20 return EFI_NOT_FOUND; } @@ -108,21 +96,28 @@ StartPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - EFI_STATUS Status; + EFI_STATUS Status; + CONST CHAR8* String; =20 - Status =3D GetPerformanceProtocol (); + Status =3D GetPerformanceMeasurementProtocol (); if (EFI_ERROR (Status)) { - return RETURN_OUT_OF_RESOURCES; + return RETURN_NOT_FOUND; + } + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; } =20 - if (mPerformanceEx !=3D NULL) { - Status =3D mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeSt= amp, Identifier); - } else if (mPerformance !=3D NULL) { - Status =3D mPerformance->StartGauge (Handle, Token, Module, TimeStamp); + if (mPerformanceMeasurement !=3D NULL) { + Status =3D mPerformanceMeasurement->CreatePerformanceMeasurement (Hand= le, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry); } else { ASSERT (FALSE); } =20 return (RETURN_STATUS) Status; @@ -160,21 +155,28 @@ EndPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - EFI_STATUS Status; + EFI_STATUS Status; + CONST CHAR8* String; =20 - Status =3D GetPerformanceProtocol (); + Status =3D GetPerformanceMeasurementProtocol (); if (EFI_ERROR (Status)) { return RETURN_NOT_FOUND; } =20 - if (mPerformanceEx !=3D NULL) { - Status =3D mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStam= p, Identifier); - } else if (mPerformance !=3D NULL) { - Status =3D mPerformance->EndGauge (Handle, Token, Module, TimeStamp); + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + if (mPerformanceMeasurement !=3D NULL) { + Status =3D mPerformanceMeasurement->CreatePerformanceMeasurement (Hand= le, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry); } else { ASSERT (FALSE); } =20 return (RETURN_STATUS) Status; @@ -231,62 +233,12 @@ GetPerformanceMeasurementEx ( OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp, OUT UINT32 *Identifier ) { - EFI_STATUS Status; - GAUGE_DATA_ENTRY_EX *GaugeData; - - GaugeData =3D NULL; - - ASSERT (Handle !=3D NULL); - ASSERT (Token !=3D NULL); - ASSERT (Module !=3D NULL); - ASSERT (StartTimeStamp !=3D NULL); - ASSERT (EndTimeStamp !=3D NULL); - ASSERT (Identifier !=3D NULL); - - Status =3D GetPerformanceProtocol (); - if (EFI_ERROR (Status)) { - return 0; - } - - if (mPerformanceEx !=3D NULL) { - Status =3D mPerformanceEx->GetGaugeEx (LogEntryKey++, &GaugeData); - } else if (mPerformance !=3D NULL) { - Status =3D mPerformance->GetGauge (LogEntryKey++, (GAUGE_DATA_ENTRY **= ) &GaugeData); - } else { - ASSERT (FALSE); - return 0; - } - - // - // Make sure that LogEntryKey is a valid log entry key, - // - ASSERT (Status !=3D EFI_INVALID_PARAMETER); - - if (EFI_ERROR (Status)) { - // - // The LogEntryKey is the last entry (equals to the total entry number= ). - // - return 0; - } - - ASSERT (GaugeData !=3D NULL); - - *Handle =3D (VOID *) (UINTN) GaugeData->Handle; - *Token =3D GaugeData->Token; - *Module =3D GaugeData->Module; - *StartTimeStamp =3D GaugeData->StartTimeStamp; - *EndTimeStamp =3D GaugeData->EndTimeStamp; - if (mPerformanceEx !=3D NULL) { - *Identifier =3D GaugeData->Identifier; - } else { - *Identifier =3D 0; - } + return 0; =20 - return LogEntryKey; } =20 /** Creates a record for the beginning of a performance measurement. =20 @@ -401,12 +353,11 @@ GetPerformanceMeasurement ( OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp ) { - UINT32 Identifier; - return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, = StartTimeStamp, EndTimeStamp, &Identifier); + return 0; } =20 /** Returns TRUE if the performance measurement macros are enabled. =20 diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf b= /MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf index edc63c6f0b6..c7d06a3a1b1 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf @@ -4,11 +4,11 @@ # This library instance provides infrastructure for DXE phase drivers to = log performance # data. It consumes PerformanceEx or Performance Protocol published by Dx= eCorePerformanceLib # to log performance data. If both PerformanceEx and Performance Protocol= are not available, # it does not log any performance information. # =20 -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 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 # =20 @@ -46,12 +46,11 @@ UefiBootServicesTableLib DebugLib =20 =20 [Guids] - gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Loc= ate protocol - gPerformanceExProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Loc= ate protocol + gEdkiiPerformanceMeasurementProtocolGuid ## SOMETIMES_CONSUMES ## U= NDEFINED # Locate protocol =20 =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES =20 diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL= ib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index dbc1166f254..e630773562f 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -52,25 +52,14 @@ BOOLEAN mLackSpaceIsReport =3D FALSE; CHAR8 *mPlatformLanguage =3D NULL; SPIN_LOCK mSmmFpdtLock; PERFORMANCE_PROPERTY mPerformanceProperty; =20 // -// Interfaces for SMM Performance Protocol. +// Interfaces for SMM PerformanceMeasurement Protocol. // -PERFORMANCE_PROTOCOL mPerformanceInterface =3D { - StartGauge, - EndGauge, - GetGauge -}; - -// -// Interfaces for SMM PerformanceEx Protocol. -// -PERFORMANCE_EX_PROTOCOL mPerformanceExInterface =3D { - StartGaugeEx, - EndGaugeEx, - GetGaugeEx +EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = =3D { + CreatePerformanceMeasurement, }; =20 /** Check whether the Token is a known one which is uesed by core. =20 @@ -641,239 +630,10 @@ InsertFpdtMeasurement ( mSmmBootPerformanceTable->Header.Length +=3D FpdtRecordPtr.RecordHeader-= >Length; =20 return EFI_SUCCESS; } =20 -/** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, Module and Identifier. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 StartGauge= of PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier - ) -{ - EFI_STATUS Status; - - AcquireSpinLock (&mSmmFpdtLock); - - Status =3D InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp= , Identifier); - - ReleaseSpinLock (&mSmmFpdtLock); - - return Status; -} - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, Module and Identifier a= nd has an end time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EndGauge of = PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier - ) -{ - EFI_STATUS Status; - - AcquireSpinLock (&mSmmFpdtLock); - - Status =3D InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStam= p, Identifier); - - ReleaseSpinLock (&mSmmFpdtLock); - - return Status; -} - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGauge and EndGauge of PERFO= RMANCE_PROTOCOL, - and then assign the Identifier with 0. - - !!! Not Support!!! - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntryEx stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntryEx The indirect pointer to the extended gau= ge data entry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntryEx is successfully fou= nd based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGaugeEx ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, and Module. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ) -{ - return StartGaugeEx (Handle, Token, Module, TimeStamp, 0); -} - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, and Module and has an e= nd time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ) -{ - return EndGaugeEx (Handle, Token, Module, TimeStamp, 0); -} - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGaugeEx and EndGaugeEx of P= ERFORMANCE_EX_PROTOCOL, - and then eliminate the Identifier. - - !!! Not Support!!! - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntry stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntry The indirect pointer to the gauge data e= ntry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntry is successfully found= based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGauge ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY **GaugeDataEntry - ) -{ - return EFI_UNSUPPORTED; -} - - /** SmmReadyToBoot protocol notification event handler. =20 @param Protocol Points to the protocol's unique identifier @param Interface Points to the interface instance @@ -940,20 +700,13 @@ InitializeSmmCorePerformanceLib ( // Install the protocol interfaces for SMM performance library instance. // Handle =3D NULL; Status =3D gSmst->SmmInstallProtocolInterface ( &Handle, - &gSmmPerformanceProtocolGuid, - EFI_NATIVE_INTERFACE, - &mPerformanceInterface - ); - ASSERT_EFI_ERROR (Status); - Status =3D gSmst->SmmInstallProtocolInterface ( - &Handle, - &gSmmPerformanceExProtocolGuid, + &gEdkiiSmmPerformanceMeasurementProtocolGuid, EFI_NATIVE_INTERFACE, - &mPerformanceExInterface + &mPerformanceMeasurementInterface ); ASSERT_EFI_ERROR (Status); =20 Status =3D gSmst->SmmRegisterProtocolNotify ( &gEdkiiSmmReadyToBootProtocolGuid, @@ -1029,10 +782,52 @@ SmmCorePerformanceLibConstructor ( ASSERT_EFI_ERROR (Status); =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 +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; + + AcquireSpinLock (&mSmmFpdtLock); + if (Attribute =3D=3D PerfStartEntry) { + Status =3D InsertFpdtMeasurement (TRUE, CallerIdentifier, String, Stri= ng, TimeStamp, Identifier); + } else if (Attribute =3D=3D PerfEndEntry) { + Status =3D InsertFpdtMeasurement (FALSE, CallerIdentifier, String, Str= ing, TimeStamp, Identifier); + } + ReleaseSpinLock (&mSmmFpdtLock); + return Status; +} + /** Adds a record at the end of the performance measurement log that records the start time of a performance measurement. =20 Adds a record to the end of the performance measurement log @@ -1064,11 +859,21 @@ StartPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - return (RETURN_STATUS) StartGaugeEx (Handle, Token, Module, TimeStamp, I= dentifier); + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String= , TimeStamp, 0, Identifier, PerfStartEntry); } =20 /** Searches the performance measurement log from the beginning of the log for the first matching record that contains a zero end time and fills in= a valid end time. @@ -1103,11 +908,21 @@ EndPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - return (RETURN_STATUS) EndGaugeEx (Handle, Token, Module, TimeStamp, Ide= ntifier); + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String= , TimeStamp, 0, Identifier, PerfEndEntry); } =20 /** 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, @@ -1196,11 +1011,11 @@ StartPerformanceMeasurement ( IN CONST CHAR8 *Token, OPTIONAL IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp ) { - return StartGaugeEx (Handle, Token, Module, TimeStamp, 0); + return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, = 0); } =20 /** Searches the performance measurement log from the beginning of the log for the first matching record that contains a zero end time and fills in= a valid end time. @@ -1232,11 +1047,11 @@ EndPerformanceMeasurement ( IN CONST CHAR8 *Token, OPTIONAL IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp ) { - return EndGaugeEx (Handle, Token, Module, TimeStamp, 0); + return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0); } =20 /** 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, diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL= ib.inf b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i= nf index 01d8604eb61..61b92836657 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf @@ -64,19 +64,14 @@ [Protocols] gEfiSmmBase2ProtocolGuid ## CONSUMES gEdkiiSmmReadyToBootProtocolGuid ## NOTIFY =20 [Guids] - ## PRODUCES ## UNDEFINED # Install protocol - ## CONSUMES ## UNDEFINED # SmiHandlerRegister - gSmmPerformanceProtocolGuid - ## PRODUCES ## UNDEFINED # Install protocol - ## CONSUMES ## UNDEFINED # SmiHandlerRegister - gSmmPerformanceExProtocolGuid ## PRODUCES ## SystemTable gPerformanceProtocolGuid gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## UNDEF= INED # StatusCode Data gZeroGuid ## SOMETIMES_CONSUMES ## GUID + gEdkiiSmmPerformanceMeasurementProtocolGuid ## PRODUCES ## U= NDEFINED # Install protocol =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CON= SUMES gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly ## CON= SUMES diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL= ibInternal.h b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanc= eLibInternal.h index 9d24d9ff7a0..76f24984735 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInter= nal.h +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInter= nal.h @@ -18,10 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #ifndef _SMM_CORE_PERFORMANCE_LIB_INTERNAL_H_ #define _SMM_CORE_PERFORMANCE_LIB_INTERNAL_H_ =20 =20 #include +#include #include #include #include #include =20 @@ -44,202 +45,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EIT= HER EXPRESS OR IMPLIED. #include #include #include =20 // -// Interface declarations for SMM PerformanceEx Protocol. +// Interface declarations for SMM PerformanceMeasurement Protocol. // /** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, Module and Identifier. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 StartGauge= of PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - + 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 -StartGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier +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 ); =20 -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, Module and Identifier a= nd has an end time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EndGauge of = PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGaugeEx ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp, - IN UINT32 Identifier - ); - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGauge and EndGauge of PERFO= RMANCE_PROTOCOL, - and then assign the Identifier with 0. - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntryEx stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntryEx The indirect pointer to the extended gau= ge data entry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntryEx is successfully fou= nd based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGaugeEx ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx - ); - -// -// Interface declarations for SMM Performance Protocol. -// -/** - Adds a record at the end of the performance measurement log - that records the start time of a performance measurement. - - Adds a record to the end of the performance measurement log - that contains the Handle, Token, and Module. - The end time of the new record must be set to zero. - If TimeStamp is not zero, then TimeStamp is used to fill in the start ti= me in the record. - If TimeStamp is zero, the start time in the record is filled in with the= value - read from the current time stamp. - - @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 EFI_SUCCESS The data was read correctly from the dev= ice. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - -**/ -EFI_STATUS -EFIAPI -StartGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ); - -/** - Searches the performance measurement log from the beginning of the log - for the first matching record that contains a zero end time and fills in= a valid end time. - - Searches the performance measurement log from the beginning of the log - for the first record that matches Handle, Token, and Module and has an e= nd time value of zero. - If the record can not be found then return EFI_NOT_FOUND. - If the record is found and TimeStamp is not zero, - then the end time in the record is filled in with the value specified by= TimeStamp. - If the record is found and TimeStamp is zero, then the end time in the m= atching record - is filled in with the current time stamp value. - - @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 EFI_SUCCESS The end of the measurement was recorded. - @retval EFI_NOT_FOUND The specified measurement record could n= ot be found. - -**/ -EFI_STATUS -EFIAPI -EndGauge ( - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 TimeStamp - ); - -/** - Retrieves a previously logged performance measurement. - It can also retrieve the log created by StartGaugeEx and EndGaugeEx of P= ERFORMANCE_EX_PROTOCOL, - and then eliminate the Identifier. - - Retrieves the performance log entry from the performance log specified b= y LogEntryKey. - If it stands for a valid entry, then EFI_SUCCESS is returned and - GaugeDataEntry stores the pointer to that entry. - - @param LogEntryKey The key for the previous performance mea= surement log entry. - If 0, then the first performance measure= ment log entry is retrieved. - @param GaugeDataEntry The indirect pointer to the gauge data e= ntry specified by LogEntryKey - if the retrieval is successful. - - @retval EFI_SUCCESS The GuageDataEntry is successfully found= based on LogEntryKey. - @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equal= s to the total entry number). - @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (gr= eater than the total entry number). - @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. - -**/ -EFI_STATUS -EFIAPI -GetGauge ( - IN UINTN LogEntryKey, - OUT GAUGE_DATA_ENTRY **GaugeDataEntry - ); - - #endif diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c b/M= deModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c index 4a08c24789c..fd820c0e49c 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c @@ -16,24 +16,22 @@ 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. =20 **/ =20 =20 -#include +#include =20 #include #include #include #include #include =20 // // The cached SMM Performance Protocol and SMM PerformanceEx Protocol inte= rface. -// -PERFORMANCE_PROTOCOL *mPerformance =3D NULL; -PERFORMANCE_EX_PROTOCOL *mPerformanceEx =3D NULL; -BOOLEAN mPerformanceMeasurementEnabled; +EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement =3D NULL; +BOOLEAN mPerformanceMeasurementEnabled; =20 /** The constructor function initializes the Performance Measurement Enable = flag =20 @param ImageHandle The firmware allocated handle for the EFI image. @@ -63,42 +61,30 @@ SmmPerformanceLibConstructor ( @retval EFI_SUCCESS SMM PerformanceEx protocol or Performance Protoc= ol is successfully located. @retval EFI_NOT_FOUND Both SMM PerformanceEx protocol and Performance = Protocol are not located to log performance. =20 **/ EFI_STATUS -GetPerformanceProtocol ( +GetPerformanceMeasurementProtocol ( VOID ) { EFI_STATUS Status; - PERFORMANCE_PROTOCOL *Performance; - PERFORMANCE_EX_PROTOCOL *PerformanceEx; + EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement; =20 - if (mPerformanceEx !=3D NULL || mPerformance !=3D NULL) { + if (mPerformanceMeasurement !=3D NULL) { return EFI_SUCCESS; } =20 - Status =3D gSmst->SmmLocateProtocol (&gSmmPerformanceExProtocolGuid, NUL= L, (VOID **) &PerformanceEx); + Status =3D gSmst->SmmLocateProtocol (&gEdkiiSmmPerformanceMeasurementPro= tocolGuid, NULL, (VOID **) &PerformanceMeasurement); if (!EFI_ERROR (Status)) { - ASSERT (PerformanceEx !=3D NULL); + ASSERT (PerformanceMeasurement !=3D NULL); // - // Cache PerformanceEx Protocol. + // Cache PerformanceMeasurement Protocol. // - mPerformanceEx =3D PerformanceEx; + mPerformanceMeasurement =3D PerformanceMeasurement; return EFI_SUCCESS; } - - Status =3D gSmst->SmmLocateProtocol (&gSmmPerformanceProtocolGuid, NULL,= (VOID **) &Performance); - if (!EFI_ERROR (Status)) { - ASSERT (Performance !=3D NULL); - // - // Cache performance protocol. - // - mPerformance =3D Performance; - return EFI_SUCCESS; - } - return EFI_NOT_FOUND; } =20 /** Creates a record for the beginning of a performance measurement. @@ -130,21 +116,28 @@ StartPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - EFI_STATUS Status; + EFI_STATUS Status; + CONST CHAR8* String; =20 - Status =3D GetPerformanceProtocol (); + Status =3D GetPerformanceMeasurementProtocol (); if (EFI_ERROR (Status)) { - return RETURN_OUT_OF_RESOURCES; + return RETURN_NOT_FOUND; } =20 - if (mPerformanceEx !=3D NULL) { - Status =3D mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeSt= amp, Identifier); - } else if (mPerformance !=3D NULL) { - Status =3D mPerformance->StartGauge (Handle, Token, Module, TimeStamp); + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + if (mPerformanceMeasurement !=3D NULL) { + Status =3D mPerformanceMeasurement->CreatePerformanceMeasurement (Hand= le, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry); } else { ASSERT (FALSE); } =20 return (RETURN_STATUS) Status; @@ -182,21 +175,28 @@ EndPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - EFI_STATUS Status; + EFI_STATUS Status; + CONST CHAR8* String; =20 - Status =3D GetPerformanceProtocol (); + Status =3D GetPerformanceMeasurementProtocol (); if (EFI_ERROR (Status)) { return RETURN_NOT_FOUND; } =20 - if (mPerformanceEx !=3D NULL) { - Status =3D mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStam= p, Identifier); - } else if (mPerformance !=3D NULL) { - Status =3D mPerformance->EndGauge (Handle, Token, Module, TimeStamp); + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + if (mPerformanceMeasurement !=3D NULL) { + Status =3D mPerformanceMeasurement->CreatePerformanceMeasurement (Hand= le, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry); } else { ASSERT (FALSE); } =20 return (RETURN_STATUS) Status; @@ -253,62 +253,11 @@ GetPerformanceMeasurementEx ( OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp, OUT UINT32 *Identifier ) { - EFI_STATUS Status; - GAUGE_DATA_ENTRY_EX *GaugeData; - - GaugeData =3D NULL; - - ASSERT (Handle !=3D NULL); - ASSERT (Token !=3D NULL); - ASSERT (Module !=3D NULL); - ASSERT (StartTimeStamp !=3D NULL); - ASSERT (EndTimeStamp !=3D NULL); - ASSERT (Identifier !=3D NULL); - - Status =3D GetPerformanceProtocol (); - if (EFI_ERROR (Status)) { - return 0; - } - - if (mPerformanceEx !=3D NULL) { - Status =3D mPerformanceEx->GetGaugeEx (LogEntryKey++, &GaugeData); - } else if (mPerformance !=3D NULL) { - Status =3D mPerformance->GetGauge (LogEntryKey++, (GAUGE_DATA_ENTRY **= ) &GaugeData); - } else { - ASSERT (FALSE); - return 0; - } - - // - // Make sure that LogEntryKey is a valid log entry key, - // - ASSERT (Status !=3D EFI_INVALID_PARAMETER); - - if (EFI_ERROR (Status)) { - // - // The LogEntryKey is the last entry (equals to the total entry number= ). - // - return 0; - } - - ASSERT (GaugeData !=3D NULL); - - *Handle =3D (VOID *) (UINTN) GaugeData->Handle; - *Token =3D GaugeData->Token; - *Module =3D GaugeData->Module; - *StartTimeStamp =3D GaugeData->StartTimeStamp; - *EndTimeStamp =3D GaugeData->EndTimeStamp; - if (mPerformanceEx !=3D NULL) { - *Identifier =3D GaugeData->Identifier; - } else { - *Identifier =3D 0; - } - - return LogEntryKey; + return 0; } =20 /** Creates a record for the beginning of a performance measurement. =20 @@ -423,12 +372,11 @@ GetPerformanceMeasurement ( OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp ) { - UINT32 Identifier; - return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, = StartTimeStamp, EndTimeStamp, &Identifier); + return 0; } =20 /** Returns TRUE if the performance measurement macros are enabled. =20 diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf b= /MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf index c3d01a1e51d..174ed3f1e59 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf @@ -4,11 +4,11 @@ # This library instance provides infrastructure for SMM drivers to log pe= rformance # data. It consumes SMM PerformanceEx or Performance Protocol published b= y SmmCorePerformanceLib # to log performance data. If both SMM PerformanceEx and Performance Prot= ocol are not available, # it does not log any performance information. # =20 -# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 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 # =20 @@ -48,10 +48,9 @@ SmmServicesTableLib DebugLib BaseMemoryLib =20 [Guids] - gSmmPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFIN= ED # Locate protocol - gSmmPerformanceExProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFIN= ED # Locate protocol + gEdkiiSmmPerformanceMeasurementProtocolGuid ## SOMETIMES_CONSUM= ES ## UNDEFINED # Locate protocol =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES --=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 Sat Dec 21 14:37:02 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 1529657814146429.5743058716524; Fri, 22 Jun 2018 01:56:54 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EF92B210D513C; Fri, 22 Jun 2018 01:56:50 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 D2FEB210D439D for ; Fri, 22 Jun 2018 01:56:49 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:56:49 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:56:49 -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.43; helo=mga05.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,256,1526367600"; d="scan'208";a="65390331" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:17 +0800 Message-Id: <20180622085623.154924-4-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 3/9] MdePkg/PerformanceLib.h: Add new Perf macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , 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" 1. Add new Perf macros for performance measurement and related APIs and definitions in Performance library class. 2. Update NULL performance library instance in MdePkg. Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- MdePkg/Include/Library/PerformanceLib.h | 408 +++++++++++++++++= +++- .../BasePerformanceLibNull/PerformanceLib.c | 57 ++- MdePkg/MdePkg.dec | 9 +- MdePkg/MdePkg.uni | 6 + 4 files changed, 477 insertions(+), 3 deletions(-) diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Libra= ry/PerformanceLib.h index 3ecd62bd201..8a8f5e3694a 100644 --- a/MdePkg/Include/Library/PerformanceLib.h +++ b/MdePkg/Include/Library/PerformanceLib.h @@ -1,9 +1,9 @@ /** @file Provides services to log the execution times and retrieve them later. =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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 =20 @@ -18,10 +18,49 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. /// /// Performance library propery mask bits /// #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001 =20 +// +// Public Progress Identifiers for Event Records. +// +#define PERF_EVENT_ID 0x00 + +#define MODULE_START_ID 0x01 +#define MODULE_END_ID 0x02 +#define MODULE_LOADIMAGE_START_ID 0x03 +#define MODULE_LOADIMAGE_END_ID 0x04 +#define MODULE_DB_START_ID 0x05 +#define MODULE_DB_END_ID 0x06 +#define MODULE_DB_SUPPORT_START_ID 0x07 +#define MODULE_DB_SUPPORT_END_ID 0x08 +#define MODULE_DB_STOP_START_ID 0x09 +#define MODULE_DB_STOP_END_ID 0x0A + +#define PERF_EVENTSIGNAL_START_ID 0x10 +#define PERF_EVENTSIGNAL_END_ID 0x11 +#define PERF_CALLBACK_START_ID 0x20 +#define PERF_CALLBACK_END_ID 0x21 +#define PERF_FUNCTION_START_ID 0x30 +#define PERF_FUNCTION_END_ID 0x31 +#define PERF_INMODULE_START_ID 0x40 +#define PERF_INMODULE_END_ID 0x41 +#define PERF_CROSSMODULE_START_ID 0x50 +#define PERF_CROSSMODULE_END_ID 0x51 + +// +// Declare bits for PcdPerformanceLibraryPropertyMask and +// also used as the Type parameter of LogPerformanceMeasurementEnabled(). +// +#define PERF_CORE_START_IMAGE 0x0002 +#define PERF_CORE_LOAD_IMAGE 0x0004 +#define PERF_CORE_DB_SUPPORT 0x0008 +#define PERF_CORE_DB_START 0x0010 +#define PERF_CORE_DB_STOP 0x0020 + +#define PERF_GENERAL_TYPE 0x0040 + /** Creates a record for the beginning of a performance measurement.=20 =20 Creates a record that contains the Handle, Token, and Module. If TimeStamp is not zero, then TimeStamp is added to the record as the s= tart time. @@ -269,10 +308,377 @@ BOOLEAN EFIAPI PerformanceMeasurementEnabled ( VOID ); =20 + +/** + 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 + ); + +/** + Create performance record with event description. + + @param CallerIdentifier - Image handle or pointer to caller ID GUID + @param Guid - Pointer to a GUID. + Used for event signal perf and callback perf t= o cache the event guid. + @param String - Pointer to a string describing the measurement + @param Address - Pointer to a location in memory relevant to th= e 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 Identifier. + +**/ +RETURN_STATUS +EFIAPI +LogPerformanceMeasurement ( + IN CONST VOID *CallerIdentifier, OPTIONAL + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 Address, OPTIONAL + IN UINT32 Identifier + ); + +/** + Begin Macro to measure the performance of StartImage in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT1(dsiable PERF_CORE_START_IMAGE) of PcdPerformanceLibraryProp= ertyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_START_IMAGE_BEGIN(ModuleHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START= _ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the performance of StartImage in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT1 (dsiable PERF_CORE_START_IMAGE)of PcdPerformanceLibraryProp= ertyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_START_IMAGE_END(ModuleHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_I= D); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the performance of LoadImage in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryProp= ertyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADI= MAGE_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the performance of LoadImage in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryProp= ertyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_LOAD_IMAGE_END(ModuleHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADI= MAGE_END_ID); \ + } \ + } while (FALSE) + +/** + Start Macro to measure the performance of DriverBinding Support in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryProp= ertyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)= ControllerHandle, MODULE_DB_SUPPORT_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the performance of DriverBinding Support in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryProp= ertyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)= ControllerHandle, MODULE_DB_SUPPORT_END_ID); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the performance of DriverBinding Start in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryProper= tyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)= ControllerHandle, MODULE_DB_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the performance of DriverBinding Start in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryProper= tyMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)= ControllerHandle, MODULE_DB_END_ID); \ + } \ + } while (FALSE) + +/** + Start Macro to measure the performance of DriverBinding Stop in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)= ControllerHandle, MODULE_DB_STOP_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the performance of DriverBinding Stop in core. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \ + LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)= ControllerHandle, MODULE_DB_STOP_END_ID); \ + } \ + } while (FALSE) + +/** + Macro to measure the time from power-on to this macro execution. + It can be used to log a meaningful thing which happens at a time point. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_EVENT(EventString) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0,= PERF_EVENT_ID); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the perofrmance of evnent signal behavior in any = module. + The event guid will be passed with this macro. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION_= _ , 0, PERF_EVENTSIGNAL_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the perofrmance of evnent signal behavior in any mo= dule. + The event guid will be passed with this macro. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_EVENT_SIGNAL_END(EventGuid) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION_= _ , 0, PERF_EVENTSIGNAL_END_ID); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the perofrmance of a callback function in any mod= ule. + The event guid which trigger the callback function will be passed with t= his macro. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_CALLBACK_BEGIN(TriggerGuid) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTIO= N__ , 0, PERF_CALLBACK_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the perofrmance of a callback function in any modul= e. + The event guid which trigger the callback function will be passed with t= his macro. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_CALLBACK_END(TriggerGuid) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTIO= N__ , 0, PERF_CALLBACK_END_ID); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the perofrmance of a general function in any modu= le. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_FUNCTION_BEGIN() \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0= , PERF_FUNCTION_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the perofrmance of a general function in any module. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_FUNCTION_END() \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0= , PERF_FUNCTION_END_ID); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the perofrmance of a behavior within one module. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_INMODULE_BEGIN(MeasurementString) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementStrin= g, 0, PERF_INMODULE_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the perofrmance of a behavior within one module. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_INMODULE_END(MeasurementString) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementStrin= g, 0, PERF_INMODULE_END_ID); \ + } \ + } while (FALSE) + +/** + Begin Macro to measure the perofrmance of a behavior in different module= s. + Such as the performance of PEI phase, DXE phase, BDS phase. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_CROSSMODULE_BEGIN(MeasurementString) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementStrin= g, 0, PERF_CROSSMODULE_START_ID); \ + } \ + } while (FALSE) + +/** + End Macro to measure the perofrmance of a behavior in different modules. + Such as the performance of PEI phase, DXE phase, BDS phase. + + If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, + and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropert= yMask is not set. + then LogPerformanceMeasurement() is called. + +**/ +#define PERF_CROSSMODULE_END(MeasurementString) \ + do { \ + if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \ + LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementStrin= g, 0, PERF_CROSSMODULE_END_ID); \ + } \ + } while (FALSE) + /** Macro that calls EndPerformanceMeasurement(). =20 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerfor= manceLibraryPropertyMask is set, then EndPerformanceMeasurement() is called. diff --git a/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c b/MdePk= g/Library/BasePerformanceLibNull/PerformanceLib.c index e35235d9a29..a68ea90d4f0 100644 --- a/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c +++ b/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c @@ -1,9 +1,9 @@ /** @file Base Performance Library which provides no service. =20 - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. =20 @@ -302,5 +302,60 @@ 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,OPTIONAL + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 Address, OPTIONAL + IN UINT32 Identifier + ) +{ + return RETURN_SUCCESS; +} + +/** + 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/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 0e64f22f4a7..432de804c5d 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -2167,12 +2167,19 @@ # @Prompt Value to Clear Memory. gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF|UINT8|0x00000008 =20 ## The mask is used to control PerformanceLib behavior.

# BIT0 - Enable Performance Measurement.
+ # BIT1 - Disable Start Image Logging.
+ # BIT2 - Disable Load Image logging.
+ # BIT3 - Disable Binding Support logging.
+ # BIT4 - Disable Binding Start logging.
+ # BIT5 - Disable Binding Stop logging.
+ # BIT6 - Disable all other general Perfs.
+ # BIT1-BIT6 are evaluated when BIT0 is set.
# @Prompt Performance Measurement Property. - # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibr= aryPropertyMask & 0xFE) =3D=3D 0 + # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibr= aryPropertyMask & 0x80) =3D=3D 0 gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0|UINT8|0x000= 00009 =20 ## The mask is used to control PostCodeLib behavior.

# BIT0 - Enable Post Code.
# BIT1 - Enable Post Code with Description.
diff --git a/MdePkg/MdePkg.uni b/MdePkg/MdePkg.uni index a110e453df8..18bb01f2199 100644 --- a/MdePkg/MdePkg.uni +++ b/MdePkg/MdePkg.uni @@ -243,10 +243,16 @@ =20 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPerformanceLibraryPropertyMask_PRO= MPT #language en-US "Performance Measurement Property" =20 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPerformanceLibraryPropertyMask_HEL= P #language en-US "The mask is used to control PerformanceLib behavior.
\n" = "BIT0 - Enable Performance Measurement.
" + = "BIT1 - Disable Start Image Logging.
" + = "BIT2 - Disable Load Image logging.
" + = "BIT3 - Disable Binding Support logging.
" + = "BIT4 - Disable Binding Start logging.
" + = "BIT5 - Disable Binding Stop logging.
" + = "BIT6 - Disable all other general Perfs.
" =20 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPostCodePropertyMask_PROMPT #lang= uage en-US "Post Code Property" =20 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPostCodePropertyMask_HELP #langua= ge en-US "The mask is used to control PostCodeLib behavior.

\n" = "BIT0 - Enable Post Code.
\n" --=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 Sat Dec 21 14:37:02 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 1529657817702308.23223826908475; Fri, 22 Jun 2018 01:56:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 294F0210D7F3D; Fri, 22 Jun 2018 01:56:55 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 C5B12210C4DC7 for ; Fri, 22 Jun 2018 01:56:53 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:56:53 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:56:53 -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.43; helo=mga05.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,256,1526367600"; d="scan'208";a="65390345" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:18 +0800 Message-Id: <20180622085623.154924-5-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 4/9] MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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" Remove the definitions of performance identifier since they have been added into PerformanceLib.h. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../Include/Guid/ExtendedFirmwarePerformance.h | 25 ------------------= ---- 1 file changed, 25 deletions(-) diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeM= odulePkg/Include/Guid/ExtendedFirmwarePerformance.h index f2db02ddf49..465b4082750 100644 --- a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -30,35 +30,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #define DRIVERBINDING_STOP_TOK "DB:Stop:" ///< Driver Bind= ing Stop() function call #define LOAD_IMAGE_TOK "LoadImage:" ///< Load a disp= atched module #define START_IMAGE_TOK "StartImage:" ///< Dispatched = Modules Entry Point execution #define PEIM_TOK "PEIM" ///< PEIM Module= s Entry Point execution =20 -// -// Public Progress Identifiers for Event Records to map the above known to= ken -// -#define MODULE_START_ID 0x01 -#define MODULE_END_ID 0x02 -#define MODULE_LOADIMAGE_START_ID 0x03 -#define MODULE_LOADIMAGE_END_ID 0x04 -#define MODULE_DB_START_ID 0x05 -#define MODULE_DB_END_ID 0x06 -#define MODULE_DB_SUPPORT_START_ID 0x07 -#define MODULE_DB_SUPPORT_END_ID 0x08 -#define MODULE_DB_STOP_START_ID 0x09 -#define MODULE_DB_STOP_END_ID 0x0A - -#define PERF_EVENTSIGNAL_START_ID 0x10 -#define PERF_EVENTSIGNAL_END_ID 0x11 -#define PERF_CALLBACK_START_ID 0x20 -#define PERF_CALLBACK_END_ID 0x21 -#define PERF_FUNCTION_START_ID 0x30 -#define PERF_FUNCTION_END_ID 0x31 -#define PERF_INMODULE_START_ID 0x40 -#define PERF_INMODULE_END_ID 0x41 -#define PERF_CROSSMODULE_START_ID 0x50 -#define PERF_CROSSMODULE_END_ID 0x51 - // // Misc defines // #define FPDT_RECORD_REVISION_1 (0x01) =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 Sat Dec 21 14:37:02 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 1529657823761752.365257711198; Fri, 22 Jun 2018 01:57:03 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 70251210D83CF; Fri, 22 Jun 2018 01:56:59 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 AEC93210D7F2E for ; Fri, 22 Jun 2018 01:56:57 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:56:57 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:56:56 -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.43; helo=mga05.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,256,1526367600"; d="scan'208";a="65390362" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:19 +0800 Message-Id: <20180622085623.154924-6-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 5/9] MdeModulePkg: Update performance library instances X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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" Update the performance library instances in MdeModulePkg to implement the APIs used for new added Perf macros. V2: Share the common logics of creating FPDT record for new added Perf macros and existing Perf macros. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../Include/Guid/ExtendedFirmwarePerformance.h | 6 - .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 864 +++++++++++++++--= ---- .../DxeCorePerformanceLib.inf | 1 + .../DxeCorePerformanceLibInternal.h | 1 + .../Library/DxePerformanceLib/DxePerformanceLib.c | 68 ++ .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 632 +++++++++------ .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 645 +++++++++------ .../Library/SmmPerformanceLib/SmmPerformanceLib.c | 68 ++ 8 files changed, 1565 insertions(+), 720 deletions(-) diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeM= odulePkg/Include/Guid/ExtendedFirmwarePerformance.h index 465b4082750..dedb0b82f0d 100644 --- a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -218,16 +218,10 @@ typedef struct { CHAR8 String[0]; } FPDT_GUID_QWORD_STRING_EVENT_RECORD; =20 #pragma pack() =20 -typedef struct { - UINT16 ProgressID; - UINT16 Type; - UINT8 RecordSize; -} FPDT_BASIC_RECORD_INFO; - // // Union of all FPDT records // typedef union { EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER RecordHeader; diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceL= ib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 79820605184..efff5134c7b 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -69,17 +69,19 @@ UINTN mCachePairCount =3D 0; UINT32 mLoadImageCount =3D 0; UINT32 mPerformanceLength =3D 0; UINT32 mMaxPerformanceLength =3D 0; UINT32 mBootRecordSize =3D 0; UINT32 mBootRecordMaxSize =3D 0; +UINT32 mCachedLength =3D 0; =20 BOOLEAN mFpdtBufferIsReported =3D FALSE; BOOLEAN mLackSpaceIsReported =3D FALSE; CHAR8 *mPlatformLanguage =3D NULL; UINT8 *mPerformancePointer =3D NULL; UINT8 *mBootRecordBuffer =3D NULL; BOOLEAN mLockInsertRecord =3D FALSE; +CHAR8 *mDevicePathString =3D NULL; =20 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText =3D NULL; =20 // // Interfaces for PerformanceMeasurement Protocol. @@ -88,10 +90,64 @@ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeas= urementInterface =3D { CreatePerformanceMeasurement, }; =20 PERFORMANCE_PROPERTY mPerformanceProperty; =20 +/** + Return the pointer to the FPDT record in the allocated memory. + + @param RecordSize The size of FPDT record. + @param FpdtRecordPtr Pointer the FPDT record in the allocated = memory. + + @retval EFI_SUCCESS Successfully get the pointer to the FPDT = record. + @retval EFI_OUT_OF_RESOURCES Ran out of space to store the records. +**/ +EFI_STATUS +GetFpdtRecordPtr ( + IN UINT8 RecordSize, + IN OUT FPDT_RECORD_PTR *FpdtRecordPtr +) +{ + if (mFpdtBufferIsReported) { + // + // Append Boot records to the boot performance table. + // + if (mBootRecordSize + RecordSize > mBootRecordMaxSize) { + if (!mLackSpaceIsReported) { + DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to sav= e boot records\n")); + mLackSpaceIsReported =3D TRUE; + } + return EFI_OUT_OF_RESOURCES; + } else { + // + // Save boot record into BootPerformance table + // + FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECOR= D_HEADER *)(mBootRecordBuffer + mBootRecordSize); + } + } else { + // + // Check if pre-allocated buffer is full + // + if (mPerformanceLength + RecordSize > mMaxPerformanceLength) { + mPerformancePointer =3D ReallocatePool ( + mPerformanceLength, + mPerformanceLength + RecordSize + FIRMWARE_R= ECORD_BUFFER, + mPerformancePointer + ); + if (mPerformancePointer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + mMaxPerformanceLength =3D mPerformanceLength + RecordSize + FIRMWARE= _RECORD_BUFFER; + } + // + // Covert buffer to FPDT Ptr Union type. + // + FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_= HEADER *)(mPerformancePointer + mPerformanceLength); + } + return EFI_SUCCESS; +} + /** Check whether the Token is a known one which is uesed by core. =20 @param Token Pointer to a Null-terminated ASCII string =20 @@ -585,282 +641,355 @@ Done: =20 return Status; } =20 /** - Get the FPDT record info. + Get the FPDT record identifier. =20 - @param IsStart TRUE if the performance log is start log. - @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 RecordInfo On return, pointer to the info of the re= cord. - @param UseModuleName Only useful for FPDT_DYNAMIC_STRING_EVEN= T_TYPE, indicate that whether need use - Module name to fill the string field in = the FPDT_DYNAMIC_STRING_EVENT_RECORD. + @param Attribute The attribute of the Record. + PerfStartEntry: Start Record. + PerfEndEntry: End Record. + @param Handle Pointer to environment specific context = used to identify the component being measured. + @param String Pointer to a Null-terminated ASCII strin= g that identifies the component being measured. + @param ProgressID On return, pointer to the ProgressID. =20 - @retval EFI_SUCCESS Get record info successfully. - @retval EFI_UNSUPPORTED No matched FPDT record. + @retval EFI_SUCCESS Get record info successfully. + @retval EFI_INVALID_PARAMETER No matched FPDT record. =20 **/ EFI_STATUS -GetFpdtRecordInfo ( - IN BOOLEAN IsStart, - IN CONST VOID *Handle, - IN CONST CHAR8 *Token, - IN CONST CHAR8 *Module, - OUT FPDT_BASIC_RECORD_INFO *RecordInfo, - IN OUT BOOLEAN *UseModuleName +GetFpdtRecordId ( + IN PERF_MEASUREMENT_ATTRIBUTE Attribute, + IN CONST VOID *Handle, + IN CONST CHAR8 *String, + OUT UINT16 *ProgressID ) { - UINT16 RecordType; - UINTN StringSize; - - RecordType =3D FPDT_DYNAMIC_STRING_EVENT_TYPE; - // - // Token to Type and Id. + // Token to PerfId. // - if (Token !=3D NULL) { - if (AsciiStrCmp (Token, START_IMAGE_TOK) =3D=3D 0) { //= "StartImage:" - *UseModuleName =3D TRUE; - RecordType =3D FPDT_GUID_EVENT_TYPE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_START_ID; + if (String !=3D NULL) { + if (AsciiStrCmp (String, START_IMAGE_TOK) =3D=3D 0) { /= / "StartImage:" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_END_ID; + *ProgressID =3D MODULE_END_ID; } - } else if (AsciiStrCmp (Token, LOAD_IMAGE_TOK) =3D=3D 0) { //= "LoadImage:" - *UseModuleName =3D TRUE; - RecordType =3D FPDT_GUID_QWORD_EVENT_TYPE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_LOADIMAGE_START_ID; + } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) =3D=3D 0) { /= / "LoadImage:" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_LOADIMAGE_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_LOADIMAGE_END_ID; + *ProgressID =3D MODULE_LOADIMAGE_END_ID; } - } else if (AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0) { /= / "DB:Start:" - *UseModuleName =3D TRUE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_DB_START_ID; - RecordType =3D FPDT_GUID_QWORD_EVENT_TYPE; + } else if (AsciiStrCmp (String, DRIVERBINDING_START_TOK) =3D=3D 0) { = // "DB:Start:" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_DB_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_DB_END_ID; - RecordType =3D FPDT_GUID_QWORD_STRING_EVENT_TYPE; + *ProgressID =3D MODULE_DB_END_ID; } - } else if (AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) =3D=3D 0) { = // "DB:Support:" - *UseModuleName =3D TRUE; + } else if (AsciiStrCmp (String, DRIVERBINDING_SUPPORT_TOK) =3D=3D 0) {= // "DB:Support:" if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { return RETURN_UNSUPPORTED; } - RecordType =3D FPDT_GUID_QWORD_EVENT_TYPE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_DB_SUPPORT_START_ID; + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_DB_SUPPORT_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_DB_SUPPORT_END_ID; + *ProgressID =3D MODULE_DB_SUPPORT_END_ID; } - } else if (AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) =3D=3D 0) { = // "DB:Stop:" - *UseModuleName =3D TRUE; + } else if (AsciiStrCmp (String, DRIVERBINDING_STOP_TOK) =3D=3D 0) { = // "DB:Stop:" if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { return RETURN_UNSUPPORTED; } - RecordType =3D FPDT_GUID_QWORD_EVENT_TYPE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_DB_STOP_START_ID; + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_DB_STOP_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_DB_STOP_END_ID; + *ProgressID =3D MODULE_DB_STOP_END_ID; } - } else if (AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || = // "PEI" - AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || = // "DXE" - AsciiStrCmp (Token, BDS_TOK) =3D=3D 0) { = // "BDS" - if (IsStart) { - RecordInfo->ProgressID =3D PERF_CROSSMODULE_START_ID; + } else if (AsciiStrCmp (String, PEI_TOK) =3D=3D 0 || = // "PEI" + AsciiStrCmp (String, DXE_TOK) =3D=3D 0 || = // "DXE" + AsciiStrCmp (String, BDS_TOK) =3D=3D 0) { = // "BDS" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_CROSSMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_CROSSMODULE_END_ID; + *ProgressID =3D PERF_CROSSMODULE_END_ID; } } else { // P= ref used in Modules. - if (IsStart) { - RecordInfo->ProgressID =3D PERF_INMODULE_START_ID; + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_INMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_INMODULE_END_ID; + *ProgressID =3D PERF_INMODULE_END_ID; } } - } else if (Handle!=3D NULL || Module !=3D NULL) { = // Pref used in Modules. - if (IsStart) { - RecordInfo->ProgressID =3D PERF_INMODULE_START_ID; + } else if (Handle!=3D NULL) { //= Pref used in Modules. + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_INMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_INMODULE_END_ID; + *ProgressID =3D PERF_INMODULE_END_ID; } } else { - return EFI_UNSUPPORTED; + return EFI_INVALID_PARAMETER; } + return EFI_SUCCESS; +} + +/** + Copies the string from Source into Destination and updates Length with t= he + size of the string. + + @param Destination - destination of the string copy + @param Source - pointer to the source string which will get copied + @param Length - pointer to a length variable to be updated + +**/ +VOID +CopyStringIntoPerfRecordAndUpdateLength ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN OUT UINT8 *Length + ) +{ + UINTN StringLen; + UINTN DestMax; + + ASSERT (Source !=3D NULL); =20 - // - // Get Record size baesed on the record type. - // When PcdEdkiiFpdtStringRecordEnableOnly is TRUE, all records are with= type of FPDT_DYNAMIC_STRING_EVENT_TYPE. - // if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { - RecordType =3D FPDT_DYNAMIC_STRING_EVENT_TYPE; - RecordInfo->RecordSize =3D sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)= + STRING_SIZE; + DestMax =3D STRING_SIZE; } else { - switch (RecordType) { - case FPDT_GUID_EVENT_TYPE: - RecordInfo->RecordSize =3D sizeof (FPDT_GUID_EVENT_RECORD); - break; - - case FPDT_DYNAMIC_STRING_EVENT_TYPE: - if (*UseModuleName) { - StringSize =3D STRING_SIZE; - } else if (Token !=3D NULL) { - StringSize =3D AsciiStrSize (Token); - } else if (Module !=3D NULL) { - StringSize =3D AsciiStrSize (Module); - } else { - StringSize =3D STRING_SIZE; - } - if (StringSize > STRING_SIZE) { - StringSize =3D STRING_SIZE; - } - RecordInfo->RecordSize =3D (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT= _RECORD) + StringSize); - break; + DestMax =3D AsciiStrSize (Source); + if (DestMax > STRING_SIZE) { + DestMax =3D STRING_SIZE; + } + } + StringLen =3D AsciiStrLen (Source); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } + + AsciiStrnCpyS(Destination, DestMax, Source, StringLen); + *Length +=3D (UINT8)DestMax; + + return; +} + +/** + Get a string description for device for the given controller handle and = update record + length. If ComponentName2 GetControllerName is supported, the value is i= ncluded in the string, + followed by device path, otherwise just device path. =20 - case FPDT_GUID_QWORD_EVENT_TYPE: - RecordInfo->RecordSize =3D (UINT8)sizeof (FPDT_GUID_QWORD_EVENT_RECO= RD); - break; + @param Handle - Image handle + @param ControllerHandle - Controller handle. + @param ComponentNameString - Pointer to a location where the string will= be saved + @param Length - Pointer to record length to be updated =20 - case FPDT_GUID_QWORD_STRING_EVENT_TYPE: - RecordInfo->RecordSize =3D (UINT8)sizeof (FPDT_GUID_QWORD_STRING_EVE= NT_RECORD); - break; + @retval EFI_SUCCESS - Successfully got string description for device + @retval EFI_UNSUPPORTED - Neither ComponentName2 ControllerName nor Devi= cePath were found =20 - default: +**/ +EFI_STATUS +GetDeviceInfoFromHandleAndUpdateLength ( + IN CONST VOID *Handle, + IN EFI_HANDLE ControllerHandle, + OUT CHAR8 *ComponentNameString, + IN OUT UINT8 *Length + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePathProtocol; + EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; + EFI_STATUS Status; + CHAR16 *StringPtr; + CHAR8 *AsciiStringPtr; + UINTN ControllerNameStringSize; + UINTN DevicePathStringSize; + + ControllerNameStringSize =3D 0; + + Status =3D gBS->HandleProtocol ( + (EFI_HANDLE) Handle, + &gEfiComponentName2ProtocolGuid, + (VOID **) &ComponentName2 + ); + + if (!EFI_ERROR(Status)) { + // + // Get the current platform language setting + // + if (mPlatformLanguage =3D=3D NULL) { + GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&mPlatformLanguage,= NULL); + } + + Status =3D ComponentName2->GetControllerName ( + ComponentName2, + ControllerHandle, + NULL, + mPlatformLanguage !=3D NULL ? mPlatformLang= uage : "en-US", + &StringPtr + ); + } + + if (!EFI_ERROR (Status)) { + // + // This will produce the size of the unicode string, which is twice as= large as the ASCII one + // This must be an even number, so ok to divide by 2 + // + ControllerNameStringSize =3D StrSize(StringPtr) / 2; + + // + // The + 1 is because we want to add a space between the ControllerNam= e and the device path + // + if ((ControllerNameStringSize + (*Length) + 1) > FPDT_MAX_PERF_RECORD_= SIZE) { // - // Record is unsupported yet, return EFI_UNSUPPORTED + // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the r= ecord // - return EFI_UNSUPPORTED; + ControllerNameStringSize =3D FPDT_MAX_PERF_RECORD_SIZE - (*Length) -= 1; } + + UnicodeStrToAsciiStrS(StringPtr, ComponentNameString, ControllerNameSt= ringSize); + + // + // Add a space in the end of the ControllerName + // + AsciiStringPtr =3D ComponentNameString + ControllerNameStringSize - 1; + *AsciiStringPtr =3D 0x20; + AsciiStringPtr++; + *AsciiStringPtr =3D 0; + ControllerNameStringSize++; + + *Length +=3D (UINT8)ControllerNameStringSize; } =20 - RecordInfo->Type =3D RecordType; - return EFI_SUCCESS; + // + // This function returns the device path protocol from the handle specif= ied by Handle. If Handle is + // NULL or Handle does not contain a device path protocol, then NULL is = returned. + // + DevicePathProtocol =3D DevicePathFromHandle(ControllerHandle); + + if (DevicePathProtocol !=3D NULL) { + StringPtr =3D ConvertDevicePathToText (DevicePathProtocol, TRUE, FALSE= ); + if (StringPtr !=3D NULL) { + // + // This will produce the size of the unicode string, which is twice = as large as the ASCII one + // This must be an even number, so ok to divide by 2 + // + DevicePathStringSize =3D StrSize(StringPtr) / 2; + + if ((DevicePathStringSize + (*Length)) > FPDT_MAX_PERF_RECORD_SIZE) { + // + // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the= record + // + DevicePathStringSize =3D FPDT_MAX_PERF_RECORD_SIZE - (*Length); + } + + if (ControllerNameStringSize !=3D 0) { + AsciiStringPtr =3D ComponentNameString + ControllerNameStringSize = - 1; + } else { + AsciiStringPtr =3D ComponentNameString; + } + + UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSiz= e); + *Length +=3D (UINT8)DevicePathStringSize; + return EFI_SUCCESS; + } + } + + return EFI_UNSUPPORTED; } =20 /** - Add performance log to FPDT boot record table. + Create performance record with event description and a timestamp. =20 - @param IsStart TRUE if the performance log is start log. - @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 Ticker 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 StartGauge= of PERFORMANCE_PROTOCOL. + @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 Ticker - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to t= he measurement. + @param PerfId - 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. =20 - @retval EFI_SUCCESS Add FPDT boot record. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - @retval EFI_UNSUPPORTED No matched FPDT record. + @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. + + @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 =20 **/ EFI_STATUS -InsertFpdtMeasurement ( - IN BOOLEAN IsStart, - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 Ticker, - IN UINT32 Identifier +InsertFpdtRecord ( + IN CONST VOID *CallerIdentifier, OPTIONAL + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 Ticker, + IN UINT64 Address, OPTIONAL + IN UINT16 PerfId, + IN PERF_MEASUREMENT_ATTRIBUTE Attribute ) { EFI_GUID ModuleGuid; CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LE= NGTH]; - EFI_STATUS Status; FPDT_RECORD_PTR FpdtRecordPtr; - FPDT_BASIC_RECORD_INFO RecordInfo; + FPDT_RECORD_PTR CachedFpdtRecordPtr; UINT64 TimeStamp; - UINTN DestMax; - UINTN StrLength; CONST CHAR8 *StringPtr; - BOOLEAN UseModuleName; + UINTN DestMax; + UINTN StringLen; + EFI_STATUS Status; + UINT16 ProgressId; =20 StringPtr =3D NULL; - UseModuleName =3D FALSE; + ProgressId =3D 0; ZeroMem (ModuleName, sizeof (ModuleName)); =20 // - // Get record info (type, size, ProgressID and Module Guid). - // - Status =3D GetFpdtRecordInfo (IsStart, Handle, Token, Module, &RecordInf= o, &UseModuleName); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // If PERF_START()/PERF_END() have specified the ProgressID,it has high = priority. - // !!! Note: If the Perf is not the known Token used in the core but hav= e same - // ID with the core Token, this case will not be supported. - // And in currtnt usage mode, for the unkown ID, there is a general rule: - // If it is start pref: the lower 4 bits of the ID should be 0. - // If it is end pref: the lower 4 bits of the ID should not be 0. - // If input ID doesn't follow the rule, we will adjust it. + // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_E= X/PERF_END_EX. + // notes: For other Perf macros (Attribute =3D=3D PerfEntry), their I= d is known. // - if ((Identifier !=3D 0) && (IsKnownID (Identifier)) && (!IsKnownTokens (= Token))) { - return EFI_UNSUPPORTED; - } else if ((Identifier !=3D 0) && (!IsKnownID (Identifier)) && (!IsKnown= Tokens (Token))) { - if (IsStart && ((Identifier & 0x000F) !=3D 0)) { - Identifier &=3D 0xFFF0; - } else if ((!IsStart) && ((Identifier & 0x000F) =3D=3D 0)) { - Identifier +=3D 1; - } - RecordInfo.ProgressID =3D (UINT16)Identifier; - } - - if (mFpdtBufferIsReported) { + if (Attribute !=3D PerfEntry) { // - // Append Boot records to the boot performance table. + // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it h= as high priority. + // !!! Note: If the Perf is not the known Token used in the core but h= ave same + // ID with the core Token, this case will not be supported. + // And in currtnt usage mode, for the unkown ID, there is a general ru= le: + // If it is start pref: the lower 4 bits of the ID should be 0. + // If it is end pref: the lower 4 bits of the ID should not be 0. + // If input ID doesn't follow the rule, we will adjust it. // - if (mBootRecordSize + RecordInfo.RecordSize > mBootRecordMaxSize) { - if (!mLackSpaceIsReported) { - DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to sav= e boot records\n")); - mLackSpaceIsReported =3D TRUE; + if ((PerfId !=3D 0) && (IsKnownID (PerfId)) && (!IsKnownTokens (String= ))) { + return EFI_INVALID_PARAMETER; + } else if ((PerfId !=3D 0) && (!IsKnownID (PerfId)) && (!IsKnownTokens= (String))) { + if ((Attribute =3D=3D PerfStartEntry) && ((PerfId & 0x000F) !=3D 0))= { + PerfId &=3D 0xFFF0; + } else if ((Attribute =3D=3D PerfEndEntry) && ((PerfId & 0x000F) =3D= =3D 0)) { + PerfId +=3D 1; } - return EFI_OUT_OF_RESOURCES; - } else { + } else if (PerfId =3D=3D 0) { // - // Save boot record into BootPerformance table + // Get ProgressID form the String Token. // - FpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD= _HEADER *)(mBootRecordBuffer + mBootRecordSize); - mBootRecordSize +=3D RecordInfo.RecordSize; - mAcpiBootPerformanceTable->Header.Length +=3D RecordInfo.RecordSize; - } - } else { - // - // Check if pre-allocated buffer is full - // - if (mPerformanceLength + RecordInfo.RecordSize > mMaxPerformanceLength= ) { - mPerformancePointer =3D ReallocatePool ( - mPerformanceLength, - mPerformanceLength + RecordInfo.RecordSize += FIRMWARE_RECORD_BUFFER, - mPerformancePointer - ); - - if (mPerformancePointer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D GetFpdtRecordId (Attribute, CallerIdentifier, String, &Pr= ogressId); + if (EFI_ERROR (Status)) { + return Status; } - mMaxPerformanceLength =3D mPerformanceLength + RecordInfo.RecordSize= + FIRMWARE_RECORD_BUFFER; + PerfId =3D ProgressId; } - // - // Covert buffer to FPDT Ptr Union type. - // - FpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_H= EADER *)(mPerformancePointer + mPerformanceLength); - mPerformanceLength +=3D RecordInfo.RecordSize; } =20 // - // Get the TimeStamp. + // 2. Get the buffer to store the FPDT record. + // + Status =3D GetFpdtRecordPtr (FPDT_MAX_PERF_RECORD_SIZE, &FpdtRecordPtr); + if (EFI_ERROR (Status)) { + return Status; + } + + // + //3. Get the TimeStamp. // if (Ticker =3D=3D 0) { Ticker =3D GetPerformanceCounter (); TimeStamp =3D GetTimeInNanoSecond (Ticker); } else if (Ticker =3D=3D 1) { @@ -868,85 +997,252 @@ InsertFpdtMeasurement ( } else { TimeStamp =3D GetTimeInNanoSecond (Ticker); } =20 // - // Get the ModuleName and ModuleGuid form the handle. - // - GetModuleInfoFromHandle ((EFI_HANDLE *)Handle, ModuleName, sizeof (Modul= eName), &ModuleGuid); - - // - // Fill in the record information. + // 4. Fill in the FPDT record according to different Performance Identif= ier. // - switch (RecordInfo.Type) { - case FPDT_GUID_EVENT_TYPE: - FpdtRecordPtr.GuidEvent->Header.Type =3D FPDT_GUID_EVEN= T_TYPE; - FpdtRecordPtr.GuidEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.GuidEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.GuidEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.GuidEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtReco= rdPtr.GuidEvent->Guid)); + switch (PerfId) { + case MODULE_START_ID: + case MODULE_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + StringPtr =3D ModuleName; + // + // Cache the offset of start image start record and use to update the = start image end record if needed. + // + if (Attribute =3D=3D PerfEntry && PerfId =3D=3D MODULE_START_ID) { + if (mFpdtBufferIsReported) { + mCachedLength =3D mBootRecordSize; + } else { + mCachedLength =3D mPerformanceLength; + } + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidEvent->Header.Type =3D FPDT_GUID_EV= ENT_TYPE; + FpdtRecordPtr.GuidEvent->Header.Length =3D sizeof (FPDT= _GUID_EVENT_RECORD); + FpdtRecordPtr.GuidEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.GuidEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRe= cordPtr.GuidEvent->Guid)); + if (CallerIdentifier =3D=3D NULL && PerfId =3D=3D MODULE_END_ID && m= CachedLength !=3D 0) { + if (mFpdtBufferIsReported) { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMA= NCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength); + } else { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMA= NCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength); + } + CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.Guid= Event->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid)); + mCachedLength =3D 0; + } + } break; =20 - case FPDT_DYNAMIC_STRING_EVENT_TYPE: - FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC_S= TRING_EVENT_TYPE; - FpdtRecordPtr.DynamicStringEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.DynamicStringEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof = (FpdtRecordPtr.DynamicStringEvent->Guid)); - - if (UseModuleName) { - StringPtr =3D ModuleName; - } else if (Token !=3D NULL) { - StringPtr =3D Token; - } else if (Module !=3D NULL) { - StringPtr =3D Module; - } else if (ModuleName !=3D NULL) { - StringPtr =3D ModuleName; + case MODULE_LOADIMAGE_START_ID: + case MODULE_LOADIMAGE_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + StringPtr =3D ModuleName; + if (PerfId =3D=3D MODULE_LOADIMAGE_START_ID) { + mLoadImageCount ++; + // + // Cache the offset of load image start record and use to be updated= by the load image end record if needed. + // + if (CallerIdentifier =3D=3D NULL && Attribute =3D=3D PerfEntry) { + if (mFpdtBufferIsReported) { + mCachedLength =3D mBootRecordSize; + } else { + mCachedLength =3D mPerformanceLength; + } + } } - if (StringPtr !=3D NULL && AsciiStrLen (StringPtr) !=3D 0) { - StrLength =3D AsciiStrLen (StringPtr); - DestMax =3D (RecordInfo.RecordSize - sizeof (FPDT_DYNAMIC_STRI= NG_EVENT_RECORD)) / sizeof (CHAR8); - if (StrLength >=3D DestMax) { - StrLength =3D DestMax -1; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QW= ORD_EVENT_TYPE; + FpdtRecordPtr.GuidQwordEvent->Header.Length =3D sizeof (FPDT= _GUID_QWORD_EVENT_RECORD); + FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.GuidQwordEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; + FpdtRecordPtr.GuidQwordEvent->Qword =3D mLoadImageCo= unt; + CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (F= pdtRecordPtr.GuidQwordEvent->Guid)); + if (PerfId =3D=3D MODULE_LOADIMAGE_END_ID && mCachedLength !=3D 0) { + if (mFpdtBufferIsReported) { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMA= NCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength); + } else { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMA= NCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength); + } + CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, s= izeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid)); + mCachedLength =3D 0; } - AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, St= ringPtr, StrLength); - } else { - AsciiStrCpyS (FpdtRecordPtr.DynamicStringEvent->String, FPDT_STRING_= EVENT_RECORD_NAME_LENGTH, "unknown name"); } break; =20 - case FPDT_GUID_QWORD_EVENT_TYPE: - FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QWOR= D_EVENT_TYPE; - FpdtRecordPtr.GuidQwordEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.GuidQwordEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (Fpd= tRecordPtr.GuidQwordEvent->Guid)); - if ((MODULE_LOADIMAGE_START_ID =3D=3D RecordInfo.ProgressID) && AsciiS= trCmp (Token, LOAD_IMAGE_TOK) =3D=3D 0) { - mLoadImageCount++; - FpdtRecordPtr.GuidQwordEvent->Qword =3D mLoadImageCoun= t; + case MODULE_DB_START_ID: + case MODULE_DB_SUPPORT_START_ID: + case MODULE_DB_SUPPORT_END_ID: + case MODULE_DB_STOP_START_ID: + case MODULE_DB_STOP_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + StringPtr =3D ModuleName; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QW= ORD_EVENT_TYPE; + FpdtRecordPtr.GuidQwordEvent->Header.Length =3D sizeof (FPDT= _GUID_QWORD_EVENT_RECORD); + FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.GuidQwordEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; + FpdtRecordPtr.GuidQwordEvent->Qword =3D Address; + CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (F= pdtRecordPtr.GuidQwordEvent->Guid)); } break; =20 - case FPDT_GUID_QWORD_STRING_EVENT_TYPE: - FpdtRecordPtr.GuidQwordStringEvent->Header.Type =3D FPDT_GUID_QWOR= D_STRING_EVENT_TYPE; - FpdtRecordPtr.GuidQwordStringEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.GuidQwordStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.GuidQwordStringEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.GuidQwordStringEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.GuidQwordStringEvent->Guid, &ModuleGuid, sizeo= f (FpdtRecordPtr.GuidQwordStringEvent->Guid)); + case MODULE_DB_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + StringPtr =3D ModuleName; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidQwordStringEvent->Header.Type =3D FPDT_GUID_QW= ORD_STRING_EVENT_TYPE; + FpdtRecordPtr.GuidQwordStringEvent->Header.Length =3D sizeof (FPDT= _GUID_QWORD_STRING_EVENT_RECORD);; + FpdtRecordPtr.GuidQwordStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.GuidQwordStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidQwordStringEvent->Timestamp =3D TimeStamp; + FpdtRecordPtr.GuidQwordStringEvent->Qword =3D Address; + CopyMem (&FpdtRecordPtr.GuidQwordStringEvent->Guid, &ModuleGuid, siz= eof (FpdtRecordPtr.GuidQwordStringEvent->Guid)); + if (Address !=3D 0) { + GetDeviceInfoFromHandleAndUpdateLength(CallerIdentifier, (EFI_HAND= LE)(UINTN)Address, FpdtRecordPtr.GuidQwordStringEvent->String, &FpdtRecordP= tr.GuidQwordStringEvent->Header.Length); + } + } break; =20 - default: + case PERF_EVENTSIGNAL_START_ID: + case PERF_EVENTSIGNAL_END_ID: + case PERF_CALLBACK_START_ID: + case PERF_CALLBACK_END_ID: + if (String =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } // - // Record is not supported in current DXE phase, return EFI_ABORTED + // Cache the event guid in string event record when PcdEdkiiFpdtString= RecordEnableOnly =3D=3D TRUE // - return EFI_UNSUPPORTED; + CopyGuid (&ModuleGuid, Guid); + StringPtr =3D String; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DualGuidStringEvent->Header.Type =3D FPDT_DUAL_GU= ID_STRING_EVENT_TYPE; + FpdtRecordPtr.DualGuidStringEvent->Header.Length =3D sizeof (FPDT= _DUAL_GUID_STRING_EVENT_RECORD); + FpdtRecordPtr.DualGuidStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.DualGuidStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DualGuidStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier= , sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1)); + CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (Fp= dtRecordPtr.DualGuidStringEvent->Guid2)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStrin= gEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Lengt= h); + } + break; + + case PERF_EVENT_ID: + case PERF_FUNCTION_START_ID: + case PERF_FUNCTION_END_ID: + case PERF_INMODULE_START_ID: + case PERF_INMODULE_END_ID: + case PERF_CROSSMODULE_START_ID: + case PERF_CROSSMODULE_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + if (String !=3D NULL) { + StringPtr =3D String; + } else { + StringPtr =3D ModuleName; + } + if (AsciiStrLen (StringPtr) =3D=3D 0) { + StringPtr =3D "unknown name"; + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC= _STRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPDT= _DYNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeo= f (FpdtRecordPtr.DynamicStringEvent->Guid)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicString= Event->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length); + } + break; + + default: + if (Attribute !=3D PerfEntry) { + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName,= sizeof (ModuleName), &ModuleGuid); + if (String !=3D NULL) { + StringPtr =3D String; + } else { + StringPtr =3D ModuleName; + } + if (AsciiStrLen (StringPtr) =3D=3D 0) { + StringPtr =3D "unknown name"; + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAM= IC_STRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FP= DT_DYNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECOR= D_REVISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, siz= eof (FpdtRecordPtr.DynamicStringEvent->Guid)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStri= ngEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Lengt= h); + } + } else { + return EFI_INVALID_PARAMETER; + } + break; + } + + // + // 4.2 When PcdEdkiiFpdtStringRecordEnableOnly=3D=3DTRUE, create string = record for all Perf entries. + // + if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + if (StringPtr =3D=3D NULL ||PerfId =3D=3D MODULE_DB_SUPPORT_START_ID |= | PerfId =3D=3D MODULE_DB_SUPPORT_END_ID) { + return EFI_INVALID_PARAMETER; + } + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC_S= TRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPDT_D= YNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof = (FpdtRecordPtr.DynamicStringEvent->Guid)); + if (AsciiStrLen (StringPtr) =3D=3D 0) { + StringPtr =3D "unknown name"; + } + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEv= ent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length); + + if ((PerfId =3D=3D MODULE_LOADIMAGE_START_ID) || (PerfId =3D=3D MODULE= _END_ID)) { + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D (UINT8)(sizeof (= FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE); + } + if ((PerfId =3D=3D MODULE_LOADIMAGE_END_ID || PerfId =3D=3D MODULE_END= _ID) && mCachedLength !=3D 0) { + if (mFpdtBufferIsReported) { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANC= E_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength); + } else { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANC= E_RECORD_HEADER *)(mPerformancePointer + mCachedLength); + } + if (PerfId =3D=3D MODULE_LOADIMAGE_END_ID) { + DestMax =3D CachedFpdtRecordPtr.DynamicStringEvent->Header.Length = - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD); + StringLen =3D AsciiStrLen (StringPtr); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } + CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGui= d, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid)); + AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, Des= tMax, StringPtr, StringLen); + } else if (PerfId =3D=3D MODULE_END_ID) { + DestMax =3D FpdtRecordPtr.DynamicStringEvent->Header.Length - size= of (FPDT_DYNAMIC_STRING_EVENT_RECORD); + StringLen =3D AsciiStrLen (CachedFpdtRecordPtr.DynamicStringEvent-= >String); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecor= dPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEve= nt->Guid)); + AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, = CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen); + } + mCachedLength =3D 0; + } } =20 + // + // 5. Update the length of the used buffer after fill in the record. + // + if (mFpdtBufferIsReported) { + mBootRecordSize +=3D FpdtRecordPtr.RecordHeader->Length; + mAcpiBootPerformanceTable->Header.Length +=3D FpdtRecordPtr.RecordHead= er->Length; + } else { + mPerformanceLength +=3D FpdtRecordPtr.RecordHeader->Length; + } return EFI_SUCCESS; } =20 /** Dumps all the PEI performance. @@ -1158,15 +1454,12 @@ CreatePerformanceMeasurement ( if (mLockInsertRecord) { return EFI_INVALID_PARAMETER; } mLockInsertRecord =3D TRUE; =20 - if (Attribute =3D=3D PerfStartEntry) { - Status =3D InsertFpdtMeasurement (TRUE, CallerIdentifier, String, Stri= ng, TimeStamp, Identifier); - } else if (Attribute =3D=3D PerfEndEntry) { - Status =3D InsertFpdtMeasurement (FALSE, CallerIdentifier, String, Str= ing, TimeStamp, Identifier); - } + Status =3D InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, = Address, (UINT16)Identifier, Attribute); + mLockInsertRecord =3D FALSE; =20 return Status; } =20 @@ -1470,5 +1763,60 @@ 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, 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/DxeCorePerformanceLib/DxeCorePerformanceL= ib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.i= nf index 68cd76da5b3..3e77f9cd57a 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf @@ -59,10 +59,11 @@ DebugLib UefiLib ReportStatusCodeLib DxeServicesLib PeCoffGetEntryPointLib + DevicePathLib =20 [Protocols] gEfiSmmCommunicationProtocolGuid ## SOMETIMES_CONSUMES =20 =20 diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceL= ibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanc= eLibInternal.h index f9800e34941..a96f4081503 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInter= nal.h +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInter= nal.h @@ -40,10 +40,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include #include #include #include +#include #include #include #include #include #include diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/M= deModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c index 9ed50d22b8d..664e8261af9 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c @@ -376,5 +376,73 @@ 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 + ) +{ + EFI_STATUS Status; + + Status =3D GetPerformanceMeasurementProtocol (); + if (EFI_ERROR (Status)) { + return RETURN_OUT_OF_RESOURCES; + } + + if (mPerformanceMeasurement !=3D NULL) { + Status =3D mPerformanceMeasurement->CreatePerformanceMeasurement (Call= erIdentifier, Guid, String, 0, Address, Identifier, PerfEntry); + } else { + ASSERT (FALSE); + } + + return (RETURN_STATUS) Status; +} + +/** + 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/PeiPerformanceLib/PeiPerformanceLib.c b/M= deModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index f770a35a995..cd1b0e34ef7 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -21,21 +21,100 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EIT= HER EXPRESS OR IMPLIED. =20 =20 #include =20 #include +#include =20 #include #include #include #include #include #include #include =20 #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * si= zeof (CHAR8)) -#define MAX_RECORD_SIZE (sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)= + STRING_SIZE) +#define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECOR= D) + STRING_SIZE) + + +/** + Return the pointer to the FPDT record in the allocated memory. + + @param RecordSize The size of FPDT record. + @param FpdtRecordPtr Pointer the FPDT record in the allocat= ed memory. + @param PeiPerformanceLogHeader Pointer to the header of the PEI Perfo= rmance records in the GUID Hob. + + @retval EFI_SUCCESS Successfully get the pointer to the FP= DT record. + @retval EFI_OUT_OF_RESOURCES Ran out of space to store the records. +**/ +EFI_STATUS +GetFpdtRecordPtr ( + IN UINT8 RecordSize, + IN OUT FPDT_RECORD_PTR *FpdtRecordPtr, + IN OUT FPDT_PEI_EXT_PERF_HEADER **PeiPerformanceLogHeader +) +{ + UINT16 PeiPerformanceLogEntries; + UINTN PeiPerformanceSize; + UINT8 *PeiFirmwarePerformance; + EFI_HOB_GUID_TYPE *GuidHob; + + // + // Get the number of PeiPerformanceLogEntries form PCD. + // + PeiPerformanceLogEntries =3D (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLog= Entries16) !=3D 0 ? + PcdGet16 (PcdMaxPeiPerformanceLogEn= tries16) : + PcdGet8 (PcdMaxPeiPerformanceLogEnt= ries)); + + // + // Create GUID HOB Data. + // + GuidHob =3D GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); + PeiFirmwarePerformance =3D NULL; + while (GuidHob !=3D NULL) { + // + // PEI Performance HOB was found, then return the existing one. + // + PeiFirmwarePerformance =3D (UINT8*)GET_GUID_HOB_DATA (GuidHob); + *PeiPerformanceLogHeader =3D (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePe= rformance; + if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeade= r)->SizeOfAllEntries + RecordSize > (UINTN)(PeiPerformanceLogEntries * PEI_= MAX_RECORD_SIZE)) { + (*PeiPerformanceLogHeader)->HobIsFull =3D TRUE; + } + if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeade= r)->SizeOfAllEntries + RecordSize <=3D (UINTN)(PeiPerformanceLogEntries * P= EI_MAX_RECORD_SIZE)) { + FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECOR= D_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + (*= PeiPerformanceLogHeader)->SizeOfAllEntries); + break; + } + // + // Previous HOB is used, then find next one. + // + GuidHob =3D GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid= , GET_NEXT_HOB (GuidHob)); + } + + if (GuidHob =3D=3D NULL) { + // + // PEI Performance HOB was not found, then build one. + // + PeiPerformanceSize =3D sizeof (FPDT_PEI_EXT_PERF_HEADER) + + PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntri= es; + PeiFirmwarePerformance =3D (UINT8*)BuildGuidHob (&gEdkiiFpdtExtendedF= irmwarePerformanceGuid, PeiPerformanceSize); + if (PeiFirmwarePerformance !=3D NULL) { + ZeroMem (PeiFirmwarePerformance, PeiPerformanceSize); + (*PeiPerformanceLogHeader) =3D (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwa= rePerformance; + FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECOR= D_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER)); + } + } + + if (PeiFirmwarePerformance =3D=3D NULL) { + // + // there is no enough resource to store performance data + // + return EFI_OUT_OF_RESOURCES; + } + + return EFI_SUCCESS; +} =20 /** Check whether the Token is a known one which is uesed by core. =20 @param Token Pointer to a Null-terminated ASCII string @@ -98,252 +177,197 @@ IsKnownID ( return FALSE; } } =20 /** - Get the FPDT record info. + Get the FPDT record identifier. =20 - @param IsStart TRUE if the performance log is start log. - @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 RecordInfo On return, pointer to the info of the re= cord. + @param Attribute The attribute of the Record. + PerfStartEntry: Start Record. + PerfEndEntry: End Record. + @param Handle Pointer to environment specific context = used to identify the component being measured. + @param String Pointer to a Null-terminated ASCII strin= g that identifies the component being measured. + @param ProgressID On return, pointer to the ProgressID. =20 - @retval EFI_SUCCESS Get record info successfully. - @retval EFI_UNSUPPORTED No matched FPDT record. + @retval EFI_SUCCESS Get record info successfully. + @retval EFI_INVALID_PARAMETER No matched FPDT record. =20 **/ EFI_STATUS -GetFpdtRecordInfo ( - IN BOOLEAN IsStart, +GetFpdtRecordId ( + IN BOOLEAN Attribute, IN CONST VOID *Handle, - IN CONST CHAR8 *Token, - IN CONST CHAR8 *Module, - OUT FPDT_BASIC_RECORD_INFO *RecordInfo + IN CONST CHAR8 *String, + OUT UINT16 *ProgressID ) { - UINTN StringSize; - UINT16 RecordType; - - RecordType =3D FPDT_DYNAMIC_STRING_EVENT_TYPE; - // // Get the ProgressID based on the Token. // When PcdEdkiiFpdtStringRecordEnableOnly is TRUE, all records are with= type of FPDT_DYNAMIC_STRING_EVENT_TYPE. // - if (Token !=3D NULL) { - if (AsciiStrCmp (Token, LOAD_IMAGE_TOK) =3D=3D 0) { // "= LoadImage:" - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_LOADIMAGE_START_ID; + if (String !=3D NULL) { + if (AsciiStrCmp (String, LOAD_IMAGE_TOK) =3D=3D 0) { // = "LoadImage:" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_LOADIMAGE_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_LOADIMAGE_END_ID; + *ProgressID =3D MODULE_LOADIMAGE_END_ID; } - if(!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { - RecordType =3D FPDT_GUID_QWORD_EVENT_TYPE; - } - } else if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || // "= SEC" - AsciiStrCmp (Token, PEI_TOK) =3D=3D 0) { // "= PEI" - if (IsStart) { - RecordInfo->ProgressID =3D PERF_CROSSMODULE_START_ID; + } else if (AsciiStrCmp (String, SEC_TOK) =3D=3D 0 || // = "SEC" + AsciiStrCmp (String, PEI_TOK) =3D=3D 0) { // = "PEI" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_CROSSMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_CROSSMODULE_END_ID; + *ProgressID =3D PERF_CROSSMODULE_END_ID; } - } else if (AsciiStrCmp (Token, PEIM_TOK) =3D=3D 0) { // "= PEIM" - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_START_ID; + } else if (AsciiStrCmp (String, PEIM_TOK) =3D=3D 0) { // = "PEIM" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_END_ID; - } - if(!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { - RecordType =3D FPDT_GUID_EVENT_TYPE; + *ProgressID =3D MODULE_END_ID; } } else { //Pref u= sed in Modules. - if (IsStart) { - RecordInfo->ProgressID =3D PERF_INMODULE_START_ID; + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_INMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_INMODULE_END_ID; + *ProgressID =3D PERF_INMODULE_END_ID; } } - } else if (Module !=3D NULL || Handle !=3D NULL) { //Pr= ef used in Modules. - if (IsStart) { - RecordInfo->ProgressID =3D PERF_INMODULE_START_ID; + } else if (Handle !=3D NULL) { //Pref= used in Modules. + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_INMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_INMODULE_END_ID; + *ProgressID =3D PERF_INMODULE_END_ID; } } else { - return EFI_UNSUPPORTED; + return EFI_INVALID_PARAMETER; } =20 - // - // Get the Guid and string. - // - if(PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { - RecordInfo->RecordSize =3D sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) += STRING_SIZE; - } else { - switch (RecordType) { - case FPDT_GUID_EVENT_TYPE: - RecordInfo->RecordSize =3D sizeof (FPDT_GUID_EVENT_RECORD); - break; + return EFI_SUCCESS; +} =20 - case FPDT_GUID_QWORD_EVENT_TYPE: - RecordInfo->RecordSize =3D sizeof (FPDT_GUID_QWORD_EVENT_RECORD); - break; +/** + Copies the string from Source into Destination and updates Length with t= he + size of the string. =20 - case FPDT_DYNAMIC_STRING_EVENT_TYPE: - if (Token !=3D NULL) { - StringSize =3D AsciiStrSize (Token); - } else if (Module !=3D NULL) { - StringSize =3D AsciiStrSize (Module); - } else { - StringSize =3D STRING_SIZE; - } - RecordInfo->RecordSize =3D (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVEN= T_RECORD) + StringSize); - break; + @param Destination - destination of the string copy + @param Source - pointer to the source string which will get copied + @param Length - pointer to a length variable to be updated =20 - default: - // - // Other type is unsupported in PEI phase yet, return EFI_UNSUPPORTED - // - return EFI_UNSUPPORTED; +**/ +VOID +CopyStringIntoPerfRecordAndUpdateLength ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN OUT UINT8 *Length + ) +{ + UINTN StringLen; + UINTN DestMax; + + ASSERT (Source !=3D NULL); + + if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + DestMax =3D STRING_SIZE; + } else { + DestMax =3D AsciiStrSize (Source); + if (DestMax > STRING_SIZE) { + DestMax =3D STRING_SIZE; } } - RecordInfo->Type =3D RecordType; - return EFI_SUCCESS; + StringLen =3D AsciiStrLen (Source); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } + + AsciiStrnCpyS(Destination, DestMax, Source, StringLen); + *Length +=3D (UINT8)DestMax; + + return; } =20 + /** Convert PEI performance log to FPDT String boot record. =20 - @param IsStart TRUE if the performance log is start log. - @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 Ticker 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 StartGauge= of PERFORMANCE_PROTOCOL. - - @retval EFI_SUCCESS Add FPDT boot record. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to recor= d the measurement. - @retval EFI_UNSUPPORTED No matched FPDT record. + @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 Ticker - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to t= he measurement. + @param PerfId - 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. =20 **/ EFI_STATUS -InsertPeiFpdtMeasurement ( - IN BOOLEAN IsStart, - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 Ticker, - IN UINT32 Identifier +InsertFpdtRecord ( + IN CONST VOID *CallerIdentifier, OPTIONAL + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 Ticker, + IN UINT64 Address, OPTIONAL + IN UINT16 PerfId, + IN PERF_MEASUREMENT_ATTRIBUTE Attribute ) { - EFI_HOB_GUID_TYPE *GuidHob; - UINTN PeiPerformanceSize; - UINT8 *PeiFirmwarePerformance; - FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader; FPDT_RECORD_PTR FpdtRecordPtr; - FPDT_BASIC_RECORD_INFO RecordInfo; CONST VOID *ModuleGuid; - UINTN DestMax; - UINTN StrLength; CONST CHAR8 *StringPtr; EFI_STATUS Status; - UINT16 PeiPerformanceLogEntries; UINT64 TimeStamp; + FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader; =20 StringPtr =3D NULL; FpdtRecordPtr.RecordHeader =3D NULL; PeiPerformanceLogHeader =3D NULL; =20 // - // Get record info (type, size, ProgressID and Module Guid). - // - Status =3D GetFpdtRecordInfo (IsStart, Handle, Token, Module, &RecordInf= o); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // If PERF_START()/PERF_END() have specified the ProgressID,it has high = priority. - // !!! Note: If the Perf is not the known Token used in the core but hav= e same - // ID with the core Token, this case will not be supported. - // And in currtnt usage mode, for the unkown ID, there is a general rule: - // If it is start pref: the lower 4 bits of the ID should be 0. - // If it is end pref: the lower 4 bits of the ID should not be 0. - // If input ID doesn't follow the rule, we will adjust it. + // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_E= X/PERF_END_EX. + // notes: For other Perf macros (Attribute =3D=3D PerfEntry), their I= d is known. // - if ((Identifier !=3D 0) && (IsKnownID (Identifier)) && (!IsKnownTokens (= Token))) { - return EFI_UNSUPPORTED; - } else if ((Identifier !=3D 0) && (!IsKnownID (Identifier)) && (!IsKnown= Tokens (Token))) { - if (IsStart && ((Identifier & 0x000F) !=3D 0)) { - Identifier &=3D 0xFFF0; - } else if ((!IsStart) && ((Identifier & 0x000F) =3D=3D 0)) { - Identifier +=3D 1; - } - RecordInfo.ProgressID =3D (UINT16)Identifier; - } - - // - // Get the number of PeiPerformanceLogEntries form PCD. - // - PeiPerformanceLogEntries =3D (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLog= Entries16) !=3D 0 ? - PcdGet16 (PcdMaxPeiPerformanceLogEn= tries16) : - PcdGet8 (PcdMaxPeiPerformanceLogEnt= ries)); - - // - // Create GUID HOB Data. - // - GuidHob =3D GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); - PeiFirmwarePerformance =3D NULL; - while (GuidHob !=3D NULL) { - // - // PEI Performance HOB was found, then return the existing one. - // - PeiFirmwarePerformance =3D (UINT8*)GET_GUID_HOB_DATA (GuidHob); - PeiPerformanceLogHeader =3D (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePer= formance; - if (!PeiPerformanceLogHeader->HobIsFull && PeiPerformanceLogHeader->Si= zeOfAllEntries + RecordInfo.RecordSize > PeiPerformanceLogEntries * MAX_REC= ORD_SIZE) { - PeiPerformanceLogHeader->HobIsFull =3D TRUE; - } - if (!PeiPerformanceLogHeader->HobIsFull && PeiPerformanceLogHeader->Si= zeOfAllEntries + RecordInfo.RecordSize <=3D PeiPerformanceLogEntries * MAX_= RECORD_SIZE) { - FpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD= _HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + Pei= PerformanceLogHeader->SizeOfAllEntries); - break; - } - // - // Previous HOB is used, then find next one. - // - GuidHob =3D GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid= , GET_NEXT_HOB (GuidHob)); - } - - if (GuidHob =3D=3D NULL) { + if (Attribute !=3D PerfEntry) { // - // PEI Performance HOB was not found, then build one. + // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it h= as high priority. + // !!! Note: If the Perf is not the known Token used in the core but h= ave same + // ID with the core Token, this case will not be supported. + // And in currtnt usage mode, for the unkown ID, there is a general ru= le: + // If it is start pref: the lower 4 bits of the ID should be 0. + // If it is end pref: the lower 4 bits of the ID should not be 0. + // If input ID doesn't follow the rule, we will adjust it. // - PeiPerformanceSize =3D sizeof (FPDT_PEI_EXT_PERF_HEADER) + - MAX_RECORD_SIZE * PeiPerformanceLogEntries; - PeiFirmwarePerformance =3D (UINT8*)BuildGuidHob (&gEdkiiFpdtExtendedF= irmwarePerformanceGuid, PeiPerformanceSize); - if (PeiFirmwarePerformance !=3D NULL) { - ZeroMem (PeiFirmwarePerformance, PeiPerformanceSize); + if ((PerfId !=3D 0) && (IsKnownID (PerfId)) && (!IsKnownTokens (String= ))) { + return EFI_UNSUPPORTED; + } else if ((PerfId !=3D 0) && (!IsKnownID (PerfId)) && (!IsKnownTokens= (String))) { + if (Attribute =3D=3D PerfStartEntry && ((PerfId & 0x000F) !=3D 0)) { + PerfId &=3D 0xFFF0; + } else if ((Attribute =3D=3D PerfEndEntry) && ((PerfId & 0x000F) =3D= =3D 0)) { + PerfId +=3D 1; + } + } else if (PerfId =3D=3D 0) { + Status =3D GetFpdtRecordId (Attribute, CallerIdentifier, String, &Pe= rfId); + if (EFI_ERROR (Status)) { + return Status; + } } - PeiPerformanceLogHeader =3D (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePer= formance; - FpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_H= EADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER)); } =20 - if (PeiFirmwarePerformance =3D=3D NULL) { - // - // there is no enough resource to store performance data - // - return EFI_OUT_OF_RESOURCES; + // + // 2. Get the buffer to store the FPDT record. + // + Status =3D GetFpdtRecordPtr (PEI_MAX_RECORD_SIZE, &FpdtRecordPtr, &PeiPe= rformanceLogHeader); + if (EFI_ERROR (Status)) { + return Status; } =20 // - // Get the TimeStamp. + // 3 Get the TimeStamp. // if (Ticker =3D=3D 0) { Ticker =3D GetPerformanceCounter (); TimeStamp =3D GetTimeInNanoSecond (Ticker); } else if (Ticker =3D=3D 1) { @@ -351,74 +375,142 @@ InsertPeiFpdtMeasurement ( } else { TimeStamp =3D GetTimeInNanoSecond (Ticker); } =20 // - // Get the ModuleGuid. + // 4.Get the ModuleGuid. // - if (Handle !=3D NULL) { - ModuleGuid =3D Handle; + if (CallerIdentifier !=3D NULL) { + ModuleGuid =3D CallerIdentifier; } else { ModuleGuid =3D &gEfiCallerIdGuid; } =20 - switch (RecordInfo.Type) { - case FPDT_GUID_EVENT_TYPE: - FpdtRecordPtr.GuidEvent->Header.Type =3D FPDT_GUID_EVENT_TYPE; - FpdtRecordPtr.GuidEvent->Header.Length =3D RecordInfo.RecordSize;; - FpdtRecordPtr.GuidEvent->Header.Revision =3D FPDT_RECORD_REVISION_1; - FpdtRecordPtr.GuidEvent->ProgressID =3D RecordInfo.ProgressID; - FpdtRecordPtr.GuidEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.GuidEvent->Guid, ModuleGuid, sizeof (EFI_GUID)= ); - PeiPerformanceLogHeader->SizeOfAllEntries +=3D RecordInfo.RecordSize; + // + // 5. Fill in the FPDT record according to different Performance Identif= ier. + // + switch (PerfId) { + case MODULE_START_ID: + case MODULE_END_ID: + StringPtr =3D PEIM_TOK; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidEvent->Header.Type =3D FPDT_GUID_EVENT_TYPE; + FpdtRecordPtr.GuidEvent->Header.Length =3D sizeof (FPDT_GUID_EVE= NT_RECORD); + FpdtRecordPtr.GuidEvent->Header.Revision =3D FPDT_RECORD_REVISION_= 1; + FpdtRecordPtr.GuidEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.GuidEvent->Guid, ModuleGuid, sizeof (EFI_GUI= D)); + } break; =20 - case FPDT_GUID_QWORD_EVENT_TYPE: - FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QWORD_EVEN= T_TYPE; - FpdtRecordPtr.GuidQwordEvent->Header.Length =3D RecordInfo.RecordSiz= e;; - FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_REVISION= _1; - FpdtRecordPtr.GuidQwordEvent->ProgressID =3D RecordInfo.ProgressI= D; - FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; - PeiPerformanceLogHeader->LoadImageCount++; - FpdtRecordPtr.GuidQwordEvent->Qword =3D PeiPerformanceLogHea= der->LoadImageCount; - CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, ModuleGuid, sizeof (EFI_= GUID)); - PeiPerformanceLogHeader->SizeOfAllEntries +=3D RecordInfo.RecordSize; + case MODULE_LOADIMAGE_START_ID: + case MODULE_LOADIMAGE_END_ID: + StringPtr =3D LOAD_IMAGE_TOK; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QWORD_EV= ENT_TYPE; + FpdtRecordPtr.GuidQwordEvent->Header.Length =3D sizeof (FPDT_GUID_= QWORD_EVENT_RECORD); + FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_REVISI= ON_1; + FpdtRecordPtr.GuidQwordEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; + if (PerfId =3D=3D MODULE_LOADIMAGE_START_ID) { + PeiPerformanceLogHeader->LoadImageCount++; + } + FpdtRecordPtr.GuidQwordEvent->Qword =3D PeiPerformanceLogH= eader->LoadImageCount; + CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, ModuleGuid, sizeof (EF= I_GUID)); + } break; =20 - case FPDT_DYNAMIC_STRING_EVENT_TYPE: - FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC_S= TRING_EVENT_TYPE; - FpdtRecordPtr.DynamicStringEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.DynamicStringEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (= EFI_GUID)); - PeiPerformanceLogHeader->SizeOfAllEntries +=3D RecordInfo.RecordSize; - - if (Token !=3D NULL) { - StringPtr =3D Token; - } else if (Module !=3D NULL) { - StringPtr =3D Module; + case PERF_EVENTSIGNAL_START_ID: + case PERF_EVENTSIGNAL_END_ID: + case PERF_CALLBACK_START_ID: + case PERF_CALLBACK_END_ID: + if (String !=3D NULL && AsciiStrLen (String) !=3D 0) { + StringPtr =3D String; + } else { + StringPtr =3D "unknown name"; } - if (StringPtr !=3D NULL && AsciiStrLen (StringPtr) !=3D 0) { - DestMax =3D (RecordInfo.RecordSize - sizeof (F= PDT_DYNAMIC_STRING_EVENT_RECORD)) / sizeof (CHAR8); - StrLength =3D AsciiStrLen (StringPtr); - if (StrLength >=3D DestMax) { - StrLength =3D DestMax -1; - } - AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, St= ringPtr, StrLength); + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DualGuidStringEvent->Header.Type =3D FPDT_DUAL_GU= ID_STRING_EVENT_TYPE; + FpdtRecordPtr.DualGuidStringEvent->Header.Length =3D sizeof (FPDT= _DUAL_GUID_STRING_EVENT_RECORD); + FpdtRecordPtr.DualGuidStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.DualGuidStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DualGuidStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, ModuleGuid, size= of (FpdtRecordPtr.DualGuidStringEvent->Guid1)); + CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (Fp= dtRecordPtr.DualGuidStringEvent->Guid2)); + } + break; + + case PERF_EVENT_ID: + case PERF_FUNCTION_START_ID: + case PERF_FUNCTION_END_ID: + case PERF_INMODULE_START_ID: + case PERF_INMODULE_END_ID: + case PERF_CROSSMODULE_START_ID: + case PERF_CROSSMODULE_END_ID: + if (String !=3D NULL && AsciiStrLen (String) !=3D 0) { + StringPtr =3D String; } else { - AsciiStrCpyS (FpdtRecordPtr.DynamicStringEvent->String, FPDT_STRING_= EVENT_RECORD_NAME_LENGTH, "unknown name"); + StringPtr =3D "unknown name"; + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC= _STRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPDT= _DYNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof= (EFI_GUID)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicString= Event->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length); } break; =20 default: - // - // Record is not supported in current PEI phase, return EFI_ABORTED - // - return EFI_UNSUPPORTED; + if (Attribute !=3D PerfEntry) { + if (String !=3D NULL && AsciiStrLen (String) !=3D 0) { + StringPtr =3D String; + } else { + StringPtr =3D "unknown name"; + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMI= C_STRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPD= T_DYNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD= _REVISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeo= f (FpdtRecordPtr.DynamicStringEvent->Guid)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStrin= gEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length= ); + } + } else { + return EFI_INVALID_PARAMETER; + } + break; + } + + // + // 5.2 When PcdEdkiiFpdtStringRecordEnableOnly=3D=3DTRUE, create string = record for all Perf entries. + // + if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC_S= TRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPDT_D= YNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + if (Guid !=3D NULL) { + // + // Cache the event guid in string event record. + // + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (EFI_= GUID)); + } else { + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof= (EFI_GUID)); + } + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEv= ent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length); } =20 + // + // 6. Update the length of the used buffer after fill in the record. + // + PeiPerformanceLogHeader->SizeOfAllEntries +=3D FpdtRecordPtr.RecordHeade= r->Length; + return EFI_SUCCESS; } =20 /** Creates a record for the beginning of a performance measurement. @@ -452,11 +544,22 @@ StartPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - return InsertPeiFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp,= Identifier); + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return (RETURN_STATUS)InsertFpdtRecord (Handle, NULL, String, TimeStamp,= 0, (UINT16)Identifier, PerfStartEntry); + } =20 /** =20 Creates a record for the end of a performance measurement. @@ -487,11 +590,21 @@ EndPerformanceMeasurementEx ( IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp, IN UINT32 Identifier ) { - return InsertPeiFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp= , Identifier); + CONST CHAR8 *String; + + if (Token !=3D NULL) { + String =3D Token; + } else if (Module !=3D NULL) { + String =3D Module; + } else { + String =3D NULL; + } + + return (RETURN_STATUS)InsertFpdtRecord (Handle, NULL, String, TimeStamp,= 0, (UINT16)Identifier, PerfEndEntry); } =20 /** 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, @@ -580,11 +693,11 @@ StartPerformanceMeasurement ( IN CONST CHAR8 *Token, OPTIONAL IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp ) { - return InsertPeiFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp,= 0); + return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, = 0); } =20 /** =20 Creates a record for the end of a performance measurement. @@ -612,11 +725,11 @@ EndPerformanceMeasurement ( IN CONST CHAR8 *Token, OPTIONAL IN CONST CHAR8 *Module, OPTIONAL IN UINT64 TimeStamp ) { - return InsertPeiFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp= , 0); + return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0); } =20 /** 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, @@ -690,5 +803,60 @@ 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)InsertFpdtRecord (CallerIdentifier, Guid, 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/SmmCorePerformanceLib/SmmCorePerformanceL= ib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index e630773562f..0c00fb51e82 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -45,23 +45,83 @@ typedef struct { HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; UINTN mCachePairCount =3D 0; =20 UINT32 mPerformanceLength =3D 0; UINT32 mMaxPerformanceLength =3D 0; +UINT32 mLoadImageCount =3D 0; BOOLEAN mFpdtDataIsReported =3D FALSE; BOOLEAN mLackSpaceIsReport =3D FALSE; CHAR8 *mPlatformLanguage =3D NULL; SPIN_LOCK mSmmFpdtLock; PERFORMANCE_PROPERTY mPerformanceProperty; +UINT32 mCachedLength =3D 0; =20 // // Interfaces for SMM PerformanceMeasurement Protocol. // EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = =3D { CreatePerformanceMeasurement, }; =20 +/** + Return the pointer to the FPDT record in the allocated memory. + + @param RecordSize The size of FPDT record. + @param FpdtRecordPtr Pointer the FPDT record in the allocated = memory. + + @retval EFI_SUCCESS Successfully get the pointer to the FPDT = record. + @retval EFI_OUT_OF_RESOURCES Ran out of space to store the records. +**/ +EFI_STATUS +GetFpdtRecordPtr ( + IN UINT8 RecordSize, + IN OUT FPDT_RECORD_PTR *FpdtRecordPtr +) +{ + if (mFpdtDataIsReported) { + // + // Append Boot records after Smm boot performance records have been re= ported. + // + if (mPerformanceLength + RecordSize > mMaxPerformanceLength) { + if (!mLackSpaceIsReport) { + DEBUG ((DEBUG_INFO, "SmmCorePerformanceLib: No enough space to sav= e boot records\n")); + mLackSpaceIsReport =3D TRUE; + } + return EFI_OUT_OF_RESOURCES; + } else { + // + // Covert buffer to FPDT Ptr Union type. + // + FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECOR= D_HEADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->He= ader.Length); + } + } else { + // + // Check if pre-allocated buffer is full + // + if (mPerformanceLength + RecordSize > mMaxPerformanceLength) { + mSmmBootPerformanceTable =3D ReallocatePool ( + mPerformanceLength, + mPerformanceLength + sizeof (SMM_BOOT_P= ERFORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER, + mSmmBootPerformanceTable + ); + + if (mSmmBootPerformanceTable =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + mSmmBootPerformanceTable->Header.Length =3D sizeof (SMM_BOOT_PERFORM= ANCE_TABLE) + mPerformanceLength; + mMaxPerformanceLength =3D mPerformanceLength + sizeof (SMM_BOOT_PERF= ORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER; + } + // + // Covert buffer to FPDT Ptr Union type. + // + FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_= HEADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Head= er.Length); + } + FpdtRecordPtr->RecordHeader->Length =3D 0; + return EFI_SUCCESS; +} + + /** Check whether the Token is a known one which is uesed by core. =20 @param Token Pointer to a Null-terminated ASCII string =20 @@ -123,117 +183,63 @@ IsKnownID ( return FALSE; } } =20 /** - Get the FPDT record info. + Get the FPDT record identifier. =20 - @param IsStart TRUE if the performance log is start log. - @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 RecordInfo On return, pointer to the info of the re= cord. - @param UseModuleName Only useful for FPDT_DYNAMIC_STRING_EVEN= T_TYPE, indicate that whether need use - Module name to fill the string field in = the FPDT_DYNAMIC_STRING_EVENT_RECORD. + @param Attribute The attribute of the Record. + PerfStartEntry: Start Record. + PerfEndEntry: End Record. + @param Handle Pointer to environment specific context = used to identify the component being measured. + @param String Pointer to a Null-terminated ASCII strin= g that identifies the component being measured. + @param ProgressID On return, pointer to the ProgressID. =20 - @retval EFI_SUCCESS Get record info successfully. - @retval EFI_UNSUPPORTED No matched FPDT record. + @retval EFI_SUCCESS Get record info successfully. + @retval EFI_INVALID_PARAMETER No matched FPDT record. =20 **/ EFI_STATUS -GetFpdtRecordInfo ( - IN BOOLEAN IsStart, - IN CONST VOID *Handle, - IN CONST CHAR8 *Token, - IN CONST CHAR8 *Module, - OUT FPDT_BASIC_RECORD_INFO *RecordInfo, - IN OUT BOOLEAN *UseModuleName +GetFpdtRecordId ( + IN PERF_MEASUREMENT_ATTRIBUTE Attribute, + IN CONST VOID *Handle, + IN CONST CHAR8 *String, + OUT UINT16 *ProgressID ) { - UINT16 RecordType; - UINTN StringSize; - - RecordType =3D FPDT_DYNAMIC_STRING_EVENT_TYPE; - // - // Token to Type and Id. + // Token to Id. // - if (Token !=3D NULL) { - if (AsciiStrCmp (Token, START_IMAGE_TOK) =3D=3D 0) { // "= StartImage:" - *UseModuleName =3D TRUE; - RecordType =3D FPDT_GUID_EVENT_TYPE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_START_ID; + if (String !=3D NULL) { + if (AsciiStrCmp (String, START_IMAGE_TOK) =3D=3D 0) { // = "StartImage:" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_END_ID; + *ProgressID =3D MODULE_END_ID; } - } else if (AsciiStrCmp (Token, LOAD_IMAGE_TOK) =3D=3D 0) { // "= LoadImage:" - *UseModuleName =3D TRUE; - RecordType =3D FPDT_GUID_QWORD_EVENT_TYPE; - if (IsStart) { - RecordInfo->ProgressID =3D MODULE_LOADIMAGE_START_ID; + } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) =3D=3D 0) { // = "LoadImage:" + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D MODULE_LOADIMAGE_START_ID; } else { - RecordInfo->ProgressID =3D MODULE_LOADIMAGE_END_ID; + *ProgressID =3D MODULE_LOADIMAGE_END_ID; } } else { // Pref = used in Modules - if (IsStart) { - RecordInfo->ProgressID =3D PERF_INMODULE_START_ID; + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_INMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_INMODULE_END_ID; + *ProgressID =3D PERF_INMODULE_END_ID; } } - } else if (Handle !=3D NULL || Module !=3D NULL) { // Pr= ef used in Modules - if (IsStart) { - RecordInfo->ProgressID =3D PERF_INMODULE_START_ID; + } else if (Handle !=3D NULL) { // Pre= f used in Modules + if (Attribute =3D=3D PerfStartEntry) { + *ProgressID =3D PERF_INMODULE_START_ID; } else { - RecordInfo->ProgressID =3D PERF_INMODULE_END_ID; + *ProgressID =3D PERF_INMODULE_END_ID; } } else { return EFI_UNSUPPORTED; } - - if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { - RecordType =3D FPDT_DYNAMIC_STRING_EVENT_TYPE; - RecordInfo->RecordSize =3D sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)= + STRING_SIZE; - } else { - switch (RecordType) { - case FPDT_GUID_EVENT_TYPE: - RecordInfo->RecordSize =3D sizeof (FPDT_GUID_EVENT_RECORD); - break; - - case FPDT_DYNAMIC_STRING_EVENT_TYPE: - if (*UseModuleName) { - StringSize =3D STRING_SIZE; - } else if (Token !=3D NULL) { - StringSize =3D AsciiStrSize (Token); - } else if (Module !=3D NULL) { - StringSize =3D AsciiStrSize (Module); - } else { - StringSize =3D STRING_SIZE; - } - if (StringSize > STRING_SIZE) { - StringSize =3D STRING_SIZE; - } - RecordInfo->RecordSize =3D (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVEN= T_RECORD) + StringSize); - break; - - case FPDT_GUID_QWORD_EVENT_TYPE: - RecordInfo->RecordSize =3D (UINT8)sizeof (FPDT_GUID_QWORD_EVENT_REC= ORD); - break; - - default: - // - // Record type is unsupported in SMM phase. - // - return EFI_UNSUPPORTED; - } - } - - RecordInfo->Type =3D RecordType; return EFI_SUCCESS; } =20 /** Get a human readable module name and module guid for the given image han= dle. @@ -435,123 +441,144 @@ Done: =20 return Status; } =20 /** - Add performance log to FPDT boot record table. + Copies the string from Source into Destination and updates Length with t= he + size of the string. =20 - @param IsStart TRUE if the performance log is start log. - @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 Ticker 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 StartGauge= of PERFORMANCE_PROTOCOL. + @param Destination - destination of the string copy + @param Source - pointer to the source string which will get copied + @param Length - pointer to a length variable to be updated + +**/ +VOID +CopyStringIntoPerfRecordAndUpdateLength ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN OUT UINT8 *Length + ) +{ + UINTN StringLen; + UINTN DestMax; + + ASSERT (Source !=3D NULL); + + if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + DestMax =3D STRING_SIZE; + } else { + DestMax =3D AsciiStrSize (Source); + if (DestMax > STRING_SIZE) { + DestMax =3D STRING_SIZE; + } + } + StringLen =3D AsciiStrLen (Source); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } =20 - @retval EFI_SUCCESS Add FPDT boot record. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to record= the measurement. - @retval EFI_UNSUPPORTED No matched FPDT record. + AsciiStrnCpyS(Destination, DestMax, Source, StringLen); + *Length +=3D (UINT8)DestMax; + + return; +} + +/** + 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 Ticker - 64-bit time stamp. + @param Address - Pointer to a location in memory relevant to t= he measurement. + @param PerfId - 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. + + @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 =20 **/ EFI_STATUS -InsertFpdtMeasurement ( - IN BOOLEAN IsStart, - IN CONST VOID *Handle, OPTIONAL - IN CONST CHAR8 *Token, OPTIONAL - IN CONST CHAR8 *Module, OPTIONAL - IN UINT64 Ticker, - IN UINT32 Identifier +InsertFpdtRecord ( + IN CONST VOID *CallerIdentifier, OPTIONAL + IN CONST VOID *Guid, OPTIONAL + IN CONST CHAR8 *String, OPTIONAL + IN UINT64 Ticker, + IN UINT64 Address, OPTIONAL + IN UINT16 PerfId, + IN PERF_MEASUREMENT_ATTRIBUTE Attribute ) + { + EFI_STATUS Status; EFI_GUID ModuleGuid; CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LE= NGTH]; - EFI_STATUS Status; FPDT_RECORD_PTR FpdtRecordPtr; + FPDT_RECORD_PTR CachedFpdtRecordPtr; UINT64 TimeStamp; - FPDT_BASIC_RECORD_INFO RecordInfo; - UINTN DestMax; - UINTN StrLength; CONST CHAR8 *StringPtr; - BOOLEAN UseModuleName; + UINTN DestMax; + UINTN StringLen; + UINT16 ProgressId; =20 StringPtr =3D NULL; - UseModuleName =3D FALSE; ZeroMem (ModuleName, sizeof (ModuleName)); =20 // - // Get record info includes type, size, ProgressID. - // - Status =3D GetFpdtRecordInfo (IsStart, Handle, Token, Module, &RecordInf= o, &UseModuleName); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // If PERF_START()/PERF_END() have specified the ProgressID,it has high = priority. - // !!! Note: If the Perf is not the known Token used in the core but hav= e same - // ID with the core Token, this case will not be supported. - // And in currtnt usage mode, for the unkown ID, there is a general rule: - // If it is start pref: the lower 4 bits of the ID should be 0. - // If it is end pref: the lower 4 bits of the ID should not be 0. - // If input ID doesn't follow the rule, we will adjust it. + // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_E= X/PERF_END_EX. + // notes: For other Perf macros (Attribute =3D=3D PerfEntry), their I= d is known. // - if ((Identifier !=3D 0) && (IsKnownID (Identifier)) && (!IsKnownTokens (= Token))) { - return EFI_UNSUPPORTED; - } else if ((Identifier !=3D 0) && (!IsKnownID (Identifier)) && (!IsKnown= Tokens (Token))) { - if (IsStart && ((Identifier & 0x000F) !=3D 0)) { - Identifier &=3D 0xFFF0; - } else if ((!IsStart) && ((Identifier & 0x000F) =3D=3D 0)) { - Identifier +=3D 1; - } - RecordInfo.ProgressID =3D (UINT16)Identifier; - } - - if (mFpdtDataIsReported) { + if (Attribute !=3D PerfEntry) { // - // Append Boot records after Smm boot performance records have been re= ported. + // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it h= as high priority. + // !!! Note: If the Perf is not the known Token used in the core but h= ave same + // ID with the core Token, this case will not be supported. + // And in currtnt usage mode, for the unkown ID, there is a general ru= le: + // If it is start pref: the lower 4 bits of the ID should be 0. + // If it is end pref: the lower 4 bits of the ID should not be 0. + // If input ID doesn't follow the rule, we will adjust it. // - if (mPerformanceLength + RecordInfo.RecordSize > mMaxPerformanceLength= ) { - if (!mLackSpaceIsReport) { - DEBUG ((DEBUG_INFO, "SmmCorePerformanceLib: No enough space to sav= e boot records\n")); - mLackSpaceIsReport =3D TRUE; + if ((PerfId !=3D 0) && (IsKnownID (PerfId)) && (!IsKnownTokens (String= ))) { + return EFI_INVALID_PARAMETER; + } else if ((PerfId !=3D 0) && (!IsKnownID (PerfId)) && (!IsKnownTokens= (String))) { + if ((Attribute =3D=3D PerfStartEntry) && ((PerfId & 0x000F) !=3D 0))= { + PerfId &=3D 0xFFF0; + } else if ((Attribute =3D=3D PerfEndEntry) && ((PerfId & 0x000F) =3D= =3D 0)) { + PerfId +=3D 1; } - return EFI_OUT_OF_RESOURCES; - } else { + } + if (PerfId =3D=3D 0) { // - // Covert buffer to FPDT Ptr Union type. + // Get ProgressID form the String Token. // - FpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD= _HEADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Hea= der.Length); - } - } else { - // - // Check if pre-allocated buffer is full - // - if (mPerformanceLength + RecordInfo.RecordSize > mMaxPerformanceLength= ) { - mSmmBootPerformanceTable =3D ReallocatePool ( - mPerformanceLength, - mPerformanceLength + sizeof (SMM_BOOT_P= ERFORMANCE_TABLE) + RecordInfo.RecordSize + FIRMWARE_RECORD_BUFFER, - mSmmBootPerformanceTable - ); - - if (mSmmBootPerformanceTable =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D GetFpdtRecordId (Attribute, CallerIdentifier, String, &Pr= ogressId); + if (EFI_ERROR (Status)) { + return Status; } - mSmmBootPerformanceTable->Header.Length =3D sizeof (SMM_BOOT_PERFORM= ANCE_TABLE) + mPerformanceLength; - mMaxPerformanceLength =3D mPerformanceLength + sizeof (SMM_BOOT_PERF= ORMANCE_TABLE) + RecordInfo.RecordSize + FIRMWARE_RECORD_BUFFER; + PerfId =3D ProgressId; } - // - // Covert buffer to FPDT Ptr Union type. - // - FpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_H= EADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Heade= r.Length); } - FpdtRecordPtr.RecordHeader->Length =3D 0; =20 // - // Get the TimeStamp. + // 2. Get the buffer to store the FPDT record. + // + Status =3D GetFpdtRecordPtr (FPDT_MAX_PERF_RECORD_SIZE, &FpdtRecordPtr); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // 3. Get the TimeStamp. // if (Ticker =3D=3D 0) { Ticker =3D GetPerformanceCounter (); TimeStamp =3D GetTimeInNanoSecond (Ticker); } else if (Ticker =3D=3D 1) { @@ -559,74 +586,190 @@ InsertFpdtMeasurement ( } else { TimeStamp =3D GetTimeInNanoSecond (Ticker); } =20 // - // Get the ModuleName and ModuleGuid form the handle. + // 4. Fill in the FPDT record according to different Performance Identif= ier. // - GetModuleInfoFromHandle ((EFI_HANDLE *)Handle, ModuleName, sizeof (Modul= eName), &ModuleGuid); + switch (PerfId) { + case MODULE_START_ID: + case MODULE_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + StringPtr =3D ModuleName; + // + // Cache the offset of start image start record and use to update the = start image end record if needed. + // + if (PerfId =3D=3D MODULE_START_ID && Attribute =3D=3D PerfEntry) { + mCachedLength =3D mSmmBootPerformanceTable->Header.Length; + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidEvent->Header.Type =3D FPDT_GUID_EV= ENT_TYPE; + FpdtRecordPtr.GuidEvent->Header.Length =3D sizeof (FPDT= _GUID_EVENT_RECORD); + FpdtRecordPtr.GuidEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.GuidEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRe= cordPtr.GuidEvent->Guid)); + if (CallerIdentifier =3D=3D NULL && PerfId =3D=3D MODULE_END_ID && m= CachedLength !=3D 0) { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANC= E_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mCachedLength); + CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.Guid= Event->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid)); + mCachedLength =3D 0; + } + } + break; =20 - // - // Fill in the record information. - // - switch (RecordInfo.Type) { - case FPDT_GUID_EVENT_TYPE: - FpdtRecordPtr.GuidEvent->Header.Type =3D FPDT_GUID_EVEN= T_TYPE; - FpdtRecordPtr.GuidEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.GuidEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.GuidEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.GuidEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtReco= rdPtr.GuidEvent->Guid)); + case MODULE_LOADIMAGE_START_ID: + case MODULE_LOADIMAGE_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + StringPtr =3D ModuleName; + if (PerfId =3D=3D MODULE_LOADIMAGE_START_ID) { + mLoadImageCount++; + // + // Cache the offset of load image start record and use to be updated= by the load image end record if needed. + // + if (CallerIdentifier =3D=3D NULL && Attribute =3D=3D PerfEntry) { + mCachedLength =3D mSmmBootPerformanceTable->Header.Length; + } + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QW= ORD_EVENT_TYPE; + FpdtRecordPtr.GuidQwordEvent->Header.Length =3D sizeof (FPDT= _GUID_QWORD_EVENT_RECORD); + FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.GuidQwordEvent->ProgressID =3D PerfId; + FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; + FpdtRecordPtr.GuidQwordEvent->Qword =3D mLoadImageCo= unt; + CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (F= pdtRecordPtr.GuidQwordEvent->Guid)); + if (PerfId =3D=3D MODULE_LOADIMAGE_END_ID && mCachedLength !=3D 0) { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANC= E_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mCachedLength); + CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, s= izeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid)); + mCachedLength =3D 0; + } + } break; =20 - case FPDT_DYNAMIC_STRING_EVENT_TYPE: - FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC_S= TRING_EVENT_TYPE; - FpdtRecordPtr.DynamicStringEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.DynamicStringEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof = (FpdtRecordPtr.DynamicStringEvent->Guid)); + case PERF_EVENTSIGNAL_START_ID: + case PERF_EVENTSIGNAL_END_ID: + case PERF_CALLBACK_START_ID: + case PERF_CALLBACK_END_ID: + if (String =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Cache the event guid in string event record when PcdEdkiiFpdtString= RecordEnableOnly =3D=3D TRUE + // + CopyGuid (&ModuleGuid, Guid); + StringPtr =3D String; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DualGuidStringEvent->Header.Type =3D FPDT_DUAL_GU= ID_STRING_EVENT_TYPE; + FpdtRecordPtr.DualGuidStringEvent->Header.Length =3D sizeof (FPDT= _DUAL_GUID_STRING_EVENT_RECORD); + FpdtRecordPtr.DualGuidStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.DualGuidStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DualGuidStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier= , sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1)); + CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (Fp= dtRecordPtr.DualGuidStringEvent->Guid2)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStrin= gEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Lengt= h); + } + break; =20 - if (UseModuleName) { - StringPtr =3D ModuleName; - } else if (Token !=3D NULL) { - StringPtr =3D Token; - } else if (Module !=3D NULL) { - StringPtr =3D Module; - } else if (ModuleName !=3D NULL) { - StringPtr =3D ModuleName; + case PERF_EVENT_ID: + case PERF_FUNCTION_START_ID: + case PERF_FUNCTION_END_ID: + case PERF_INMODULE_START_ID: + case PERF_INMODULE_END_ID: + case PERF_CROSSMODULE_START_ID: + case PERF_CROSSMODULE_END_ID: + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, s= izeof (ModuleName), &ModuleGuid); + if (String !=3D NULL) { + StringPtr =3D String; + } else { + StringPtr =3D ModuleName; + } + if (AsciiStrLen (StringPtr) =3D=3D 0) { + StringPtr =3D "unknown name"; } - if (StringPtr !=3D NULL && AsciiStrLen (StringPtr) !=3D 0) { - StrLength =3D AsciiStrLen (StringPtr); - DestMax =3D (RecordInfo.RecordSize - sizeof (FPDT_DYNAMIC_STRI= NG_EVENT_RECORD)) / sizeof (CHAR8); - if (StrLength >=3D DestMax) { - StrLength =3D DestMax -1; + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC= _STRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPDT= _DYNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_= REVISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeo= f (FpdtRecordPtr.DynamicStringEvent->Guid)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicString= Event->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length); + } + break; + + default: + if (Attribute !=3D PerfEntry) { + GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName,= sizeof (ModuleName), &ModuleGuid); + if (String !=3D NULL) { + StringPtr =3D String; + } else { + StringPtr =3D ModuleName; + } + if (AsciiStrLen (StringPtr) =3D=3D 0) { + StringPtr =3D "unknown name"; + } + if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAM= IC_STRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FP= DT_DYNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECOR= D_REVISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, siz= eof (FpdtRecordPtr.DynamicStringEvent->Guid)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStri= ngEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Lengt= h); } - AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, St= ringPtr, StrLength); } else { - AsciiStrCpyS (FpdtRecordPtr.DynamicStringEvent->String, FPDT_STRING_= EVENT_RECORD_NAME_LENGTH, "unknown name"); + return EFI_INVALID_PARAMETER; } break; + } =20 - case FPDT_GUID_QWORD_EVENT_TYPE: - FpdtRecordPtr.GuidQwordEvent->Header.Type =3D FPDT_GUID_QWOR= D_EVENT_TYPE; - FpdtRecordPtr.GuidQwordEvent->Header.Length =3D RecordInfo.Rec= ordSize; - FpdtRecordPtr.GuidQwordEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; - FpdtRecordPtr.GuidQwordEvent->ProgressID =3D RecordInfo.Pro= gressID; - FpdtRecordPtr.GuidQwordEvent->Timestamp =3D TimeStamp; - CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (Fpd= tRecordPtr.GuidQwordEvent->Guid)); - break; + // + // 4.2 When PcdEdkiiFpdtStringRecordEnableOnly=3D=3DTRUE, create string = record for all Perf entries. + // + if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { + if (StringPtr =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + FpdtRecordPtr.DynamicStringEvent->Header.Type =3D FPDT_DYNAMIC_S= TRING_EVENT_TYPE; + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D sizeof (FPDT_D= YNAMIC_STRING_EVENT_RECORD); + FpdtRecordPtr.DynamicStringEvent->Header.Revision =3D FPDT_RECORD_RE= VISION_1; + FpdtRecordPtr.DynamicStringEvent->ProgressID =3D PerfId; + FpdtRecordPtr.DynamicStringEvent->Timestamp =3D TimeStamp; + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof = (FpdtRecordPtr.DynamicStringEvent->Guid)); + if (AsciiStrLen (StringPtr) =3D=3D 0) { + StringPtr =3D "unknown name"; + } + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEv= ent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length); =20 - default: - // - // Record is not supported in current SMM phase, return EFI_UNSUPPORTED - // - return EFI_UNSUPPORTED; + if ((PerfId =3D=3D MODULE_LOADIMAGE_START_ID) || (PerfId =3D=3D MODULE= _END_ID)) { + FpdtRecordPtr.DynamicStringEvent->Header.Length =3D (UINT8)(sizeof (= FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE); + } + if ((PerfId =3D=3D MODULE_LOADIMAGE_END_ID || PerfId =3D=3D MODULE_END= _ID) && mCachedLength !=3D 0) { + CachedFpdtRecordPtr.RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_= RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mCachedLength); + if (PerfId =3D=3D MODULE_LOADIMAGE_END_ID) { + DestMax =3D CachedFpdtRecordPtr.DynamicStringEvent->Header.Length = - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD); + StringLen =3D AsciiStrLen (StringPtr); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } + CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGui= d, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid)); + AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, Des= tMax, StringPtr, StringLen); + } else if (PerfId =3D=3D MODULE_END_ID) { + DestMax =3D FpdtRecordPtr.DynamicStringEvent->Header.Length - size= of (FPDT_DYNAMIC_STRING_EVENT_RECORD); + StringLen =3D AsciiStrLen (CachedFpdtRecordPtr.DynamicStringEvent-= >String); + if (StringLen >=3D DestMax) { + StringLen =3D DestMax -1; + } + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecor= dPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEve= nt->Guid)); + AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, = CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen); + } + mCachedLength =3D 0; + } } =20 // - // Update the cached FPDT record buffer. + // 5. Update the length of the used buffer after fill in the record. // mPerformanceLength +=3D FpdtRecordPtr.RecordHeader->Length; mSmmBootPerformanceTable->Header.Length +=3D FpdtRecordPtr.RecordHeader-= >Length; =20 return EFI_SUCCESS; @@ -814,16 +957,14 @@ CreatePerformanceMeasurement( IN PERF_MEASUREMENT_ATTRIBUTE Attribute ) { EFI_STATUS Status; =20 + Status =3D EFI_SUCCESS; + AcquireSpinLock (&mSmmFpdtLock); - if (Attribute =3D=3D PerfStartEntry) { - Status =3D InsertFpdtMeasurement (TRUE, CallerIdentifier, String, Stri= ng, TimeStamp, Identifier); - } else if (Attribute =3D=3D PerfEndEntry) { - Status =3D InsertFpdtMeasurement (FALSE, CallerIdentifier, String, Str= ing, TimeStamp, Identifier); - } + Status =3D InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, = Address, (UINT16)Identifier, Attribute); ReleaseSpinLock (&mSmmFpdtLock); return Status; } =20 /** @@ -1125,5 +1266,61 @@ 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, 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/SmmPerformanceLib/SmmPerformanceLib.c b/M= deModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c index fd820c0e49c..830037befa6 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c @@ -395,5 +395,73 @@ PerformanceMeasurementEnabled ( VOID ) { return mPerformanceMeasurementEnabled; } + +/** + 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 + ) +{ + EFI_STATUS Status; + + Status =3D GetPerformanceMeasurementProtocol (); + if (EFI_ERROR (Status)) { + return RETURN_OUT_OF_RESOURCES; + } + + if (mPerformanceMeasurement !=3D NULL) { + Status =3D mPerformanceMeasurement->CreatePerformanceMeasurement (Call= erIdentifier, Guid, String, 0, Address, Identifier, PerfEntry); + } else { + ASSERT (FALSE); + } + + return (RETURN_STATUS) Status; +} + +/** + 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; +} --=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 Sat Dec 21 14:37:02 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 1529657828857666.4685236033306; Fri, 22 Jun 2018 01:57:08 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A5592210D93BA; Fri, 22 Jun 2018 01:57:01 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 39963210D7F2E for ; Fri, 22 Jun 2018 01:57:00 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:57:00 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:56:59 -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.43; helo=mga05.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,256,1526367600"; d="scan'208";a="65390372" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:20 +0800 Message-Id: <20180622085623.154924-7-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 6/9] ShellPkg/dp: Update dp tool to parse new Perf record X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , 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" Since performance library instances have been updated to create new FPDT records for new Perf macros. So enhance dp tool to parse the new FPDT records. Enhancement mainly includes: 1. parse the single records for PERF_EVENT macro 2. Parse the new added FPDT_DUAL_GUID_STRING_EVENT_RECORD Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 75 ++++++++++++++++++= +--- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 1 + .../DynamicCommand/DpDynamicCommand/DpInternal.h | 14 ++++ ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 4 +- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 31 +++++++++ 5 files changed, 113 insertions(+), 12 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/Dynam= icCommand/DpDynamicCommand/Dp.c index 38766613175..925341303a4 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -428,15 +428,29 @@ GetMeasurementInfo ( break; default: ASSERT(FALSE); } =20 - if (AsciiStrCmp (Measurement->Token, ALit_PEIM) =3D=3D 0) { - Measurement->Handle =3D &(((FPDT_GUID_EVENT_RECORD *)RecordH= eader)->Guid); + if (Measurement->Token !=3D NULL && AsciiStrCmp (Measurement->Token, A= Lit_PEIM) =3D=3D 0) { + Measurement->Handle =3D &(((FPDT_DYNAMIC_STRING_EVENT_RECORD= *)RecordHeader)->Guid); } else { GetHandleFormModuleGuid(ModuleGuid, &StartHandle); - Measurement->Handle =3D StartHandle; + Measurement->Handle =3D StartHandle; + // + // When no perf entry to record the PEI and DXE phase, + // For start image, we need detect the PEIM and non PEIM here. + // + if (Measurement->Token =3D=3D NULL) { + if (StartHandle =3D=3D NULL && !IsZeroGuid (ModuleGuid)) { + Measurement->Token =3D ALit_PEIM; + Measurement->Module =3D ALit_PEIM; + Measurement->Handle =3D ModuleGuid; + } else { + Measurement->Token =3D ALit_START_IMAGE; + Measurement->Module =3D ALit_START_IMAGE; + } + } } break; =20 case FPDT_DYNAMIC_STRING_EVENT_TYPE: ModuleGuid =3D &(((FPDT_DYNAMIC_STRING_EVENT_RECORD= *)RecordHeader)->Guid); @@ -481,15 +495,27 @@ GetMeasurementInfo ( break; } =20 Measurement->Module =3D ((FPDT_DYNAMIC_STRING_EVENT_RECORD *= )RecordHeader)->String; =20 - if (AsciiStrCmp (Measurement->Token, ALit_PEIM) =3D=3D 0) { + if (Measurement->Token !=3D NULL && AsciiStrCmp (Measurement->Token, A= Lit_PEIM) =3D=3D 0) { Measurement->Handle =3D &(((FPDT_DYNAMIC_STRING_EVENT_RECORD= *)RecordHeader)->Guid); } else { GetHandleFormModuleGuid(ModuleGuid, &StartHandle); Measurement->Handle =3D StartHandle; + // + // When no perf entry to record the PEI and DXE phase, + // For start image, we need detect the PEIM and non PEIM here. + // + if (Measurement->Token =3D=3D NULL && (Measurement->Identifier =3D= =3D MODULE_START_ID || Measurement->Identifier =3D=3D MODULE_END_ID)) { + if (StartHandle =3D=3D NULL && !IsZeroGuid (ModuleGuid)) { + Measurement->Token =3D ALit_PEIM; + Measurement->Handle =3D ModuleGuid; + } else { + Measurement->Token =3D ALit_START_IMAGE; + } + } } break; =20 case FPDT_GUID_QWORD_EVENT_TYPE: ModuleGuid =3D &(((FPDT_GUID_QWORD_EVENT_RECORD *)R= ecordHeader)->Guid); @@ -551,10 +577,24 @@ GetMeasurementInfo ( } GetHandleFormModuleGuid(ModuleGuid, &StartHandle); Measurement->Handle =3D StartHandle; break; =20 + case FPDT_DUAL_GUID_STRING_EVENT_TYPE: + ModuleGuid =3D &(((FPDT_DUAL_GUID_STRING_EVENT_RECO= RD *)RecordHeader)->Guid1); + Measurement->Identifier =3D ((UINT32)((FPDT_DUAL_GUID_STRING_EVE= NT_RECORD *)RecordHeader)->ProgressID); + if (IsStart) { + Measurement->StartTimeStamp =3D ((FPDT_DUAL_GUID_STRING_EVENT_RECORD= *)RecordHeader)->Timestamp; + } else { + Measurement->EndTimeStamp =3D ((FPDT_DUAL_GUID_STRING_EVENT_RECORD= *)RecordHeader)->Timestamp; + } + Measurement->Token =3D ((FPDT_DUAL_GUID_STRING_EVENT_RECORD= *)RecordHeader)->String; + Measurement->Module =3D ((FPDT_DUAL_GUID_STRING_EVENT_RECORD= *)RecordHeader)->String; + GetHandleFormModuleGuid(ModuleGuid, &StartHandle); + Measurement->Handle =3D StartHandle; + break; + default: break; } } =20 @@ -578,10 +618,18 @@ SearchMeasurement ( (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Tok= en) =3D=3D 0) && (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Mo= dule) =3D=3D 0)) { mMeasurementList[Index].EndTimeStamp =3D EndMeasureMent->EndTimeSt= amp; break; } + } else if (EndMeasureMent->Identifier =3D=3D PERF_CROSSMODULE_END_ID) { + if (mMeasurementList[Index].EndTimeStamp =3D=3D 0 && + (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Toke= n) =3D=3D 0) && + (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Mod= ule) =3D=3D 0) && + mMeasurementList[Index].Identifier =3D=3D PERF_CROSSMODULE_START_= ID) { + mMeasurementList[Index].EndTimeStamp =3D EndMeasureMent->EndTimeSt= amp; + break; + } } else { if (mMeasurementList[Index].EndTimeStamp =3D=3D 0 && mMeasurementLis= t[Index].Handle =3D=3D EndMeasureMent->Handle && (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Toke= n) =3D=3D 0) && (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Mod= ule) =3D=3D 0)) { mMeasurementList[Index].EndTimeStamp =3D EndMeasureMent->EndTimeSt= amp; @@ -618,29 +666,36 @@ BuildMeasurementList ( RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) P= erformanceTablePtr; StartRecordEvent =3D (UINT8 *)RecordHeader; StartProgressId =3D ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->Pr= ogressID; =20 // + // If the record with ProgressId 0, the record doesn't appear in pairs= . The timestamp in the record is the EndTimeStamp, its StartTimeStamp is 0. // If the record is the start record, fill the info to the measurement= in the mMeasurementList. // If the record is the end record, find the related start measurement= in the mMeasurementList and fill the EndTimeStamp. // - if (((StartProgressId >=3D PERF_EVENTSIGNAL_START_ID && ((StartProgres= sId & 0x000F) =3D=3D 0)) || + if (StartProgressId =3D=3D 0) { + GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasure= mentNum])); + mMeasurementNum ++; + } else if (((StartProgressId >=3D PERF_EVENTSIGNAL_START_ID && ((Start= ProgressId & 0x000F) =3D=3D 0)) || (StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId = & 0x0001) !=3D 0)))) { // // Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiF= pdtStringRecordEnableOnly =3D FALSE // So we need to identify these two kinds of record through differen= t phase. // - if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEve= nt)->String, ALit_PEI) =3D=3D 0) { - mPeiPhase =3D TRUE; - } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRe= cordEvent)->String, ALit_DXE) =3D=3D 0) { - mDxePhase =3D TRUE; - mPeiPhase =3D FALSE; + if(StartProgressId =3D=3D PERF_CROSSMODULE_START_ID ){ + if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordE= vent)->String, ALit_PEI) =3D=3D 0) { + mPeiPhase =3D TRUE; + } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)Start= RecordEvent)->String, ALit_DXE) =3D=3D 0) { + mDxePhase =3D TRUE; + mPeiPhase =3D FALSE; + } } // Get measurement info form the start record to the mMeasurementLis= t. GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurem= entNum])); mMeasurementNum ++; } else { + ZeroMem(&MeasureMent, sizeof(MEASUREMENT_RECORD)); GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent); SearchMeasurement (&MeasureMent); } TableLength +=3D RecordHeader->Length; PerformanceTablePtr +=3D RecordHeader->Length; diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/Dynam= icCommand/DpDynamicCommand/Dp.h index aae021334d6..96bc89db8dc 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h @@ -39,10 +39,11 @@ #include #include #include #include #include +#include =20 extern EFI_HANDLE mDpHiiHandle; =20 #define DP_MAJOR_VERSION 2 #define DP_MINOR_VERSION 5 diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h b/ShellP= kg/DynamicCommand/DpDynamicCommand/DpInternal.h index 8dd3076cc71..d8bc7453d2d 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h @@ -83,10 +83,24 @@ GetDuration ( BOOLEAN IsPhase( IN MEASUREMENT_RECORD *Measurement ); =20 +/** + Determine whether the Measurement record is for core code. + + @param[in] Measurement A pointer to the Measurement record to test. + + @retval TRUE The measurement record is used for core. + @retval FALSE The measurement record is NOT used for core. + +**/ +BOOLEAN +IsCorePerf( + IN MEASUREMENT_RECORD *Measurement + ); + /**=20 Get the file name portion of the Pdb File Name. =20 The portion of the Pdb File Name between the last backslash and either a following period or the end of the string is converted diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c b/ShellPkg/= DynamicCommand/DpDynamicCommand/DpTrace.c index 7f7d296946f..675cbc3fd14 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c @@ -602,11 +602,11 @@ ProcessHandles( Count++; Duration =3D GetDuration (&Measurement); ElapsedTime =3D DurationInMicroSeconds ( Duration ); if ((ElapsedTime < mInterestThreshold) || (Measurement.EndTimeStamp =3D=3D 0) || - (Measurement.Handle =3D=3D NULL) || + (!IsCorePerf (&Measurement)) || ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >=3D 0)) ) { // Ignore "uninteresting" or excluded records continue; } mGaugeString[0] =3D 0; // Empty driver name by default @@ -792,11 +792,11 @@ ProcessGlobal( AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (m= GaugeString)); AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (m= UnicodeToken)); mGaugeString[25] =3D 0; mUnicodeToken[31] =3D 0; if ( ! ( IsPhase( &Measurement) || - (Measurement.Handle !=3D NULL) || + IsCorePerf (&Measurement) || (Measurement.EndTimeStamp =3D=3D 0) )) { Duration =3D GetDuration (&Measurement); ElapsedTime =3D DurationInMicroSeconds ( Duration ); diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c b/Shell= Pkg/DynamicCommand/DpDynamicCommand/DpUtilities.c index 39f71a044c3..5c6ab209d5a 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c @@ -106,10 +106,41 @@ IsPhase( (AsciiStrCmp (Measurement->Token, ALit_BDS) =3D=3D 0)) ); return RetVal; } =20 +/** + Determine whether the Measurement record is for core code. + + @param[in] Measurement A pointer to the Measurement record to test. + + @retval TRUE The measurement record is used for core. + @retval FALSE The measurement record is NOT used for core. + +**/ +BOOLEAN +IsCorePerf( + IN MEASUREMENT_RECORD *Measurement + ) +{ + BOOLEAN RetVal; + + RetVal =3D (BOOLEAN)( + ((Measurement->Identifier =3D=3D MODULE_START_ID) || + (Measurement->Identifier =3D=3D MODULE_END_ID) || + (Measurement->Identifier =3D=3D MODULE_LOADIMAGE_START_ID) || + (Measurement->Identifier =3D=3D MODULE_LOADIMAGE_END_ID) || + (Measurement->Identifier =3D=3D MODULE_DB_START_ID) || + (Measurement->Identifier =3D=3D MODULE_DB_END_ID) || + (Measurement->Identifier =3D=3D MODULE_DB_SUPPORT_START_ID) || + (Measurement->Identifier =3D=3D MODULE_DB_SUPPORT_END_ID) || + (Measurement->Identifier =3D=3D MODULE_DB_STOP_START_ID) || + (Measurement->Identifier =3D=3D MODULE_DB_STOP_START_ID)) + ); + return RetVal; +} + /**=20 Get the file name portion of the Pdb File Name. =20 The portion of the Pdb File Name between the last backslash and either a following period or the end of the string is converted --=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 Sat Dec 21 14:37:02 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 1529657833332239.37585816165597; Fri, 22 Jun 2018 01:57:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CFD39210D93AD; Fri, 22 Jun 2018 01:57:08 -0700 (PDT) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 B04D5210D7F2E for ; Fri, 22 Jun 2018 01:57:07 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:57:07 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:57:06 -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.126; helo=mga18.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,256,1526367600"; d="scan'208";a="65390395" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:21 +0800 Message-Id: <20180622085623.154924-8-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 7/9] MdeModulePkg: Use new added Perf macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng , Liming Gao , Eric Dong 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" Replace old Perf macros with the new added ones. Cc: Liming Gao Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 7 +++++ MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 8 ++---- MdeModulePkg/Core/Dxe/Hand/DriverSupport.c | 8 +++--- MdeModulePkg/Core/Dxe/Image/Image.c | 30 +++++-------------= ---- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +++--- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 17 ++++++------ MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 15 ++++------- MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 4 +-- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 2 +- .../Library/UefiBootManagerLib/BmConsole.c | 9 +++---- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 21 ++++++++------- 11 files changed, 53 insertions(+), 76 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Dxe/Dispatcher/Dispatcher.c index 088cd810631..4c6ca761a60 100644 --- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c @@ -417,10 +417,11 @@ CoreDispatcher ( LIST_ENTRY *Link; EFI_CORE_DRIVER_ENTRY *DriverEntry; BOOLEAN ReadyToRun; EFI_EVENT DxeDispatchEvent; =20 + PERF_FUNCTION_BEGIN (); =20 if (gDispatcherRunning) { // // If the dispatcher is running don't let it be restarted. // @@ -582,10 +583,12 @@ CoreDispatcher ( // CoreCloseEvent (DxeDispatchEvent); =20 gDispatcherRunning =3D FALSE; =20 + PERF_FUNCTION_END (); + return ReturnStatus; } =20 =20 /** @@ -1435,17 +1438,21 @@ CoreFwVolEventProtocolNotify ( VOID CoreInitializeDispatcher ( VOID ) { + PERF_FUNCTION_BEGIN (); + mFwVolEvent =3D EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolume2ProtocolGuid, TPL_CALLBACK, CoreFwVolEventProtocolNotify, NULL, &mFwVolEventRegistration ); + + PERF_FUNCTION_END (); } =20 // // Function only used in debug builds // diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 07c74034624..3f753738a27 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -299,12 +299,12 @@ DxeMain ( =20 // // Call constructor for all libraries // ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST); - PERF_END (NULL,"PEI", NULL, 0) ; - PERF_START (NULL,"DXE", NULL, 0) ; + PERF_CROSSMODULE_END ("PEI"); + PERF_CROSSMODULE_BEGIN ("DXE"); =20 // // Report DXE Core image information to the PE/COFF Extra Action Library // ZeroMem (&ImageContext, sizeof (ImageContext)); @@ -497,20 +497,16 @@ DxeMain ( ASSERT_EFI_ERROR (Status); =20 // // Initialize the DXE Dispatcher // - PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; CoreInitializeDispatcher (); - PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; =20 // // Invoke the DXE Dispatcher // - PERF_START (NULL, "CoreDispatcher", "DxeMain", 0); CoreDispatcher (); - PERF_END (NULL, "CoreDispatcher", "DxeMain", 0); =20 // // Display Architectural protocols that were not loaded if this is DEBUG= build // DEBUG_CODE_BEGIN (); diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c b/MdeModulePkg/Core= /Dxe/Hand/DriverSupport.c index 33dd0bd0b7c..ab3cc0c07e5 100644 --- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c +++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c @@ -625,32 +625,32 @@ CoreConnectSingleController ( DriverBinding =3D NULL; DriverFound =3D FALSE; for (Index =3D 0; (Index < NumberOfSortedDriverBindingProtocols) && !D= riverFound; Index++) { if (SortedDriverBindingProtocols[Index] !=3D NULL) { DriverBinding =3D SortedDriverBindingProtocols[Index]; - PERF_START (DriverBinding->DriverBindingHandle, "DB:Support:", NUL= L, 0); + PERF_DRIVER_BINDING_SUPPORT_BEGIN (DriverBinding->DriverBindingHan= dle, ControllerHandle); Status =3D DriverBinding->Supported( DriverBinding, ControllerHandle, RemainingDevicePath ); - PERF_END (DriverBinding->DriverBindingHandle, "DB:Support:", NULL,= 0); + PERF_DRIVER_BINDING_SUPPORT_END (DriverBinding->DriverBindingHandl= e, ControllerHandle); if (!EFI_ERROR (Status)) { SortedDriverBindingProtocols[Index] =3D NULL; DriverFound =3D TRUE; =20 // // A driver was found that supports ControllerHandle, so attempt= to start the driver // on ControllerHandle. // - PERF_START (DriverBinding->DriverBindingHandle, "DB:Start:", NUL= L, 0); + PERF_DRIVER_BINDING_START_BEGIN (DriverBinding->DriverBindingHan= dle, ControllerHandle); Status =3D DriverBinding->Start ( DriverBinding, ControllerHandle, RemainingDevicePath ); - PERF_END (DriverBinding->DriverBindingHandle, "DB:Start:", NULL,= 0); + PERF_DRIVER_BINDING_START_END (DriverBinding->DriverBindingHandl= e, ControllerHandle); =20 if (!EFI_ERROR (Status)) { // // The driver was successfully started on ControllerHandle, so= set a flag // diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index c49ddfcc81d..adeb4bf313a 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1434,17 +1434,13 @@ CoreLoadImage ( IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle ) { EFI_STATUS Status; - UINT64 Tick; EFI_HANDLE Handle; =20 - Tick =3D 0; - PERF_CODE ( - Tick =3D GetPerformanceCounter (); - ); + PERF_LOAD_IMAGE_BEGIN (NULL); =20 Status =3D CoreLoadImageCommon ( BootPolicy, ParentImageHandle, FilePath, @@ -1463,12 +1459,11 @@ CoreLoadImage ( // ImageHandle will be valid only Status is success.=20 // Handle =3D *ImageHandle; } =20 - PERF_START (Handle, "LoadImage:", NULL, Tick); - PERF_END (Handle, "LoadImage:", NULL, 0); + PERF_LOAD_IMAGE_END (Handle); =20 return Status; } =20 =20 @@ -1524,17 +1519,13 @@ CoreLoadImageEx ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL, IN UINT32 Attribute ) { EFI_STATUS Status; - UINT64 Tick; EFI_HANDLE Handle; =20 - Tick =3D 0; - PERF_CODE ( - Tick =3D GetPerformanceCounter (); - ); + PERF_LOAD_IMAGE_BEGIN (NULL); =20 Status =3D CoreLoadImageCommon ( TRUE, ParentImageHandle, FilePath, @@ -1553,12 +1544,11 @@ CoreLoadImageEx ( // ImageHandle will be valid only Status is success.=20 // Handle =3D *ImageHandle; } =20 - PERF_START (Handle, "LoadImage:", NULL, Tick); - PERF_END (Handle, "LoadImage:", NULL, 0); + PERF_LOAD_IMAGE_END (Handle); =20 return Status; } =20 =20 @@ -1592,14 +1582,12 @@ CoreStartImage ( EFI_STATUS Status; LOADED_IMAGE_PRIVATE_DATA *Image; LOADED_IMAGE_PRIVATE_DATA *LastImage; UINT64 HandleDatabaseKey; UINTN SetJumpFlag; - UINT64 Tick; EFI_HANDLE Handle; =20 - Tick =3D 0; Handle =3D ImageHandle; =20 Image =3D CoreLoadedImageInfo (ImageHandle); if (Image =3D=3D NULL || Image->Started) { return EFI_INVALID_PARAMETER; @@ -1619,13 +1607,11 @@ CoreStartImage ( DEBUG ((EFI_D_ERROR, "Image type %s can't be started ", GetMachineType= Name(Image->Machine))); DEBUG ((EFI_D_ERROR, "on %s UEFI system.\n", GetMachineTypeName(mDxeCo= reImageMachineType))); return EFI_UNSUPPORTED; } =20 - PERF_CODE ( - Tick =3D GetPerformanceCounter (); - ); + PERF_START_IMAGE_BEGIN (Handle); =20 =20 // // Push the current start image context, and // link the current image to the head. This is the @@ -1645,12 +1631,11 @@ CoreStartImage ( if (Image->JumpBuffer =3D=3D NULL) { // // Image may be unloaded after return with failure, // then ImageHandle may be invalid, so use NULL handle to record perf = log. // - PERF_START (NULL, "StartImage:", NULL, Tick); - PERF_END (NULL, "StartImage:", NULL, 0); + PERF_START_IMAGE_END (NULL); =20 // // Pop the current start image context // mCurrentImage =3D LastImage; @@ -1761,12 +1746,11 @@ CoreStartImage ( } =20 // // Done // - PERF_START (Handle, "StartImage:", NULL, Tick); - PERF_END (Handle, "StartImage:", NULL, 0); + PERF_START_IMAGE_END (Handle); return Status; } =20 /** Terminates the currently loaded EFI image and returns control to boot se= rvices. diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Pei/Dispatcher/Dispatcher.c index 0ac3fdde6a9..c4f629dadff 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -998,13 +998,13 @@ PeiDispatcher ( // // Call the PEIM entry point // PeimEntryPoint =3D (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint; =20 - PERF_START (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_BEGIN (PeimFileHandle); PeimEntryPoint(PeimFileHandle, (const EFI_PEI_SERVICES **) &Pr= ivate->Ps); - PERF_END (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_END (PeimFileHandle); } =20 // // Process the Notify list and dispatch any notifies for // newly installed PPIs. @@ -1107,11 +1107,11 @@ PeiDispatcher ( if (Status =3D=3D EFI_SUCCESS) { // // The PEIM has its dependencies satisfied, and its entry = point // has been found, so invoke it. // - PERF_START (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_BEGIN (PeimFileHandle); =20 REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_BEGIN), (VOID *)(&PeimFileHandle), @@ -1143,11 +1143,11 @@ PeiDispatcher ( EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_END), (VOID *)(&PeimFileHandle), sizeof (PeimFileHandle) ); - PERF_END (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_END (PeimFileHandle); =20 } } =20 PeiCheckAndSwitchStack (SecCoreData, Private); diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pe= i/PeiMain/PeiMain.c index 775bf18ce93..a52e6f02017 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -350,22 +350,21 @@ PeiCore ( =20 // // Update performance measurements=20 // if (OldCoreData =3D=3D NULL) { - PERF_START (NULL, "SEC", NULL, 1); - PERF_END (NULL, "SEC", NULL, 0); + PERF_EVENT ("SEC"); // Means the end of SEC phase. =20 // // If first pass, start performance measurement. // - PERF_START (NULL,"PEI", NULL, 0); - PERF_START (NULL,"PreMem", NULL, 0); + PERF_CROSSMODULE_BEGIN ("PEI"); + PERF_INMODULE_BEGIN ("PreMem"); =20 } else { - PERF_END (NULL,"PreMem", NULL, 0); - PERF_START (NULL,"PostMem", NULL, 0); + PERF_INMODULE_END ("PreMem"); + PERF_INMODULE_BEGIN ("PostMem"); } =20 // // Complete PEI Core Service initialization // =20 @@ -409,19 +408,19 @@ PeiCore ( } =20 // // Alert any listeners that there is permanent memory available // - PERF_START (NULL,"DisMem", NULL, 0); + PERF_INMODULE_BEGIN ("DisMem"); Status =3D PeiServicesInstallPpi (&mMemoryDiscoveredPpi); =20 // // Process the Notify list and dispatch any notifies for the Memory Di= scovered PPI // ProcessNotifyList (&PrivateData); =20 - PERF_END (NULL,"DisMem", NULL, 0); + PERF_INMODULE_END ("DisMem"); } =20 // // Call PEIM dispatcher // @@ -435,11 +434,11 @@ PeiCore ( } =20 // // Measure PEI Core execution time. // - PERF_END (NULL, "PostMem", NULL, 0); + PERF_INMODULE_END ("PostMem"); =20 // // Lookup DXE IPL PPI // Status =3D PeiServicesLocatePpi ( diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/P= iSmmCore/Dispatcher.c index f32bbbd1b4b..0b3b5924d38 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -319,17 +319,13 @@ SmmLoadImage ( EFI_DEVICE_PATH_PROTOCOL *FilePath; EFI_DEVICE_PATH_PROTOCOL *OriginalFilePath; EFI_DEVICE_PATH_PROTOCOL *HandleFilePath; EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - UINT64 Tick; =20 - Tick =3D 0; - PERF_CODE ( - Tick =3D GetPerformanceCounter (); - ); - =20 + PERF_LOAD_IMAGE_BEGIN (DriverEntry->ImageHandle); + Buffer =3D NULL; Size =3D 0; Fv =3D DriverEntry->Fv; NameGuid =3D &DriverEntry->FileName; FilePath =3D DriverEntry->FvFileDevicePath; @@ -639,12 +635,11 @@ SmmLoadImage ( &gEfiLoadedImageProtocolGuid, EFI_NATIVE_INTERFACE, &DriverEntry->SmmLoadedImage ); =20 - PERF_START (DriverEntry->ImageHandle, "LoadImage:", NULL, Tick); - PERF_END (DriverEntry->ImageHandle, "LoadImage:", NULL, 0); + PERF_LOAD_IMAGE_END (DriverEntry->ImageHandle); =20 // // Print the load address and the PDB file name if it is available // =20 @@ -907,13 +902,13 @@ SmmDispatcher ( =20 // // For each SMM driver, pass NULL as ImageHandle // RegisterSmramProfileImage (DriverEntry, TRUE); - PERF_START (DriverEntry->ImageHandle, "StartImage:", NULL, 0); + PERF_START_IMAGE_BEGIN (DriverEntry->ImageHandle); Status =3D ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoi= nt)(DriverEntry->ImageHandle, gST); - PERF_END (DriverEntry->ImageHandle, "StartImage:", NULL, 0); + PERF_START_IMAGE_END (DriverEntry->ImageHandle); if (EFI_ERROR(Status)){ UnregisterSmramProfileImage (DriverEntry, TRUE); SmmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage); // // Uninstall LoadedImage diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/Pi= SmmCore/PiSmmCore.c index 686b9b45a55..45f40e0e60c 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c @@ -642,11 +642,11 @@ SmmEntryPoint ( BOOLEAN InLegacyBoot; BOOLEAN IsOverlapped; VOID *CommunicationBuffer; UINTN BufferSize; =20 - PERF_START (NULL, "SMM", NULL, 0) ; + PERF_INMODULE_BEGIN ("SMM"); =20 // // Update SMST with contents of the SmmEntryContext structure // gSmmCoreSmst.SmmStartupThisAp =3D SmmEntryContext->SmmStartupThisAp; @@ -737,11 +737,11 @@ SmmEntryPoint ( // Clear the InSmm flag as we are going to leave SMM // gSmmCorePrivate->InSmm =3D FALSE; } =20 - PERF_END (NULL, "SMM", NULL, 0) ; + PERF_INMODULE_END ("SMM"); } =20 /** Install LoadedImage protocol for SMM Core. **/ diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmBoot.c index b842d5824ae..59bd1e4c6c0 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -43,11 +43,11 @@ BmEndOfBdsPerfCode ( ) { // // Record the performance data for End of BDS // - PERF_END(NULL, "BDS", NULL, 0); + PERF_CROSSMODULE_END("BDS"); =20 return ; } =20 /** diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c b/MdeModul= ePkg/Library/UefiBootManagerLib/BmConsole.c index 80511814eec..d85b603d64a 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c @@ -720,27 +720,24 @@ EfiBootManagerConnectAllDefaultConsoles ( =20 Status =3D EfiBootManagerConnectConsoleVariable (ConOut); if (!EFI_ERROR (Status)) { OneConnected =3D TRUE; } - PERF_START (NULL, "ConOutReady", "BDS", 1); - PERF_END (NULL, "ConOutReady", "BDS", 0); + PERF_EVENT ("ConOutReady"); =20 =20 Status =3D EfiBootManagerConnectConsoleVariable (ConIn); if (!EFI_ERROR (Status)) { OneConnected =3D TRUE; } - PERF_START (NULL, "ConInReady", "BDS", 1); - PERF_END (NULL, "ConInReady", "BDS", 0); + PERF_EVENT ("ConInReady"); =20 Status =3D EfiBootManagerConnectConsoleVariable (ErrOut); if (!EFI_ERROR (Status)) { OneConnected =3D TRUE; } - PERF_START (NULL, "ErrOutReady", "BDS", 1); - PERF_END (NULL, "ErrOutReady", "BDS", 0); + PERF_EVENT ("ErrOutReady"); =20 SystemTableUpdated =3D FALSE; // // Fill console handles in System Table if no console device assignd. // diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Univer= sal/BdsDxe/BdsEntry.c index 3191a986304..acb25abfcd4 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -723,12 +723,12 @@ BdsEntry ( BootSuccess =3D FALSE; =20 // // Insert the performance probe // - PERF_END (NULL, "DXE", NULL, 0); - PERF_START (NULL, "BDS", NULL, 0); + PERF_CROSSMODULE_END("DXE"); + PERF_CROSSMODULE_BEGIN("BDS"); DEBUG ((EFI_D_INFO, "[Bds] Entry...\n")); =20 // // Fill in FirmwareVendor and FirmwareRevision from PCDs // @@ -886,13 +886,13 @@ BdsEntry ( // > Register new Driver#### or Boot#### // > Register new Key####: e.g.: F12=20 // > Signal ReadyToLock event // > Authentication action: 1. connect Auth devices; 2. Identify auto lo= gon user. // - PERF_START (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0); + PERF_INMODULE_BEGIN("PlatformBootManagerBeforeConsole"); PlatformBootManagerBeforeConsole (); - PERF_END (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0); + PERF_INMODULE_END("PlatformBootManagerBeforeConsole"); =20 // // Initialize hotkey service // EfiBootManagerStartHotkeyService (&HotkeyTriggered); @@ -905,21 +905,21 @@ BdsEntry ( EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); =20 // // Connect consoles // - PERF_START (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0); + PERF_INMODULE_BEGIN("EfiBootManagerConnectAllDefaultConsoles"); if (PcdGetBool (PcdConInConnectOnDemand)) { EfiBootManagerConnectConsoleVariable (ConOut); EfiBootManagerConnectConsoleVariable (ErrOut); // // Do not connect ConIn devices when lazy ConIn feature is ON. // } else { EfiBootManagerConnectAllDefaultConsoles (); } - PERF_END (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0); + PERF_INMODULE_END("EfiBootManagerConnectAllDefaultConsoles"); =20 // // Do the platform specific action after the console is ready // Possible things that can be done in PlatformBootManagerAfterConsole: // > Console post action: @@ -928,13 +928,13 @@ BdsEntry ( // > Run diagnostics like memory testing // > Connect certain devices // > Dispatch aditional option roms // > Special boot: e.g.: USB boot, enter UI //=20 - PERF_START (NULL, "PlatformBootManagerAfterConsole", "BDS", 0); + PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole"); PlatformBootManagerAfterConsole (); - PERF_END (NULL, "PlatformBootManagerAfterConsole", "BDS", 0); + PERF_INMODULE_END("PlatformBootManagerAfterConsole"); // // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is se= t. Skip HotkeyBoot // DataSize =3D sizeof (UINT64); Status =3D gRT->GetVariable ( @@ -1023,14 +1023,13 @@ BdsEntry ( EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); =20 // // Execute Key#### // - PERF_START (NULL, "BdsWait", "BDS", 0); + PERF_INMODULE_BEGIN ("BdsWait"); BdsWait (HotkeyTriggered); - PERF_END (NULL, "BdsWait", "BDS", 0); - + PERF_INMODULE_END ("BdsWait"); // // BdsReadKeys() can be removed after all keyboard drivers invoke call= back in timer callback. // BdsReadKeys (); =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 Sat Dec 21 14:37:02 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 1529657837655396.93027832883706; Fri, 22 Jun 2018 01:57:17 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0BFBC210D9789; Fri, 22 Jun 2018 01:57:11 -0700 (PDT) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 3E334210D9785 for ; Fri, 22 Jun 2018 01:57:10 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:57:10 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:57:09 -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.126; helo=mga18.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,256,1526367600"; d="scan'208";a="65390412" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:22 +0800 Message-Id: <20180622085623.154924-9-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 8/9] SecurityPkg: Use new added Perf macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chao Zhang , 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" Replace old Perf macros with the new added ones. Cc: Liming Gao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../DxeRsa2048Sha256GuidedSectionExtractLib.c | 16 ++++++++----= ---- .../PeiRsa2048Sha256GuidedSectionExtractLib.c | 16 ++++++++----= ---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/Dx= eRsa2048Sha256GuidedSectionExtractLib.c b/SecurityPkg/Library/DxeRsa2048Sha= 256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c index 39768fbac22..d6f4207a506 100644 --- a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa204= 8Sha256GuidedSectionExtractLib.c +++ b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa204= 8Sha256GuidedSectionExtractLib.c @@ -161,13 +161,13 @@ Rsa2048Sha256GuidedSectionHandler ( // Get the RSA 2048 SHA 256 information. // CertBlockRsa2048Sha256 =3D &((RSA_2048_SHA_256_SECTION2_HEADER *) Inpu= tSection)->CertBlockRsa2048Sha256; OutputBufferSize =3D SECTION2_SIZE (InputSection) - sizeof (RSA_= 2048_SHA_256_SECTION2_HEADER); if ((((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUID= ED_SECTION_PROCESSING_REQUIRED) !=3D 0) { - PERF_START (NULL, "RsaCopy", "DXE", 0); + PERF_INMODULE_BEGIN ("DxeRsaCopy"); CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof (RSA_2048_SHA= _256_SECTION2_HEADER), OutputBufferSize); - PERF_END (NULL, "RsaCopy", "DXE", 0); + PERF_INMODULE_END ("DxeRsaCopy"); } else { *OutputBuffer =3D (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_S= ECTION2_HEADER); } =20 // @@ -189,13 +189,13 @@ Rsa2048Sha256GuidedSectionHandler ( // Get the RSA 2048 SHA 256 information. // CertBlockRsa2048Sha256 =3D &((RSA_2048_SHA_256_SECTION_HEADER *)InputS= ection)->CertBlockRsa2048Sha256; OutputBufferSize =3D SECTION_SIZE (InputSection) - sizeof (RSA_2= 048_SHA_256_SECTION_HEADER); if ((((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUID= ED_SECTION_PROCESSING_REQUIRED) !=3D 0) { - PERF_START (NULL, "RsaCopy", "DXE", 0); + PERF_INMODULE_BEGIN ("DxeRsaCopy"); CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof (RSA_2048_SHA= _256_SECTION_HEADER), OutputBufferSize); - PERF_END (NULL, "RsaCopy", "DXE", 0); + PERF_INMODULE_END ("DxeRsaCopy"); } else { *OutputBuffer =3D (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_S= ECTION_HEADER); } =20 // @@ -325,13 +325,13 @@ Rsa2048Sha256GuidedSectionHandler ( if (!CryptoStatus) { DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: Sha256Init() failed\n")); *AuthenticationStatus |=3D EFI_AUTH_STATUS_TEST_FAILED; goto Done; } - PERF_START (NULL, "RsaShaData", "DXE", 0); + PERF_INMODULE_BEGIN ("DxeRsaShaData"); CryptoStatus =3D Sha256Update (HashContext, *OutputBuffer, OutputBufferS= ize); - PERF_END (NULL, "RsaShaData", "DXE", 0); + PERF_INMODULE_END ("DxeRsaShaData"); if (!CryptoStatus) { DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: Sha256Update() failed\n")); *AuthenticationStatus |=3D EFI_AUTH_STATUS_TEST_FAILED; goto Done; } @@ -343,19 +343,19 @@ Rsa2048Sha256GuidedSectionHandler ( } =20 // // Verify the RSA 2048 SHA 256 signature. // - PERF_START (NULL, "RsaVerify", "DXE", 0); + PERF_INMODULE_BEGIN ("DxeRsaVerify"); CryptoStatus =3D RsaPkcs1Verify ( Rsa,=20 Digest,=20 SHA256_DIGEST_SIZE,=20 CertBlockRsa2048Sha256->Signature,=20 sizeof (CertBlockRsa2048Sha256->Signature) ); - PERF_END (NULL, "RsaVerify", "DXE", 0); + PERF_INMODULE_END ("DxeRsaVerify"); if (!CryptoStatus) { // // If RSA 2048 SHA 256 signature verification fails, AUTH tested faile= d bit is set. // DEBUG ((DEBUG_ERROR, "DxeRsa2048Sha256: RsaPkcs1Verify() failed\n")); diff --git a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/Pe= iRsa2048Sha256GuidedSectionExtractLib.c b/SecurityPkg/Library/PeiRsa2048Sha= 256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c index ba1c700ad03..2272308ddca 100644 --- a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa204= 8Sha256GuidedSectionExtractLib.c +++ b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa204= 8Sha256GuidedSectionExtractLib.c @@ -158,13 +158,13 @@ Rsa2048Sha256GuidedSectionHandler ( // Get the RSA 2048 SHA 256 information. // CertBlockRsa2048Sha256 =3D &((RSA_2048_SHA_256_SECTION2_HEADER *) Inpu= tSection)->CertBlockRsa2048Sha256; OutputBufferSize =3D SECTION2_SIZE (InputSection) - sizeof (RSA_= 2048_SHA_256_SECTION2_HEADER); if ((((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUID= ED_SECTION_PROCESSING_REQUIRED) !=3D 0) { - PERF_START (NULL, "RsaCopy", "PEI", 0); + PERF_INMODULE_BEGIN ("PeiRsaCopy"); CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof (RSA_2048_SHA= _256_SECTION2_HEADER), OutputBufferSize); - PERF_END (NULL, "RsaCopy", "PEI", 0); + PERF_INMODULE_END ("PeiRsaCopy"); } else { *OutputBuffer =3D (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_S= ECTION2_HEADER); } =20 // @@ -186,13 +186,13 @@ Rsa2048Sha256GuidedSectionHandler ( // Get the RSA 2048 SHA 256 information. // CertBlockRsa2048Sha256 =3D &((RSA_2048_SHA_256_SECTION_HEADER *)InputS= ection)->CertBlockRsa2048Sha256; OutputBufferSize =3D SECTION_SIZE (InputSection) - sizeof (RSA_2= 048_SHA_256_SECTION_HEADER); if ((((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUID= ED_SECTION_PROCESSING_REQUIRED) !=3D 0) { - PERF_START (NULL, "RsaCopy", "PEI", 0); + PERF_INMODULE_BEGIN ("PeiRsaCopy"); CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof (RSA_2048_SHA= _256_SECTION_HEADER), OutputBufferSize); - PERF_END (NULL, "RsaCopy", "PEI", 0); + PERF_INMODULE_END ("PeiRsaCopy"); } else { *OutputBuffer =3D (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_S= ECTION_HEADER); } =20 // @@ -309,13 +309,13 @@ Rsa2048Sha256GuidedSectionHandler ( if (!CryptoStatus) { DEBUG ((DEBUG_ERROR, "PeiRsa2048Sha256: Sha256Init() failed\n")); *AuthenticationStatus |=3D EFI_AUTH_STATUS_TEST_FAILED; goto Done; } - PERF_START (NULL, "RsaShaData", "PEI", 0); + PERF_INMODULE_BEGIN ("PeiRsaShaData"); CryptoStatus =3D Sha256Update (HashContext, *OutputBuffer, OutputBufferS= ize); - PERF_END (NULL, "RsaShaData", "PEI", 0); + PERF_INMODULE_END ("PeiRsaShaData"); if (!CryptoStatus) { DEBUG ((DEBUG_ERROR, "PeiRsa2048Sha256: Sha256Update() failed\n")); *AuthenticationStatus |=3D EFI_AUTH_STATUS_TEST_FAILED; goto Done; } @@ -327,19 +327,19 @@ Rsa2048Sha256GuidedSectionHandler ( } =20 // // Verify the RSA 2048 SHA 256 signature. // - PERF_START (NULL, "RsaVerify", "PEI", 0); + PERF_INMODULE_BEGIN ("PeiRsaVerify"); CryptoStatus =3D RsaPkcs1Verify ( Rsa,=20 Digest,=20 SHA256_DIGEST_SIZE,=20 CertBlockRsa2048Sha256->Signature,=20 sizeof (CertBlockRsa2048Sha256->Signature) ); - PERF_END (NULL, "RsaVerify", "PEI", 0); + PERF_INMODULE_END ("PeiRsaVerify"); if (!CryptoStatus) { // // If RSA 2048 SHA 256 signature verification fails, AUTH tested faile= d bit is set. // DEBUG ((DEBUG_ERROR, "PeiRsa2048Sha256: RsaPkcs1Verify() failed\n")); --=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 Sat Dec 21 14:37:02 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 1529657841941705.1668065624045; Fri, 22 Jun 2018 01:57:21 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3D7F7210DC1A4; Fri, 22 Jun 2018 01:57:16 -0700 (PDT) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 DF36F210D9787 for ; Fri, 22 Jun 2018 01:57:14 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2018 01:57:14 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2018 01:57:14 -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.126; helo=mga18.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,256,1526367600"; d="scan'208";a="65390426" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Jun 2018 16:56:23 +0800 Message-Id: <20180622085623.154924-10-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com> References: <20180622085623.154924-1-dandan.bi@intel.com> Subject: [edk2] [patch V2 9/9] UefiCpuPkg: Use new added Perf macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Dong , 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" Replace old Perf macros with the new added ones. Cc: Liming Gao Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg= /Universal/Acpi/S3Resume2Pei/S3Resume.c index 4ae168a2c3c..d3cb07cd2d0 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -428,21 +428,21 @@ S3ResumeBootOs ( // NOTE: Because Debug Timer interrupt and system interrupts will be dis= abled=20 // in BootScriptExecuteDxe, the rest code in S3ResumeBootOs() cannot be = halted // by soft debugger. // =20 - PERF_END (NULL, "ScriptExec", NULL, 0); + PERF_INMODULE_END ("ScriptExec"); =20 // // Install BootScriptDonePpi // - PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_START_I= D); + PERF_INMODULE_BEGIN ("BootScriptDonePpi"); =20 Status =3D PeiServicesInstallPpi (&mPpiListPostScriptTable); ASSERT_EFI_ERROR (Status); =20 - PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_END_ID); + PERF_INMODULE_END ("BootScriptDonePpi"); =20 // // Get ACPI Table Address // Facs =3D (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (Acpi= S3Context->AcpiFacsTable)); @@ -462,26 +462,26 @@ S3ResumeBootOs ( } =20 // // Install EndOfPeiPpi // - PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_START_ID); + PERF_INMODULE_BEGIN("EndOfPeiPpi"); =20 Status =3D PeiServicesInstallPpi (&mPpiListEndOfPeiTable); ASSERT_EFI_ERROR (Status); =20 - PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID); + PERF_INMODULE_END("EndOfPeiPpi"); =20 - PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID); + PERF_INMODULE_BEGIN("EndOfS3Resume"); =20 DEBUG ((DEBUG_INFO, "Signal EndOfS3Resume\n")); // // Signal EndOfS3Resume to SMM. // SignalToSmmByCommunication (&gEdkiiEndOfS3ResumeGuid); =20 - PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID); + PERF_INMODULE_END ("EndOfS3Resume"); =20 // // report status code on S3 resume // REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_= PEI_PC_OS_WAKE); @@ -878,11 +878,11 @@ S3ResumeExecuteBootScript ( // // Report Status Code to indicate S3 boot script execution // REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_= PEI_PC_S3_BOOT_SCRIPT); =20 - PERF_START (NULL, "ScriptExec", NULL, 0); + PERF_INMODULE_BEGIN ("ScriptExec"); =20 if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { // // X64 S3 Resume // --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel