From nobody Fri Nov 1 14:38:39 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 Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151667931153317.266333440462063; Mon, 22 Jan 2018 19:48:31 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CAC0F22344321; Mon, 22 Jan 2018 19:43:03 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 2FDA12233379A for ; Mon, 22 Jan 2018 19:43:02 -0800 (PST) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 19:48:28 -0800 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 22 Jan 2018 19:48:26 -0800 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.20; helo=mga02.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.46,399,1511856000"; d="scan'208";a="12262586" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 23 Jan 2018 11:47:35 +0800 Message-Id: <1516679255-12328-9-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1516679255-12328-1-git-send-email-dandan.bi@intel.com> References: <1516679255-12328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [patch 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Jaben Carsey , Star Zeng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 +++++++++++++++++= +++- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 5 +- .../DpDynamicCommand/DpDynamicCommand.inf | 5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h | 9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 92 +++- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 31 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h | 8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 11 files changed, 713 insertions(+), 116 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTok= ens.h diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/Dynam= icCommand/DpDynamicCommand/Dp.c index 3ecc753..6013d99 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -11,40 +11,64 @@ Measurement records contain identifying information (Handle, Token, Modu= le) and start and end time values. Dp uses this information to group records in different ways. It also us= es timer information to calculate elapsed time for each measurement. =20 - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
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 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. **/ =20 -#include "PerformanceTokens.h" #include "Dp.h" #include "Literals.h" #include "DpInternal.h" =20 +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Entry; +} RSDT_TABLE; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 Entry; +} XSDT_TABLE; + +#pragma pack() + EFI_HANDLE mDpHiiHandle; =20 +typedef struct { + EFI_HANDLE Handle; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP *mCacheHandleGuidTable; +UINTN mCachePairCount =3D 0; + // /// Module-Global Variables ///@{ CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; BOOLEAN mShowId =3D FALSE; +UINT8 *mBootPerformanceTable; +UINTN mBootPerformanceTableSize; +BOOLEAN mPeiPhase =3D FALSE; +BOOLEAN mDxePhase =3D FALSE; =20 PERF_SUMMARY_DATA SummaryData =3D { 0 }; ///< Create the SummaryData st= ructure and init. to ZERO. - -/// Timer Specific Information. -TIMER_INFO TimerInfo; +MEASUREMENT_RECORD *mMeasurementList =3D NULL; +UINTN mMeasurementNum =3D 0; =20 /// Items for which to gather cumulative statistics. PERF_CUM_DATA CumData[] =3D { PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK), PERF_INIT_CUM_DATA (START_IMAGE_TOK), @@ -98,10 +122,540 @@ DumpStatistics( void ) SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } =20 /** + This function scan ACPI table in RSDT. + + @param Rsdt ACPI RSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInRSDT ( + IN RSDT_TABLE *Rsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32 EntryCount; + UINT32 *EntryPtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount =3D (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADE= R)) / sizeof(UINT32); + + EntryPtr =3D &Rsdt->Entry; + for (Index =3D 0; Index < EntryCount; Index ++, EntryPtr ++) { + Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); + if (Table->Signature =3D=3D Signature) { + return Table; + } + } + + return NULL; +} + +/** + This function scan ACPI table in XSDT. + + @param Xsdt ACPI XSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInXSDT ( + IN XSDT_TABLE *Xsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32 EntryCount; + UINT64 EntryPtr; + UINTN BasePtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount =3D (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADE= R)) / sizeof(UINT64); + + BasePtr =3D (UINTN)(&(Xsdt->Entry)); + for (Index =3D 0; Index < EntryCount; Index ++) { + CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof= (UINT64)); + Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr)); + if (Table->Signature =3D=3D Signature) { + return Table; + } + } + + return NULL; +} + +/** + This function scan ACPI table in RSDP. + + @param Rsdp ACPI RSDP + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +FindAcpiPtr ( + IN EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, + IN UINT32 Signature + ) +{ + EFI_ACPI_DESCRIPTION_HEADER *AcpiTable; + RSDT_TABLE *Rsdt; + XSDT_TABLE *Xsdt; + + AcpiTable =3D NULL; + + // + // Check ACPI2.0 table + // + Rsdt =3D (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress; + Xsdt =3D NULL; + if ((Rsdp->Revision >=3D 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) { + Xsdt =3D (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress; + } + // + // Check Xsdt + // + if (Xsdt !=3D NULL) { + AcpiTable =3D ScanTableInXSDT (Xsdt, Signature); + } + // + // Check Rsdt + // + if ((AcpiTable =3D=3D NULL) && (Rsdt !=3D NULL)) { + AcpiTable =3D ScanTableInRSDT (Rsdt, Signature); + } + + return AcpiTable; +} + +/** + Get Boot performance table form Acpi table. + +**/ +EFI_STATUS +GetBootPerformanceTable ( + ) +{ + EFI_STATUS Status; + VOID *AcpiTable; + FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable; + + AcpiTable =3D NULL; + + Status =3D EfiGetSystemConfigurationTable ( + &gEfiAcpi20TableGuid, + &AcpiTable + ); + if (EFI_ERROR (Status)) { + Status =3D EfiGetSystemConfigurationTable ( + &gEfiAcpi10TableGuid, + &AcpiTable + ); + } + if (EFI_ERROR(Status)) { + return Status; + } + + FirmwarePerformanceTable =3D FindAcpiPtr ( + (EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)Acpi= Table, + EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATU= RE + ); + if (FirmwarePerformanceTable =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + mBootPerformanceTable =3D (UINT8*) (UINTN)FirmwarePerformanceTable->Boot= PointerRecord.BootPerformanceTablePointer; + mBootPerformanceTableSize =3D ((BOOT_PERFORMANCE_TABLE *) mBootPerforman= ceTable)->Header.Length; + + return EFI_SUCCESS; +} + +/** + Get Handle form Module Guid. + + @param ModuleGuid Module Guid. + @param Handle The handle to be returned. + +**/ +VOID +GetHandleFormModuleGuid ( + IN EFI_GUID *ModuleGuid, + IN OUT EFI_HANDLE *Handle + ) +{ + UINTN Index; + + if (IsZeroGuid (ModuleGuid)) { + *Handle =3D NULL; + } + // + // Try to get the Handle form the caached array. + // + for (Index =3D 0; Index < mCachePairCount; Index++) { + if (CompareGuid (ModuleGuid, &mCacheHandleGuidTable[Index].ModuleGuid)= ) { + *Handle =3D mCacheHandleGuidTable[Index].Handle; + break; + } + } + if (Index >=3D mCachePairCount) { + *Handle =3D NULL; + } +} + +/** +Cache the GUID and handle mapping pairs. In order to save time for searchi= ng. + +**/ +EFI_STATUS +BuildCachedGuidHandleTable ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + EFI_GUID *TempGuid; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath; + + Status =3D gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount= , &HandleBuffer); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mD= pHiiHandle, Status); + return Status; + } + + mCacheHandleGuidTable =3D AllocateZeroPool (HandleCount * sizeof (HANDLE= _GUID_MAP)); + if (mCacheHandleGuidTable =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + for (Index =3D 0; Index < HandleCount; Index++) { + // + // Try Handle as ImageHandle. + // + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiLoadedImageProtocolGuid, + (VOID**) &LoadedImage + ); + if (EFI_ERROR (Status)) { + // + // Try Handle as Controller Handle + // + Status =3D gBS->OpenProtocol ( + HandleBuffer[Index], + &gEfiDriverBindingProtocolGuid, + (VOID **) &DriverBinding, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (!EFI_ERROR (Status)) { + // + // Get Image protocol from ImageHandle + // + Status =3D gBS->HandleProtocol ( + DriverBinding->ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID**) &LoadedImage + ); + } + } + + if (!EFI_ERROR (Status) && LoadedImage !=3D NULL) { + // + // Get Module Guid from DevicePath. + // + if (LoadedImage->FilePath !=3D NULL && + LoadedImage->FilePath->Type =3D=3D MEDIA_DEVICE_PATH && + LoadedImage->FilePath->SubType =3D=3D MEDIA_PIWG_FW_FILE_DP + ) { + FvFilePath =3D (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedIm= age->FilePath; + TempGuid =3D &FvFilePath->FvFileName; + + mCacheHandleGuidTable[mCachePairCount].Handle =3D HandleBuffer[Ind= ex]; + CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, Temp= Guid); + mCachePairCount ++; + } + } + } + if (HandleBuffer !=3D NULL) { + FreePool (HandleBuffer); + HandleBuffer =3D NULL; + } + return Status; +} + +/** + Get Measurement form Fpdt records. + + @param RecordHeader Pointer to the start record. + @param IsStart Is start record or End record. + @param Measurement Pointer to the measurement which need to be = filled. + +**/ +VOID +GetMeasurementInfo ( + IN EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader, + IN BOOLEAN IsStart, + IN OUT MEASUREMENT_RECORD *Measurement + ) +{ + VOID *ModuleGuid; + EFI_HANDLE StartHandle; + + switch (RecordHeader->Type) { + case GUID_EVENT_TYPE: + ModuleGuid =3D &(((GUID_EVENT_RECORD *)RecordHeader= )->Guid); + Measurement->Identifier =3D ((UINT32)((GUID_EVENT_RECORD *)Recor= dHeader)->ProgressID); + if (IsStart) { + Measurement->StartTimeStamp =3D ((GUID_EVENT_RECORD *)RecordHeader)-= >Timestamp; + } else { + Measurement->EndTimeStamp =3D ((GUID_EVENT_RECORD *)RecordHeader)-= >Timestamp; + } + switch (Measurement->Identifier) { + case MODULE_START_ID: + case MODULE_END_ID: + if (mPeiPhase) { + Measurement->Token =3D ALit_PEIM; + Measurement->Module =3D ALit_PEIM; + } else if (mDxePhase) { + Measurement->Token =3D ALit_START_IMAGE; + Measurement->Module =3D ALit_START_IMAGE; + } + break; + default: + ASSERT(FALSE); + } + + if (AsciiStrnCmp (Measurement->Token, ALit_PEIM, PERF_TOKEN_LENGTH) = =3D=3D 0) { + Measurement->Handle =3D &(((GUID_EVENT_RECORD *)RecordHeader= )->Guid); + } else { + GetHandleFormModuleGuid(ModuleGuid, &StartHandle); + Measurement->Handle =3D StartHandle; + } + break; + + case DYNAMIC_STRING_EVENT_TYPE: + ModuleGuid =3D &(((DYNAMIC_STRING_EVENT_RECORD *)Re= cordHeader)->Guid); + Measurement->Identifier =3D ((UINT32)((DYNAMIC_STRING_EVENT_RECO= RD *)RecordHeader)->ProgressID); + if (IsStart) { + Measurement->StartTimeStamp =3D ((DYNAMIC_STRING_EVENT_RECORD *)Reco= rdHeader)->Timestamp; + } else { + Measurement->EndTimeStamp =3D ((DYNAMIC_STRING_EVENT_RECORD *)Reco= rdHeader)->Timestamp; + } + switch (Measurement->Identifier) { + case MODULE_START_ID: + case MODULE_END_ID: + if (mPeiPhase) { + Measurement->Token =3D ALit_PEIM; + } else if (mDxePhase) { + Measurement->Token =3D ALit_START_IMAGE; + } + break; + + case MODULE_LOADIMAGE_START_ID: + case MODULE_LOADIMAGE_END_ID: + Measurement->Token =3D ALit_LOAD_IMAGE; + break; + + case MODULE_DB_START_ID: + case MODULE_DB_END_ID: + Measurement->Token =3D ALit_DB_START; + break; + + case MODULE_DB_SUPPORT_START_ID: + case MODULE_DB_SUPPORT_END_ID: + Measurement->Token =3D ALit_DB_SUPPORT; + break; + + case MODULE_DB_STOP_START_ID: + case MODULE_DB_STOP_END_ID: + Measurement->Token =3D ALit_DB_STOP; + break; + + default: + Measurement->Token =3D ((DYNAMIC_STRING_EVENT_RECORD *)Reco= rdHeader)->String; + break; + } + + Measurement->Module =3D ((DYNAMIC_STRING_EVENT_RECORD *)Reco= rdHeader)->String; + + if (AsciiStrnCmp (Measurement->Token, ALit_PEIM, PERF_TOKEN_LENGTH) = =3D=3D 0) { + Measurement->Handle =3D &(((GUID_EVENT_RECORD *)RecordHeader= )->Guid); + } else { + GetHandleFormModuleGuid(ModuleGuid, &StartHandle); + Measurement->Handle =3D StartHandle; + } + break; + + case GUID_QWORD_EVENT_TYPE: + ModuleGuid =3D &(((GUID_QWORD_EVENT_RECORD *)Record= Header)->Guid); + Measurement->Identifier =3D ((UINT32)((GUID_QWORD_EVENT_RECORD *= )RecordHeader)->ProgressID); + if (IsStart) { + Measurement->StartTimeStamp =3D ((GUID_QWORD_EVENT_RECORD *)RecordHe= ader)->Timestamp; + } else { + Measurement->EndTimeStamp =3D ((GUID_QWORD_EVENT_RECORD *)RecordHe= ader)->Timestamp; + } + switch (Measurement->Identifier) { + case MODULE_DB_START_ID: + Measurement->Token =3D ALit_DB_START; + Measurement->Module =3D ALit_DB_START; + break; + + case MODULE_DB_SUPPORT_START_ID: + case MODULE_DB_SUPPORT_END_ID: + Measurement->Token =3D ALit_DB_SUPPORT; + Measurement->Module =3D ALit_DB_SUPPORT; + break; + + case MODULE_DB_STOP_START_ID: + case MODULE_DB_STOP_END_ID: + Measurement->Token =3D ALit_DB_STOP; + Measurement->Module =3D ALit_DB_STOP; + break; + + case MODULE_LOADIMAGE_START_ID: + case MODULE_LOADIMAGE_END_ID: + Measurement->Token =3D ALit_LOAD_IMAGE; + Measurement->Module =3D ALit_LOAD_IMAGE; + break; + + default: + ASSERT(FALSE); + } + GetHandleFormModuleGuid(ModuleGuid, &StartHandle); + Measurement->Handle =3D StartHandle; + break; + + case GUID_QWORD_STRING_EVENT_TYPE: + ModuleGuid =3D &(((GUID_QWORD_STRING_EVENT_RECORD *= )RecordHeader)->Guid); + Measurement->Identifier =3D ((UINT32)((GUID_QWORD_STRING_EVENT_R= ECORD *)RecordHeader)->ProgressID); + if (IsStart) { + Measurement->StartTimeStamp =3D ((GUID_QWORD_STRING_EVENT_RECORD*)Re= cordHeader)->Timestamp; + } else { + Measurement->EndTimeStamp =3D ((GUID_QWORD_STRING_EVENT_RECORD *)R= ecordHeader)->Timestamp; + } + // + // Currently only "DB:Start:" end record with GUID_QWORD_STRING_EVENT_= TYPE. + // + switch (Measurement->Identifier) { + case MODULE_DB_END_ID: + Measurement->Token =3D ALit_DB_START; + Measurement->Module =3D ALit_DB_START; + break; + default: + ASSERT(FALSE); + } + GetHandleFormModuleGuid(ModuleGuid, &StartHandle); + Measurement->Handle =3D StartHandle; + break; + + default: + break; + } +} + +/** + Search the start measurement in the mMeasurementList for the end measure= ment. + + @param EndMeasureMent Measurement for end record. + +**/ +VOID +SearchMeasurement ( + IN MEASUREMENT_RECORD *EndMeasureMent + ) +{ + INTN Index; + + for (Index =3D mMeasurementNum - 1; Index >=3D 0; Index--) { + if (AsciiStrnCmp (EndMeasureMent->Token, ALit_PEIM, PERF_TOKEN_LENGTH)= =3D=3D 0) { + if (mMeasurementList[Index].EndTimeStamp =3D=3D 0 && EndMeasureMent-= >Handle!=3D NULL && mMeasurementList[Index].Handle !=3D NULL&& + CompareGuid(mMeasurementList[Index].Handle, EndMeasureMent->Hand= le) && + (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 (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; + break; + } + } + } +} + +/** + Generate the measure record array. + +**/ +EFI_STATUS +BuildMeasurementList ( + ) +{ + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader; + UINT8 *PerformanceTablePtr; + UINT16 StartProgressId; + UINTN TableLength; + UINT8 *StartRecordEvent; + MEASUREMENT_RECORD MeasureMent; + + mMeasurementList =3D AllocateZeroPool (mBootPerformanceTableSize); + if (mMeasurementList =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + TableLength =3D sizeof (BOOT_PERFORMANCE_TABLE); + PerformanceTablePtr =3D (mBootPerformanceTable + TableLength); + + while (TableLength < mBootPerformanceTableSize) { + RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) P= erformanceTablePtr; + StartRecordEvent =3D (UINT8 *)RecordHeader; + StartProgressId =3D ((GUID_EVENT_RECORD *)StartRecordEvent)->Progres= sID; + + // + // 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)) || + (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 (((DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->= String, ALit_PEI) =3D=3D 0) { + mPeiPhase =3D TRUE; + } else if (AsciiStrCmp (((DYNAMIC_STRING_EVENT_RECORD *)StartRecordE= vent)->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 { + GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent); + SearchMeasurement (&MeasureMent); + } + TableLength +=3D RecordHeader->Length; + PerformanceTablePtr +=3D RecordHeader->Length; + } + return EFI_SUCCESS; +} + +/** Initialize the cumulative data. =20 **/ VOID InitCumulativeData ( @@ -153,10 +707,11 @@ RunDp ( BOOLEAN CumulativeMode; CONST CHAR16 *CustomCumulativeToken; PERF_CUM_DATA *CustomCumulativeData; UINTN NameSize; SHELL_STATUS ShellStatus; + TIMER_INFO TimerInfo; =20 StringPtr =3D NULL; SummaryMode =3D FALSE; VerboseMode =3D FALSE; AllMode =3D FALSE; @@ -173,10 +728,40 @@ RunDp ( // Status =3D ShellInitialize(); ASSERT_EFI_ERROR(Status); =20 // + // DP dump performance data by parsing FPDT table in ACPI table. + // Folloing 3 steps are to get the measurement form the FPDT table. + // + + // + //1. Get FPDT from ACPI table. + // + Status =3D GetBootPerformanceTable (); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_BOOT_PERFORMAN= CE_TABLE_FAIL), mDpHiiHandle); + return Status; + } + + // + //2. Cache the ModuleGuid and hanlde mapping table. + // + Status =3D BuildCachedGuidHandleTable(); + if (EFI_ERROR (Status)) { + return Status; + } + + // + //3. Build the measurement array form the FPDT records. + // + Status =3D BuildMeasurementList (); + if (EFI_ERROR(Status)) { + return Status; + } + + // // Process Command Line arguments // Status =3D ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE); if (EFI_ERROR(Status)) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpH= iiHandle); @@ -265,15 +850,13 @@ RunDp ( ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOU= ND), mDpHiiHandle); goto Done; } =20 TimerInfo.Frequency =3D (UINT32)DivU64x32 (PerformanceProperty->Frequen= cy, 1000); - TimerInfo.StartCount =3D PerformanceProperty->TimerStartValue; - TimerInfo.EndCount =3D PerformanceProperty->TimerEndValue; - - // Determine in which direction the performance counter counts. - TimerInfo.CountUp =3D (BOOLEAN) (TimerInfo.EndCount >=3D TimerInfo.Start= Count); + TimerInfo.StartCount =3D 0; + TimerInfo.EndCount =3D 0xFFFF; + TimerInfo.CountUp =3D TRUE; =20 // // Print header // // print DP's build version @@ -383,10 +966,16 @@ Done: if (CustomCumulativeData !=3D NULL) { SHELL_FREE_NON_NULL (CustomCumulativeData->Name); } SHELL_FREE_NON_NULL (CustomCumulativeData); =20 + SHELL_FREE_NON_NULL (mMeasurementList); + + SHELL_FREE_NON_NULL (mCacheHandleGuidTable); + + mMeasurementNum =3D 0; + mCachePairCount =3D 0; return ShellStatus; } =20 =20 /** diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/Dynam= icCommand/DpDynamicCommand/Dp.h index 4027b6b..9fd8857 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h @@ -1,9 +1,9 @@ /** @file Header file for 'dp' command functions. =20 - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 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 @@ -17,10 +17,13 @@ =20 =20 #include =20 #include +#include +#include +#include =20 #include #include #include #include @@ -40,11 +43,11 @@ #include =20 extern EFI_HANDLE mDpHiiHandle; =20 #define DP_MAJOR_VERSION 2 -#define DP_MINOR_VERSION 4 +#define DP_MINOR_VERSION 5 =20 /** * The value assigned to DP_DEBUG controls which debug output * is generated. Set it to ZERO to disable. **/ diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/Dyn= amicCommand/DpDynamicCommand/Dp.uni index b77c507..b6069ae 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni @@ -1,9 +1,9 @@ // *++ // // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.
-// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
// (C) Copyright 2015 Hewlett Packard Enterprise Development LP
// 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 @@ -49,14 +49,14 @@ #string STR_DP_HANDLE_SECTION #language en-US "Index: Handle = Driver Name Description Time(us)\n" #string STR_DP_HANDLE_VARS #language en-US "%5d: [%3x] %36= s %11s %L8d\n" #string STR_DP_HANDLE_SECTION2 #language en-US "Index: Handle = Driver Name Description Time(us) ID\n" #string STR_DP_HANDLE_VARS2 #language en-US "%5d: [%3x] %36s = %11s %L8d %5d\n" #string STR_DP_SECTION_PEIMS #language en-US "PEIMs" -#string STR_DP_PEIM_SECTION #language en-US "Index: Pointer V= alue Instance GUID Token Time(us)\n" -#string STR_DP_PEIM_VARS #language en-US "%5d: 0x%11p %g= PEIM %L8d\n" -#string STR_DP_PEIM_SECTION2 #language en-US "Index: Pointer Va= lue Instance GUID Token Time(us) ID\n" -#string STR_DP_PEIM_VARS2 #language en-US "%5d: 0x%11p %g P= EIM %L8d %5d\n" +#string STR_DP_PEIM_SECTION #language en-US "Index: = Instance GUID Token Time(us)\n" +#string STR_DP_PEIM_VARS #language en-US "%5d: %g PEIM= %L8d\n" +#string STR_DP_PEIM_SECTION2 #language en-US "Index: = Instance GUID Token Time(us) ID\n" +#string STR_DP_PEIM_VARS2 #language en-US "%5d: %g PEIM %= L8d %5d\n" #string STR_DP_SECTION_GENERAL #language en-US "General" #string STR_DP_GLOBAL_SECTION #language en-US "Index = Name Description Time(us)\n" #string STR_DP_GLOBAL_VARS #language en-US "%5d:%25s %31s= %L8d\n" #string STR_DP_GLOBAL_SECTION2 #language en-US "Index = Name Description Time(us) ID\n" #string STR_DP_GLOBAL_VARS2 #language en-US "%5d:%25s %31s %L= 8d %5d\n" @@ -88,10 +88,11 @@ #string STR_DP_RAW_VARS2 #language en-US "%5d: %16LX %16LX = %16LX %31a %31a %5d\n" #string STR_DP_RAW_HEADR2 #language en-US "\nIndex Han= dle Start Count End Count Token = Module ID\n" #string STR_DP_INCOMPLETE #language en-US " I " #string STR_DP_COMPLETE #language en-US " " #string STR_ALIT_UNKNOWN #language en-US "Unknown" +#string STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL #language en-US "= Fail to get boot performance table\n" =20 #string STR_GET_HELP_DP #language en-US "" ".TH dp 0 "Display performance metrics"\r\n" ".SH NAME\r\n" "Displays performance metrics that are stored in memory.\r\n" diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf b/ShellPkg/= DynamicCommand/DpDynamicCommand/DpApp.inf index b0ed229..54fe001 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf @@ -1,9 +1,9 @@ ## @file # Provides Shell 'dp' standalone application. # -# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2009 - 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 b= e found at # http://opensource.org/licenses/bsd-license.php # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, @@ -23,11 +23,10 @@ # This flag specifies whether HII resource section is generated into PE i= mage. # UEFI_HII_RESOURCE_SECTION =3D TRUE =20 [Sources.common] - PerformanceTokens.h Dp.uni Dp.c Dp.h Literals.h Literals.c @@ -59,10 +58,12 @@ DxeServicesLib PeCoffGetEntryPointLib =20 [Guids] gPerformanceProtocolGuid ## CONSUMES ## S= ystemTable + gEfiAcpi20TableGuid ## CONSUMES ## S= ystemTable + gEfiAcpi10TableGuid ## CONSUMES ## S= ystemTable =20 [Protocols] gEfiLoadedImageProtocolGuid ## CONSUMES gEfiDriverBindingProtocolGuid ## SOMETIMES_CON= SUMES gEfiComponentName2ProtocolGuid ## SOMETIMES_CON= SUMES diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf = b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf index 3164561..e906870 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf @@ -1,9 +1,9 @@ ## @file # Provides Shell 'dp' dynamic command. # -# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2009 - 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 b= e found at # http://opensource.org/licenses/bsd-license.php # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, @@ -24,11 +24,10 @@ # This flag specifies whether HII resource section is generated into PE i= mage. # UEFI_HII_RESOURCE_SECTION =3D TRUE =20 [Sources.common] - PerformanceTokens.h Dp.uni Dp.c Dp.h Literals.h Literals.c @@ -60,10 +59,12 @@ DxeServicesLib PeCoffGetEntryPointLib =20 [Guids] gPerformanceProtocolGuid ## CONSUMES ## S= ystemTable + gEfiAcpi20TableGuid ## CONSUMES + gEfiAcpi10TableGuid ## CONSUMES =20 [Protocols] gEfiLoadedImageProtocolGuid ## CONSUMES gEfiDriverBindingProtocolGuid ## SOMETIMES_CON= SUMES gEfiComponentName2ProtocolGuid ## SOMETIMES_CON= SUMES diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h b/ShellP= kg/DynamicCommand/DpDynamicCommand/DpInternal.h index ece1c23..eedc377 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h @@ -4,11 +4,11 @@ Declarations of data and functions which are private to the Dp applicati= on. This file should never be referenced by anything other than components o= f the Dp application. In addition to global data, function declarations for DpUtilities.c, DpTrace.c, and DpProfile.c are included here. =20 - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
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 @@ -27,16 +27,17 @@ extern EFI_HII_HANDLE mDpHiiHandle; extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; extern UINT64 mInterestThreshold; extern BOOLEAN mShowId; +extern UINT8 *mBootPerformanceTable; +extern UINTN mBootPerformanceTableLength; +extern MEASUREMENT_RECORD *mMeasurementList; +extern UINTN mMeasurementNum; =20 extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData stru= cture and init. to ZERO. =20 -/// Timer Specific Information. -extern TIMER_INFO TimerInfo; - /// Items for which to gather cumulative statistics. extern PERF_CUM_DATA CumData[]; =20 /// Number of items for which we are gathering cumulative statistics. extern UINT32 const NumCum; diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c b/ShellPkg/= DynamicCommand/DpDynamicCommand/DpTrace.c index bc882be..46ee0f8 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c @@ -1,9 +1,9 @@ /** @file Trace reporting for the Dp utility. =20 - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
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 @@ -21,17 +21,65 @@ #include #include #include #include =20 -#include - #include "Dp.h" #include "Literals.h" #include "DpInternal.h" =20 /** + Attempts to retrieve a performance measurement log entry from the perfor= mance measurement log. + + + @param LogEntryKey On entry, the key of the performance mea= surement log entry to retrieve. + 0, then the first performance measuremen= t log entry is retrieved. + On exit, the key of the next performance= log entry. + @param Handle Pointer to environment specific context = used to identify the component + being measured. + @param Token Pointer to a Null-terminated ASCII strin= g that identifies the component + being measured. + @param Module Pointer to a Null-terminated ASCII strin= g that identifies the module + being measured. + @param StartTimeStamp Pointer to the 64-bit time stamp that wa= s recorded when the measurement + was started. + @param EndTimeStamp Pointer to the 64-bit time stamp that wa= s recorded when the measurement + was ended. + @param Identifier Pointer to the 32-bit identifier that wa= s recorded when the measurement + was ended. + + @return The key for the next performance log entry (in general case). + +**/ +UINTN +GetPerformanceMeasurementRecord ( + IN UINTN LogEntryKey, + OUT CONST VOID **Handle, + OUT CONST CHAR8 **Token, + OUT CONST CHAR8 **Module, + OUT UINT64 *StartTimeStamp, + OUT UINT64 *EndTimeStamp, + OUT UINT32 *Identifier + ) +{ + if (LogEntryKey =3D=3D mMeasurementNum) { + return 0; + } + + *Handle =3D (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handl= e; + *Token =3D mMeasurementList[LogEntryKey].Token; + *Module =3D mMeasurementList[LogEntryKey].Module; + *StartTimeStamp =3D mMeasurementList[LogEntryKey].StartTimeStamp; + *EndTimeStamp =3D mMeasurementList[LogEntryKey].EndTimeStamp; + *Identifier =3D mMeasurementList[LogEntryKey].Identifier; + + LogEntryKey ++; + + return LogEntryKey; +} + +/** Collect verbose statistics about the logged performance measurements. =20 General Summary information for all Trace measurements is gathered and stored within the SummaryData structure. This information is both used internally by subsequent reporting functions, and displayed @@ -55,11 +103,11 @@ GatherStatistics( UINT64 Duration; UINTN LogEntryKey; INTN TIndex; =20 LogEntryKey =3D 0; - while ((LogEntryKey =3D GetPerformanceMeasurementEx ( + while ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, @@ -77,11 +125,11 @@ GatherStatistics( } =20 if (IsPhase( &Measurement)) { ++SummaryData.NumSummary; // Count the number of major phases } - else { // !IsPhase(... + else { // !IsPhase if(Measurement.Handle =3D=3D NULL) { ++SummaryData.NumGlobal; } } =20 @@ -188,11 +236,11 @@ DumpAllTrace( =20 LogEntryKey =3D 0; Count =3D 0; Index =3D 0; while ( WITHIN_LIMIT(Count, Limit) && - ((LogEntryKey =3D GetPerformanceMeasurementEx ( + ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, @@ -329,11 +377,11 @@ DumpRawTrace( =20 LogEntryKey =3D 0; Count =3D 0; Index =3D 0; while ( WITHIN_LIMIT(Count, Limit) && - ((LogEntryKey =3D GetPerformanceMeasurementEx ( + ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, @@ -418,11 +466,11 @@ ProcessPhases( (StringPtr =3D=3D NULL) ? StringPtrUnknown : StringPtr); FreePool (StringPtr); FreePool (StringPtrUnknown); =20 LogEntryKey =3D 0; - while ((LogEntryKey =3D GetPerformanceMeasurementEx ( + while ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, @@ -460,45 +508,33 @@ ProcessPhases( } =20 // print PEI phase duration time // if (PeiTime > 0) { - ElapsedTime =3D DivU64x32 ( - PeiTime, - (UINT32)TimerInfo.Frequency - ); + ElapsedTime =3D DivU64x32 (PeiTime, 1000000); Total +=3D ElapsedTime; ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), m= DpHiiHandle, ALit_PEI, ElapsedTime); } =20 // print DXE phase duration time // if (DxeTime > 0) { - ElapsedTime =3D DivU64x32 ( - DxeTime, - (UINT32)TimerInfo.Frequency - ); + ElapsedTime =3D DivU64x32 (DxeTime, 1000000); Total +=3D ElapsedTime; ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), m= DpHiiHandle, ALit_DXE, ElapsedTime); } =20 // print BDS phase duration time // if (BdsTime > 0) { - ElapsedTime =3D DivU64x32 ( - BdsTime, - (UINT32)TimerInfo.Frequency - ); + ElapsedTime =3D DivU64x32 (BdsTime, 1000000); Total +=3D ElapsedTime; ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), m= DpHiiHandle, ALit_BDS, ElapsedTime); } =20 if (BdsTimeoutValue > 0) { - ElapsedTime =3D DivU64x32 ( - BdsTimeoutValue, - (UINT32)TimerInfo.Frequency - ); + ElapsedTime =3D DivU64x32 (BdsTimeoutValue, 1000000); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpH= iiHandle, ALit_BdsTO, ElapsedTime); } =20 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), mDp= HiiHandle, Total); } @@ -552,11 +588,11 @@ ProcessHandles( } ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHan= dle); =20 LogEntryKey =3D 0; Count =3D 0; - while ((LogEntryKey =3D GetPerformanceMeasurementEx ( + while ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, @@ -655,11 +691,11 @@ ProcessPeims( ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDp= HiiHandle); } ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandl= e); TIndex =3D 0; LogEntryKey =3D 0; - while ((LogEntryKey =3D GetPerformanceMeasurementEx ( + while ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, @@ -678,19 +714,17 @@ ProcessPeims( if (ElapsedTime >=3D mInterestThreshold) { // PEIM FILE Handle is the start address of its FFS file that contai= ns its file guid. if (mShowId) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), m= DpHiiHandle, TIndex, // 1 based, Which measurement record is being prin= ted - Measurement.Handle, // base address Measurement.Handle, // file guid ElapsedTime, Measurement.Identifier ); } else { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mD= pHiiHandle, TIndex, // 1 based, Which measurement record is being prin= ted - Measurement.Handle, // base address Measurement.Handle, // file guid ElapsedTime ); } } @@ -744,11 +778,11 @@ ProcessGlobal( ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandl= e); =20 Index =3D 1; LogEntryKey =3D 0; =20 - while ((LogEntryKey =3D GetPerformanceMeasurementEx ( + while ((LogEntryKey =3D GetPerformanceMeasurementRecord ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c b/Shell= Pkg/DynamicCommand/DpDynamicCommand/DpUtilities.c index b98ec4b..3d082e9 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c @@ -1,9 +1,9 @@ /** @file Utility functions used by the Dp application. =20 - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
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 @@ -37,11 +37,11 @@ =20 #include "Dp.h" #include "Literals.h" #include "DpInternal.h" =20 -/**=20 +/** Calculate an event's duration in timer ticks. =20 Given the count direction and the event's start and end timer values, calculate the duration of the event in timer ticks. Information for the current measurement is pointed to by the parameter. @@ -69,35 +69,21 @@ GetDuration ( =20 if (Measurement->EndTimeStamp =3D=3D 0) { return 0; } =20 - // PERF_START macros are called with a value of 1 to indicate - // the beginning of time. So, adjust the start ticker value - // to the real beginning of time. - // Assumes no wraparound. Even then, there is a very low probability - // of having a valid StartTicker value of 1. - if (Measurement->StartTimeStamp =3D=3D 1) { - Measurement->StartTimeStamp =3D TimerInfo.StartCount; - } - if (TimerInfo.CountUp) { - Duration =3D Measurement->EndTimeStamp - Measurement->StartTimeStamp; - Error =3D (BOOLEAN)(Duration > Measurement->EndTimeStamp); - } - else { - Duration =3D Measurement->StartTimeStamp - Measurement->EndTimeStamp; - Error =3D (BOOLEAN)(Duration > Measurement->StartTimeStamp); - } + Duration =3D Measurement->EndTimeStamp - Measurement->StartTimeStamp; + Error =3D (BOOLEAN)(Duration > Measurement->EndTimeStamp); =20 if (Error) { DEBUG ((EFI_D_ERROR, ALit_TimerLibError)); Duration =3D 0; } return Duration; } =20 -/**=20 +/** Determine whether the Measurement record is for an EFI Phase. =20 The Token and Module members of the measurement record are checked. Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHE= LL. =20 @@ -111,11 +97,11 @@ IsPhase( IN MEASUREMENT_RECORD *Measurement ) { BOOLEAN RetVal; =20 - RetVal =3D (BOOLEAN)( ( *Measurement->Module =3D=3D '\0') = && + RetVal =3D (BOOLEAN)( ((AsciiStrnCmp (Measurement->Token, ALit_SEC, PERF_TOKEN_LENGT= H) =3D=3D 0) || (AsciiStrnCmp (Measurement->Token, ALit_PEI, PERF_TOKEN_LENGT= H) =3D=3D 0) || (AsciiStrnCmp (Measurement->Token, ALit_DXE, PERF_TOKEN_LENGT= H) =3D=3D 0) || (AsciiStrnCmp (Measurement->Token, ALit_BDS, PERF_TOKEN_LENGT= H) =3D=3D 0)) ); @@ -376,14 +362,11 @@ DpGetNameFromHandle ( UINT64 DurationInMicroSeconds ( IN UINT64 Duration ) { - UINT64 Temp; - - Temp =3D MultU64x32 (Duration, 1000); - return DivU64x32 (Temp, TimerInfo.Frequency); + return DivU64x32 (Duration, 1000); } =20 /**=20 Get index of Measurement Record's match in the CumData array. =20 diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c b/ShellPkg= /DynamicCommand/DpDynamicCommand/Literals.c index c1cddfb..69dfc57 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c @@ -1,22 +1,28 @@ /** @file Definitions of ASCII string literals used by DP. =20 - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 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 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. **/ -#include +#include =20 // ASCII String literals which probably don't need translation -CHAR8 const ALit_TimerLibError[] =3D "Timer library instance error!\n"; -CHAR8 const ALit_SEC[] =3D SEC_TOK; -CHAR8 const ALit_DXE[] =3D DXE_TOK; -CHAR8 const ALit_PEI[] =3D PEI_TOK; -CHAR8 const ALit_BDS[] =3D BDS_TOK; -CHAR8 const ALit_BdsTO[] =3D "BdsTimeOut"; -CHAR8 const ALit_PEIM[] =3D "PEIM"; +CHAR8 const ALit_TimerLibError[] =3D "Timer library instance error!\n"; +CHAR8 const ALit_SEC[] =3D SEC_TOK; +CHAR8 const ALit_DXE[] =3D DXE_TOK; +CHAR8 const ALit_PEI[] =3D PEI_TOK; +CHAR8 const ALit_BDS[] =3D BDS_TOK; +CHAR8 const ALit_START_IMAGE[] =3D START_IMAGE_TOK; +CHAR8 const ALit_LOAD_IMAGE[] =3D LOAD_IMAGE_TOK; +CHAR8 const ALit_DB_START[] =3D DRIVERBINDING_START_TOK; +CHAR8 const ALit_DB_SUPPORT[] =3D DRIVERBINDING_SUPPORT_TOK; +CHAR8 const ALit_DB_STOP[] =3D DRIVERBINDING_STOP_TOK; + +CHAR8 const ALit_BdsTO[] =3D "BdsTimeOut"; +CHAR8 const ALit_PEIM[] =3D "PEIM"; diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h b/ShellPkg= /DynamicCommand/DpDynamicCommand/Literals.h index 8aec09c..8695b1e 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h @@ -1,9 +1,9 @@ /** @file Declarations of ASCII string literals used by DP. =20 - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 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 @@ -18,9 +18,15 @@ extern CHAR8 const ALit_TimerLibError[]; extern CHAR8 const ALit_SEC[]; extern CHAR8 const ALit_DXE[]; extern CHAR8 const ALit_SHELL[]; extern CHAR8 const ALit_PEI[]; extern CHAR8 const ALit_BDS[]; +extern CHAR8 const ALit_PEIM[]; +extern CHAR8 const ALit_START_IMAGE[]; +extern CHAR8 const ALit_LOAD_IMAGE[]; +extern CHAR8 const ALit_DB_START[]; +extern CHAR8 const ALit_DB_SUPPORT[]; +extern CHAR8 const ALit_DB_STOP[]; extern CHAR8 const ALit_BdsTO[]; extern CHAR8 const ALit_PEIM[]; =20 #endif // _LITERALS_H_ diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h b= /ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h deleted file mode 100644 index bbbc48d..0000000 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - ASCII String Literals with special meaning to Performance measurement an= d the Dp utility. - -Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD = License -which accompanies this distribution. The full text of the license may be = found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. - -**/ - -#ifndef __PERFORMANCE_TOKENS_H__ -#define __PERFORMANCE_TOKENS_H__ - -#define SEC_TOK "SEC" ///< SEC Phase -#define DXE_TOK "DXE" ///< DEC Phase -#define SHELL_TOK "SHELL" ///< Shell Phase -#define PEI_TOK "PEI" ///< PEI Phase -#define BDS_TOK "BDS" ///< BDS Phase -#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Bind= ing Start() function call -#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Bind= ing Support() function call -#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a disp= atched module -#define START_IMAGE_TOK "StartImage:" ///< Dispatched = Modules Entry Point execution - -#endif // __PERFORMANCE_TOKENS_H__ --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel