Cc: Liming Gao <liming....@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Ruiyu Ni <ruiyu...@intel.com>
Cc: Jaben Carsey <jaben.car...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 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 | 108 ++--
 .../DynamicCommand/DpDynamicCommand/DpUtilities.c  |  37 +-
 .../DynamicCommand/DpDynamicCommand/Literals.c     |  24 +-
 .../DynamicCommand/DpDynamicCommand/Literals.h     |   8 +-
 .../DpDynamicCommand/PerformanceTokens.h           |  28 -
 11 files changed, 724 insertions(+), 127 deletions(-)
 delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 3ecc753..fafc64f 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -11,40 +11,64 @@
   Measurement records contain identifying information (Handle, Token, Module)
   and start and end time values.
   Dp uses this information to group records in different ways.  It also uses
   timer information to calculate elapsed time for each measurement.
  
-  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<BR>
   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 IMPLIED.
 **/
 
-#include "PerformanceTokens.h"
 #include "Dp.h"
 #include "Literals.h"
 #include "DpInternal.h"
 
+#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;
 
+typedef struct {
+  EFI_HANDLE    Handle;
+  EFI_GUID      ModuleGuid;
+} HANDLE_GUID_MAP;
+
+HANDLE_GUID_MAP  *mCacheHandleGuidTable;
+UINTN            mCachePairCount = 0;
+
 //
 /// Module-Global Variables
 ///@{
 CHAR16           mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
 CHAR16           mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
 UINT64           mInterestThreshold;
 BOOLEAN          mShowId = FALSE;
+UINT8            *mBootPerformanceTable;
+UINTN            mBootPerformanceTableSize;
+BOOLEAN          mPeiPhase = FALSE;
+BOOLEAN          mDxePhase = FALSE;
 
 PERF_SUMMARY_DATA SummaryData = { 0 };    ///< Create the SummaryData 
structure and init. to ZERO.
-
-/// Timer Specific Information.
-TIMER_INFO TimerInfo;
+MEASUREMENT_RECORD  *mMeasurementList = NULL;
+UINTN               mMeasurementNum    = 0;
 
 /// Items for which to gather cumulative statistics.
 PERF_CUM_DATA CumData[] = {
   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);
 }
 
 /**
+  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 = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / 
sizeof(UINT32);
+
+  EntryPtr = &Rsdt->Entry;
+  for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
+    Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));
+    if (Table->Signature == 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 = (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / 
sizeof(UINT64);
+
+  BasePtr = (UINTN)(&(Xsdt->Entry));
+  for (Index = 0; Index < EntryCount; Index ++) {
+    CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), 
sizeof(UINT64));
+    Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));
+    if (Table->Signature == 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 = NULL;
+
+  //
+  // Check ACPI2.0 table
+  //
+  Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;
+  Xsdt = NULL;
+  if ((Rsdp->Revision >= 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) {
+    Xsdt = (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress;
+  }
+  //
+  // Check Xsdt
+  //
+  if (Xsdt != NULL) {
+    AcpiTable = ScanTableInXSDT (Xsdt, Signature);
+  }
+  //
+  // Check Rsdt
+  //
+  if ((AcpiTable == NULL) && (Rsdt != NULL)) {
+    AcpiTable = 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 = NULL;
+
+  Status = EfiGetSystemConfigurationTable (
+             &gEfiAcpi20TableGuid,
+             &AcpiTable
+             );
+  if (EFI_ERROR (Status)) {
+    Status = EfiGetSystemConfigurationTable (
+               &gEfiAcpi10TableGuid,
+               &AcpiTable
+                 );
+  }
+  if (EFI_ERROR(Status)) {
+    return Status;
+  }
+
+  FirmwarePerformanceTable = FindAcpiPtr (
+                      (EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER 
*)AcpiTable,
+                      EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
+                      );
+  if (FirmwarePerformanceTable == NULL) {
+    return EFI_NOT_FOUND;
+  }
+
+  mBootPerformanceTable = (UINT8*) 
(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
+  mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *) 
mBootPerformanceTable)->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 = NULL;
+  }
+  //
+  // Try to get the Handle form the caached array.
+  //
+  for (Index = 0; Index < mCachePairCount; Index++) {
+    if (CompareGuid (ModuleGuid, &mCacheHandleGuidTable[Index].ModuleGuid)) {
+      *Handle = mCacheHandleGuidTable[Index].Handle;
+      break;
+    }
+  }
+  if (Index >= mCachePairCount) {
+    *Handle = NULL;
+  }
+}
+
+/**
+Cache the GUID and handle mapping pairs. In order to save time for searching.
+
+**/
+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 = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, 
&HandleBuffer);
+  if (EFI_ERROR (Status)) {
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), 
mDpHiiHandle, Status);
+    return Status;
+  }
+
+  mCacheHandleGuidTable = AllocateZeroPool (HandleCount * sizeof 
(HANDLE_GUID_MAP));
+  if (mCacheHandleGuidTable == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  for (Index = 0; Index < HandleCount; Index++) {
+    //
+    // Try Handle as ImageHandle.
+    //
+    Status = gBS->HandleProtocol (
+                  HandleBuffer[Index],
+                  &gEfiLoadedImageProtocolGuid,
+                  (VOID**) &LoadedImage
+                  );
+    if (EFI_ERROR (Status)) {
+      //
+      // Try Handle as Controller Handle
+      //
+      Status = gBS->OpenProtocol (
+                    HandleBuffer[Index],
+                    &gEfiDriverBindingProtocolGuid,
+                    (VOID **) &DriverBinding,
+                    NULL,
+                    NULL,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+      if (!EFI_ERROR (Status)) {
+        //
+        // Get Image protocol from ImageHandle
+        //
+        Status = gBS->HandleProtocol (
+                      DriverBinding->ImageHandle,
+                      &gEfiLoadedImageProtocolGuid,
+                      (VOID**) &LoadedImage
+                      );
+      }
+    }
+
+    if (!EFI_ERROR (Status) && LoadedImage != NULL) {
+      //
+      // Get Module Guid from DevicePath.
+      //
+      if (LoadedImage->FilePath != NULL &&
+          LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
+          LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
+         ) {
+        FvFilePath      = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) 
LoadedImage->FilePath;
+        TempGuid        = &FvFilePath->FvFileName;
+
+        mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index];
+        CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, 
TempGuid);
+        mCachePairCount ++;
+      }
+    }
+  }
+  if (HandleBuffer != NULL) {
+    FreePool (HandleBuffer);
+    HandleBuffer = 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 FPDT_GUID_EVENT_TYPE:
+    ModuleGuid                    = &(((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->Guid);
+    Measurement->Identifier       = ((UINT32)((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->ProgressID);
+    if (IsStart) {
+      Measurement->StartTimeStamp = ((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    } else {
+      Measurement->EndTimeStamp   = ((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    }
+    switch (Measurement->Identifier) {
+    case MODULE_START_ID:
+    case MODULE_END_ID:
+      if (mPeiPhase) {
+        Measurement->Token        = ALit_PEIM;
+        Measurement->Module       = ALit_PEIM;
+      } else if (mDxePhase) {
+        Measurement->Token        = ALit_START_IMAGE;
+        Measurement->Module       = ALit_START_IMAGE;
+      }
+      break;
+    default:
+      ASSERT(FALSE);
+    }
+
+    if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
+      Measurement->Handle         = &(((FPDT_GUID_EVENT_RECORD 
*)RecordHeader)->Guid);
+    } else {
+      GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
+      Measurement->Handle         = StartHandle;
+    }
+    break;
+
+  case FPDT_DYNAMIC_STRING_EVENT_TYPE:
+    ModuleGuid                    = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
+    Measurement->Identifier       = 
((UINT32)((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+    if (IsStart) {
+      Measurement->StartTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    } else {
+      Measurement->EndTimeStamp   = ((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    }
+    switch (Measurement->Identifier) {
+    case MODULE_START_ID:
+    case MODULE_END_ID:
+      if (mPeiPhase) {
+        Measurement->Token        = ALit_PEIM;
+      } else if (mDxePhase) {
+        Measurement->Token        = ALit_START_IMAGE;
+      }
+      break;
+
+    case MODULE_LOADIMAGE_START_ID:
+    case MODULE_LOADIMAGE_END_ID:
+      Measurement->Token          = ALit_LOAD_IMAGE;
+      break;
+
+    case MODULE_DB_START_ID:
+    case MODULE_DB_END_ID:
+      Measurement->Token          = ALit_DB_START;
+      break;
+
+    case MODULE_DB_SUPPORT_START_ID:
+    case MODULE_DB_SUPPORT_END_ID:
+      Measurement->Token          = ALit_DB_SUPPORT;
+      break;
+
+    case MODULE_DB_STOP_START_ID:
+    case MODULE_DB_STOP_END_ID:
+      Measurement->Token          = ALit_DB_STOP;
+      break;
+
+    default:
+      Measurement->Token          = ((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->String;
+      break;
+    }
+
+    Measurement->Module           = ((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->String;
+
+    if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
+      Measurement->Handle         = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
+    } else {
+      GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
+      Measurement->Handle = StartHandle;
+    }
+    break;
+
+  case FPDT_GUID_QWORD_EVENT_TYPE:
+    ModuleGuid                    = &(((FPDT_GUID_QWORD_EVENT_RECORD 
*)RecordHeader)->Guid);
+    Measurement->Identifier       = ((UINT32)((FPDT_GUID_QWORD_EVENT_RECORD 
*)RecordHeader)->ProgressID);
+    if (IsStart) {
+      Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    } else {
+      Measurement->EndTimeStamp   = ((FPDT_GUID_QWORD_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    }
+    switch (Measurement->Identifier) {
+    case MODULE_DB_START_ID:
+      Measurement->Token          = ALit_DB_START;
+      Measurement->Module         = ALit_DB_START;
+      break;
+
+    case MODULE_DB_SUPPORT_START_ID:
+    case MODULE_DB_SUPPORT_END_ID:
+      Measurement->Token          = ALit_DB_SUPPORT;
+      Measurement->Module         = ALit_DB_SUPPORT;
+      break;
+
+    case MODULE_DB_STOP_START_ID:
+    case MODULE_DB_STOP_END_ID:
+      Measurement->Token          = ALit_DB_STOP;
+      Measurement->Module         = ALit_DB_STOP;
+      break;
+
+    case MODULE_LOADIMAGE_START_ID:
+    case MODULE_LOADIMAGE_END_ID:
+      Measurement->Token          = ALit_LOAD_IMAGE;
+      Measurement->Module         = ALit_LOAD_IMAGE;
+      break;
+
+    default:
+      ASSERT(FALSE);
+    }
+    GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
+    Measurement->Handle = StartHandle;
+    break;
+
+  case  FPDT_GUID_QWORD_STRING_EVENT_TYPE:
+    ModuleGuid                    = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD 
*)RecordHeader)->Guid);
+    Measurement->Identifier       = 
((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+    if (IsStart) {
+      Measurement->StartTimeStamp = 
((FPDT_GUID_QWORD_STRING_EVENT_RECORD*)RecordHeader)->Timestamp;
+    } else {
+      Measurement->EndTimeStamp   = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD 
*)RecordHeader)->Timestamp;
+    }
+    //
+    // Currently only "DB:Start:" end record with 
FPDT_GUID_QWORD_STRING_EVENT_TYPE.
+    //
+    switch (Measurement->Identifier) {
+    case MODULE_DB_END_ID:
+      Measurement->Token          = ALit_DB_START;
+      Measurement->Module         = ALit_DB_START;
+      break;
+    default:
+      ASSERT(FALSE);
+    }
+    GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
+    Measurement->Handle = StartHandle;
+    break;
+
+  default:
+    break;
+  }
+}
+
+/**
+  Search the start measurement in the mMeasurementList for the end measurement.
+
+  @param  EndMeasureMent        Measurement for end record.
+
+**/
+VOID
+SearchMeasurement (
+  IN MEASUREMENT_RECORD                           *EndMeasureMent
+  )
+{
+  INTN                            Index;
+
+  for (Index = mMeasurementNum - 1; Index >= 0; Index--) {
+    if (AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) {
+      if (mMeasurementList[Index].EndTimeStamp == 0 && 
EndMeasureMent->Handle!= NULL && mMeasurementList[Index].Handle != NULL&&
+          CompareGuid(mMeasurementList[Index].Handle, EndMeasureMent->Handle) 
&&
+          (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) 
== 0) &&
+          (AsciiStrCmp (mMeasurementList[Index].Module, 
EndMeasureMent->Module) == 0)) {
+        mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
+        break;
+      }
+    } else {
+      if (mMeasurementList[Index].EndTimeStamp == 0 && 
mMeasurementList[Index].Handle == EndMeasureMent->Handle &&
+         (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) 
== 0) &&
+         (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) 
== 0)) {
+        mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
+        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 = AllocateZeroPool (mBootPerformanceTableSize);
+  if (mMeasurementList == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  TableLength         = sizeof (BOOT_PERFORMANCE_TABLE);
+  PerformanceTablePtr = (mBootPerformanceTable + TableLength);
+
+  while (TableLength < mBootPerformanceTableSize) {
+    RecordHeader      = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) 
PerformanceTablePtr;
+    StartRecordEvent  = (UINT8 *)RecordHeader;
+    StartProgressId   = ((FPDT_GUID_EVENT_RECORD 
*)StartRecordEvent)->ProgressID;
+
+    //
+    // 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 >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 
0x000F) == 0)) ||
+        (StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 
0x0001) != 0)))) {
+      //
+      // Since PEIM and StartImage has same Type and ID when PCD 
PcdEdkiiFpdtStringRecordEnableOnly = FALSE
+      // So we need to identify these two kinds of record through different 
phase.
+      //
+      if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)StartRecordEvent)->String, ALit_PEI) == 0) {
+        mPeiPhase = TRUE;
+      } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD 
*)StartRecordEvent)->String, ALit_DXE) == 0) {
+        mDxePhase = TRUE;
+        mPeiPhase = FALSE;
+      }
+      // Get measurement info form the start record to the mMeasurementList.
+      GetMeasurementInfo (RecordHeader, TRUE, 
&(mMeasurementList[mMeasurementNum]));
+      mMeasurementNum ++;
+    } else {
+      GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);
+      SearchMeasurement (&MeasureMent);
+    }
+    TableLength         += RecordHeader->Length;
+    PerformanceTablePtr += RecordHeader->Length;
+  }
+  return EFI_SUCCESS;
+}
+
+/**
   Initialize the cumulative data.
 
 **/
 VOID
 InitCumulativeData (
@@ -153,10 +707,11 @@ RunDp (
   BOOLEAN                   CumulativeMode;
   CONST CHAR16              *CustomCumulativeToken;
   PERF_CUM_DATA             *CustomCumulativeData;
   UINTN                     NameSize;
   SHELL_STATUS              ShellStatus;
+  TIMER_INFO                TimerInfo;
 
   StringPtr   = NULL;
   SummaryMode = FALSE;
   VerboseMode = FALSE;
   AllMode     = FALSE;
@@ -173,10 +728,40 @@ RunDp (
   //
   Status = ShellInitialize();
   ASSERT_EFI_ERROR(Status);
 
   //
+  // 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 = GetBootPerformanceTable ();
+  if (EFI_ERROR(Status)) {
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL), mDpHiiHandle);
+    return Status;
+  }
+
+  //
+  //2. Cache the ModuleGuid and hanlde mapping table.
+  //
+  Status = BuildCachedGuidHandleTable();
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  //3. Build the measurement array form the FPDT records.
+  //
+  Status = BuildMeasurementList ();
+  if (EFI_ERROR(Status)) {
+    return Status;
+  }
+
+  //
   // Process Command Line arguments
   //
   Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
   if (EFI_ERROR(Status)) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), 
mDpHiiHandle);
@@ -265,15 +850,13 @@ RunDp (
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), 
mDpHiiHandle);
     goto Done;
   }
 
   TimerInfo.Frequency  = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 
1000);
-  TimerInfo.StartCount = PerformanceProperty->TimerStartValue;
-  TimerInfo.EndCount   = PerformanceProperty->TimerEndValue;
-
-  // Determine in which direction the performance counter counts.
-  TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);
+  TimerInfo.StartCount = 0;
+  TimerInfo.EndCount   = 0xFFFF;
+  TimerInfo.CountUp = TRUE;
 
   //
   // Print header
   //
   // print DP's build version
@@ -383,10 +966,16 @@ Done:
   if (CustomCumulativeData != NULL) {
     SHELL_FREE_NON_NULL (CustomCumulativeData->Name);
   }
   SHELL_FREE_NON_NULL (CustomCumulativeData);
 
+  SHELL_FREE_NON_NULL (mMeasurementList);
+
+  SHELL_FREE_NON_NULL (mCacheHandleGuidTable);
+
+  mMeasurementNum = 0;
+  mCachePairCount = 0;
   return ShellStatus;
 }
 
 
 /**
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h 
b/ShellPkg/DynamicCommand/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.
 
-  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 BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -17,10 +17,13 @@
 
 
 #include <Uefi.h>
 
 #include <Guid/Performance.h>
+#include <Guid/ExtendedFirmwarePerformance.h>
+#include <Guid/FirmwarePerformance.h>
+#include <Guid/Acpi.h>
 
 #include <Protocol/HiiPackageList.h>
 #include <Protocol/DevicePath.h>
 #include <Protocol/LoadedImage.h>
 #include <Protocol/UnicodeCollation.h>
@@ -40,11 +43,11 @@
 #include <Library/UefiHiiServicesLib.h>
 
 extern EFI_HANDLE mDpHiiHandle;
 
 #define DP_MAJOR_VERSION        2
-#define DP_MINOR_VERSION        4
+#define DP_MINOR_VERSION        5
 
 /**
   * 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/DynamicCommand/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.<BR>
-// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
 // (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 // 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
@@ -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]   %36s    
%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 Value 
             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 Value  
           Instance GUID            Token  Time(us)    ID\n"
-#string STR_DP_PEIM_VARS2              #language en-US  "%5d: 0x%11p  %g PEIM  
%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  %L8d 
%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       Handle  
      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"
 
 #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 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,
@@ -23,11 +23,10 @@
 #  This flag specifies whether HII resource section is generated into PE image.
 #
   UEFI_HII_RESOURCE_SECTION      = TRUE
 
 [Sources.common]
-  PerformanceTokens.h
   Dp.uni
   Dp.c
   Dp.h
   Literals.h
   Literals.c
@@ -59,10 +58,12 @@
   DxeServicesLib
   PeCoffGetEntryPointLib
 
 [Guids]
   gPerformanceProtocolGuid                                ## CONSUMES ## 
SystemTable
+  gEfiAcpi20TableGuid                                     ## CONSUMES ## 
SystemTable
+  gEfiAcpi10TableGuid                                     ## CONSUMES ## 
SystemTable
 
 [Protocols]
   gEfiLoadedImageProtocolGuid                             ## CONSUMES
   gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
   gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES
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 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,
@@ -24,11 +24,10 @@
 #  This flag specifies whether HII resource section is generated into PE image.
 #
   UEFI_HII_RESOURCE_SECTION      = TRUE
 
 [Sources.common]
-  PerformanceTokens.h
   Dp.uni
   Dp.c
   Dp.h
   Literals.h
   Literals.c
@@ -60,10 +59,12 @@
   DxeServicesLib
   PeCoffGetEntryPointLib
 
 [Guids]
   gPerformanceProtocolGuid                                ## CONSUMES ## 
SystemTable
+  gEfiAcpi20TableGuid                                     ## CONSUMES
+  gEfiAcpi10TableGuid                                     ## CONSUMES
 
 [Protocols]
   gEfiLoadedImageProtocolGuid                             ## CONSUMES
   gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
   gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h 
b/ShellPkg/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 application.
   This file should never be referenced by anything other than components of the
   Dp application.  In addition to global data, function declarations for
   DpUtilities.c, DpTrace.c, and DpProfile.c are included here.
 
-  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<BR>
   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
@@ -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;
 
 extern PERF_SUMMARY_DATA  SummaryData;    ///< Create the SummaryData 
structure and init. to ZERO.
 
-/// Timer Specific Information.
-extern TIMER_INFO         TimerInfo;
-
 /// Items for which to gather cumulative statistics.
 extern PERF_CUM_DATA      CumData[];
 
 /// 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..7f7d296 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
@@ -1,9 +1,9 @@
 /** @file
   Trace reporting for the Dp utility.
 
-  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<BR>
   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
@@ -21,17 +21,65 @@
 #include <Library/PerformanceLib.h>
 #include <Library/PrintLib.h>
 #include <Library/HiiLib.h>
 #include <Library/PcdLib.h>
 
-#include <Guid/Performance.h>
-
 #include "Dp.h"
 #include "Literals.h"
 #include "DpInternal.h"
 
 /**
+  Attempts to retrieve a performance measurement log entry from the 
performance measurement log.
+
+
+  @param  LogEntryKey             On entry, the key of the performance 
measurement log entry to retrieve.
+                                  0, then the first performance measurement 
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 string 
that identifies the component
+                                  being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string 
that identifies the module
+                                  being measured.
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was 
recorded when the measurement
+                                  was started.
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was 
recorded when the measurement
+                                  was ended.
+  @param  Identifier              Pointer to the 32-bit identifier that was 
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 == mMeasurementNum) {
+    return 0;
+  }
+
+  *Handle         = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle;
+  *Token          = mMeasurementList[LogEntryKey].Token;
+  *Module         = mMeasurementList[LogEntryKey].Module;
+  *StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;
+  *EndTimeStamp   = mMeasurementList[LogEntryKey].EndTimeStamp;
+  *Identifier     = mMeasurementList[LogEntryKey].Identifier;
+
+  LogEntryKey ++;
+
+  return LogEntryKey;
+}
+
+/**
   Collect verbose statistics about the logged performance measurements.
 
   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;
 
   LogEntryKey = 0;
-  while ((LogEntryKey = GetPerformanceMeasurementEx (
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (
                         LogEntryKey,
                         &Measurement.Handle,
                         &Measurement.Token,
                         &Measurement.Module,
                         &Measurement.StartTimeStamp,
@@ -77,17 +125,17 @@ GatherStatistics(
     }
 
     if (IsPhase( &Measurement)) {
       ++SummaryData.NumSummary;       // Count the number of major phases
     }
-    else {  // !IsPhase(...
+    else {  // !IsPhase
       if(Measurement.Handle == NULL) {
         ++SummaryData.NumGlobal;
       }
     }
 
-    if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {
+    if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {
       ++SummaryData.NumPEIMs;         // Count PEIM measurements
     }
 
     Duration = GetDuration (&Measurement);
     TIndex = GetCumulativeItem (&Measurement);
@@ -188,11 +236,11 @@ DumpAllTrace(
 
     LogEntryKey = 0;
     Count = 0;
     Index = 0;
     while ( WITHIN_LIMIT(Count, Limit) &&
-            ((LogEntryKey = GetPerformanceMeasurementEx (
+            ((LogEntryKey = GetPerformanceMeasurementRecord (
                             LogEntryKey,
                             &Measurement.Handle,
                             &Measurement.Token,
                             &Measurement.Module,
                             &Measurement.StartTimeStamp,
@@ -229,11 +277,11 @@ DumpAllTrace(
             break;
           }
         }
       }
 
-      if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) 
{
+      if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {
         UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", 
Measurement.Handle);
       }
 
       // Ensure that the argument strings are not too long.
       mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
@@ -329,11 +377,11 @@ DumpRawTrace(
 
   LogEntryKey = 0;
   Count = 0;
   Index = 0;
   while ( WITHIN_LIMIT(Count, Limit) &&
-          ((LogEntryKey = GetPerformanceMeasurementEx (
+          ((LogEntryKey = GetPerformanceMeasurementRecord (
                           LogEntryKey,
                           &Measurement.Handle,
                           &Measurement.Token,
                           &Measurement.Module,
                           &Measurement.StartTimeStamp,
@@ -418,11 +466,11 @@ ProcessPhases(
               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
   LogEntryKey = 0;
-  while ((LogEntryKey = GetPerformanceMeasurementEx (
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (
                           LogEntryKey,
                           &Measurement.Handle,
                           &Measurement.Token,
                           &Measurement.Module,
                           &Measurement.StartTimeStamp,
@@ -432,21 +480,21 @@ ProcessPhases(
     if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records
       continue;
     }
     Duration = GetDuration (&Measurement);
     if (   Measurement.Handle != NULL
-        && (AsciiStrnCmp (Measurement.Token, ALit_BdsTO, PERF_TOKEN_LENGTH) == 
0)
+        && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
        )
     {
       BdsTimeoutValue = Duration;
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_SEC, PERF_TOKEN_LENGTH) 
== 0) {
+    } else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {
       SecTime     = Duration;
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_PEI, PERF_TOKEN_LENGTH) 
== 0) {
+    } else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {
       PeiTime     = Duration;
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_DXE, PERF_TOKEN_LENGTH) 
== 0) {
+    } else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {
       DxeTime      = Duration;
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_BDS, PERF_TOKEN_LENGTH) 
== 0) {
+    } else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {
       BdsTime      = Duration;
     }
   }
 
   Total = 0;
@@ -460,45 +508,33 @@ ProcessPhases(
   }
 
   // print PEI phase duration time
   //
   if (PeiTime > 0) {
-    ElapsedTime = DivU64x32 (
-                    PeiTime,
-                    (UINT32)TimerInfo.Frequency
-                    );
+    ElapsedTime = DivU64x32 (PeiTime, 1000000);
     Total += ElapsedTime;
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), 
mDpHiiHandle, ALit_PEI, ElapsedTime);
   }
 
   // print DXE phase duration time
   //
   if (DxeTime > 0) {
-    ElapsedTime = DivU64x32 (
-                    DxeTime,
-                    (UINT32)TimerInfo.Frequency
-                    );
+    ElapsedTime = DivU64x32 (DxeTime, 1000000);
     Total += ElapsedTime;
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), 
mDpHiiHandle, ALit_DXE, ElapsedTime);
   }
 
   // print BDS phase duration time
   //
   if (BdsTime > 0) {
-    ElapsedTime = DivU64x32 (
-                    BdsTime,
-                    (UINT32)TimerInfo.Frequency
-                    );
+    ElapsedTime = DivU64x32 (BdsTime, 1000000);
     Total += ElapsedTime;
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), 
mDpHiiHandle, ALit_BDS, ElapsedTime);
   }
 
   if (BdsTimeoutValue > 0) {
-    ElapsedTime = DivU64x32 (
-                    BdsTimeoutValue,
-                    (UINT32)TimerInfo.Frequency
-                    );
+    ElapsedTime = DivU64x32 (BdsTimeoutValue, 1000000);
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), 
mDpHiiHandle, ALit_BdsTO, ElapsedTime);
   }
 
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), 
mDpHiiHandle, Total);
 }
@@ -552,11 +588,11 @@ ProcessHandles(
     }
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
 
     LogEntryKey = 0;
     Count   = 0;
-    while ((LogEntryKey = GetPerformanceMeasurementEx (
+    while ((LogEntryKey = GetPerformanceMeasurementRecord (
                             LogEntryKey,
                             &Measurement.Handle,
                             &Measurement.Token,
                             &Measurement.Module,
                             &Measurement.StartTimeStamp,
@@ -655,22 +691,22 @@ ProcessPeims(
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), 
mDpHiiHandle);
   }
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
   TIndex  = 0;
   LogEntryKey = 0;
-  while ((LogEntryKey = GetPerformanceMeasurementEx (
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (
                           LogEntryKey,
                           &Measurement.Handle,
                           &Measurement.Token,
                           &Measurement.Module,
                           &Measurement.StartTimeStamp,
                           &Measurement.EndTimeStamp,
                           &Measurement.Identifier)) != 0)
   {
     TIndex++;
     if ((Measurement.EndTimeStamp == 0) ||
-        (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) != 0)
+        (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)
        ) {
       continue;
     }
 
     Duration = GetDuration (&Measurement);
@@ -678,19 +714,17 @@ ProcessPeims(
     if (ElapsedTime >= mInterestThreshold) {
       // PEIM FILE Handle is the start address of its FFS file that contains 
its file guid.
       if (mShowId) {
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), 
mDpHiiHandle,
               TIndex,   // 1 based, Which measurement record is being printed
-              Measurement.Handle,  // base address
               Measurement.Handle,  // file guid
               ElapsedTime,
               Measurement.Identifier
         );
       } else {
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), 
mDpHiiHandle,
               TIndex,   // 1 based, Which measurement record is being printed
-              Measurement.Handle,  // base address
               Measurement.Handle,  // file guid
               ElapsedTime
         );
       }
     }
@@ -744,11 +778,11 @@ ProcessGlobal(
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
 
   Index = 1;
   LogEntryKey = 0;
 
-  while ((LogEntryKey = GetPerformanceMeasurementEx (
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (
                           LogEntryKey,
                           &Measurement.Handle,
                           &Measurement.Token,
                           &Measurement.Module,
                           &Measurement.StartTimeStamp,
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
index b98ec4b..39f71a0 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.
 
-  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<BR>
   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
@@ -69,26 +69,12 @@ GetDuration (
 
   if (Measurement->EndTimeStamp == 0) {
     return 0;
   }
 
-  // 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 == 1) {
-    Measurement->StartTimeStamp = TimerInfo.StartCount;
-  }
-  if (TimerInfo.CountUp) {
-    Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;
-    Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
-  }
-  else {
-    Duration = Measurement->StartTimeStamp - Measurement->EndTimeStamp;
-    Error = (BOOLEAN)(Duration > Measurement->StartTimeStamp);
-  }
+  Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;
+  Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
 
   if (Error) {
     DEBUG ((EFI_D_ERROR, ALit_TimerLibError));
     Duration = 0;
   }
@@ -111,15 +97,15 @@ IsPhase(
   IN MEASUREMENT_RECORD        *Measurement
   )
 {
   BOOLEAN   RetVal;
 
-  RetVal = (BOOLEAN)( ( *Measurement->Module == '\0')                          
     &&
-            ((AsciiStrnCmp (Measurement->Token, ALit_SEC, PERF_TOKEN_LENGTH) 
== 0)    ||
-             (AsciiStrnCmp (Measurement->Token, ALit_PEI, PERF_TOKEN_LENGTH) 
== 0)    ||
-             (AsciiStrnCmp (Measurement->Token, ALit_DXE, PERF_TOKEN_LENGTH) 
== 0)    ||
-             (AsciiStrnCmp (Measurement->Token, ALit_BDS, PERF_TOKEN_LENGTH) 
== 0))
+  RetVal = (BOOLEAN)(
+            ((AsciiStrCmp (Measurement->Token, ALit_SEC) == 0)    ||
+             (AsciiStrCmp (Measurement->Token, ALit_PEI) == 0)    ||
+             (AsciiStrCmp (Measurement->Token, ALit_DXE) == 0)    ||
+             (AsciiStrCmp (Measurement->Token, ALit_BDS) == 0))
             );
   return RetVal;
 }
 
 /** 
@@ -376,14 +362,11 @@ DpGetNameFromHandle (
 UINT64
 DurationInMicroSeconds (
   IN UINT64 Duration
   )
 {
-  UINT64 Temp;
-
-  Temp = MultU64x32 (Duration, 1000);
-  return DivU64x32 (Temp, TimerInfo.Frequency);
+  return DivU64x32 (Duration, 1000);
 }
 
 /** 
   Get index of Measurement Record's match in the CumData array.
   
@@ -403,11 +386,11 @@ GetCumulativeItem(
   )
 {
   INTN    Index;
 
   for( Index = 0; Index < (INTN)NumCum; ++Index) {
-    if (AsciiStrnCmp (Measurement->Token, CumData[Index].Name, 
PERF_TOKEN_LENGTH) == 0) {
+    if (AsciiStrCmp (Measurement->Token, CumData[Index].Name) == 0) {
       return Index;  // Exit, we found a match
     }
   }
   // If the for loop exits, Token was not found.
   return -1;   // Indicate failure
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.
 
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
   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 IMPLIED.
 **/
-#include <PerformanceTokens.h>
+#include <Guid/ExtendedFirmwarePerformance.h>
 
 // ASCII String literals which probably don't need translation
-CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";
-CHAR8 const ALit_SEC[]    = SEC_TOK;
-CHAR8 const ALit_DXE[]    = DXE_TOK;
-CHAR8 const ALit_PEI[]    = PEI_TOK;
-CHAR8 const ALit_BDS[]    = BDS_TOK;
-CHAR8 const ALit_BdsTO[]  = "BdsTimeOut";
-CHAR8 const ALit_PEIM[]   = "PEIM";
+CHAR8 const ALit_TimerLibError[]  = "Timer library instance error!\n";
+CHAR8 const ALit_SEC[]            = SEC_TOK;
+CHAR8 const ALit_DXE[]            = DXE_TOK;
+CHAR8 const ALit_PEI[]            = PEI_TOK;
+CHAR8 const ALit_BDS[]            = BDS_TOK;
+CHAR8 const ALit_START_IMAGE[]    = START_IMAGE_TOK;
+CHAR8 const ALit_LOAD_IMAGE[]     = LOAD_IMAGE_TOK;
+CHAR8 const ALit_DB_START[]       = DRIVERBINDING_START_TOK;
+CHAR8 const ALit_DB_SUPPORT[]     = DRIVERBINDING_SUPPORT_TOK;
+CHAR8 const ALit_DB_STOP[]        = DRIVERBINDING_STOP_TOK;
+
+CHAR8 const ALit_BdsTO[]      = "BdsTimeOut";
+CHAR8 const ALit_PEIM[]       = "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.
 
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
   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
 
@@ -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[];
 
 #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 and 
the Dp utility.
-
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
-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 IMPLIED.
-
-**/
-
-#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 Binding 
Start() function call
-#define DRIVERBINDING_SUPPORT_TOK       "DB:Support:"     ///< Driver Binding 
Support() function call
-#define LOAD_IMAGE_TOK                  "LoadImage:"      ///< Load a 
dispatched module
-#define START_IMAGE_TOK                 "StartImage:"     ///< Dispatched 
Modules Entry Point execution
-
-#endif  // __PERFORMANCE_TOKENS_H__
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to