From nobody Mon Sep 16 19:01:41 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 1529393173446622.617620078646; Tue, 19 Jun 2018 00:26:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8886B211299A8; Tue, 19 Jun 2018 00:26:12 -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 574AF210D7F47 for ; Tue, 19 Jun 2018 00:26:10 -0700 (PDT) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2018 00:26:09 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga006.jf.intel.com with ESMTP; 19 Jun 2018 00:26: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=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,242,1526367600"; d="scan'208";a="51022232" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 19 Jun 2018 15:23:58 +0800 Message-Id: <20180619072405.142872-3-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180619072405.142872-1-dandan.bi@intel.com> References: <20180619072405.142872-1-dandan.bi@intel.com> Subject: [edk2] [patch 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 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 --- .../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