]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/Dp: Updated to dump perf log based on FPDT table
authorDandan Bi <dandan.bi@intel.com>
Mon, 22 Jan 2018 08:39:03 +0000 (16:39 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 8 Feb 2018 04:50:22 +0000 (12:50 +0800)
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h [deleted file]

index 3ecc753d0cf7313c8b5fb79fcfcadc42848eea38..fafc64fe2d950902936f91e396798e8ece8e9922 100644 (file)
@@ -13,7 +13,7 @@
   Dp uses this information to group records in different ways.  It also uses\r
   timer information to calculate elapsed time for each measurement.\r
  \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
 \r
-#include "PerformanceTokens.h"\r
 #include "Dp.h"\r
 #include "Literals.h"\r
 #include "DpInternal.h"\r
 \r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER  Header;\r
+  UINT32                       Entry;\r
+} RSDT_TABLE;\r
+\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER  Header;\r
+  UINT64                       Entry;\r
+} XSDT_TABLE;\r
+\r
+#pragma pack()\r
+\r
 EFI_HANDLE   mDpHiiHandle;\r
 \r
+typedef struct {\r
+  EFI_HANDLE    Handle;\r
+  EFI_GUID      ModuleGuid;\r
+} HANDLE_GUID_MAP;\r
+\r
+HANDLE_GUID_MAP  *mCacheHandleGuidTable;\r
+UINTN            mCachePairCount = 0;\r
+\r
 //\r
 /// Module-Global Variables\r
 ///@{\r
@@ -38,11 +59,14 @@ CHAR16           mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
 CHAR16           mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
 UINT64           mInterestThreshold;\r
 BOOLEAN          mShowId = FALSE;\r
+UINT8            *mBootPerformanceTable;\r
+UINTN            mBootPerformanceTableSize;\r
+BOOLEAN          mPeiPhase = FALSE;\r
+BOOLEAN          mDxePhase = FALSE;\r
 \r
 PERF_SUMMARY_DATA SummaryData = { 0 };    ///< Create the SummaryData structure and init. to ZERO.\r
-\r
-/// Timer Specific Information.\r
-TIMER_INFO TimerInfo;\r
+MEASUREMENT_RECORD  *mMeasurementList = NULL;\r
+UINTN               mMeasurementNum    = 0;\r
 \r
 /// Items for which to gather cumulative statistics.\r
 PERF_CUM_DATA CumData[] = {\r
@@ -99,6 +123,536 @@ DumpStatistics( void )
   SHELL_FREE_NON_NULL (StringPtrUnknown);\r
 }\r
 \r
+/**\r
+  This function scan ACPI table in RSDT.\r
+\r
+  @param  Rsdt        ACPI RSDT\r
+  @param  Signature   ACPI table signature\r
+\r
+  @return ACPI table\r
+**/\r
+VOID *\r
+ScanTableInRSDT (\r
+  IN RSDT_TABLE                   *Rsdt,\r
+  IN UINT32                       Signature\r
+  )\r
+{\r
+  UINTN                         Index;\r
+  UINT32                        EntryCount;\r
+  UINT32                        *EntryPtr;\r
+  EFI_ACPI_DESCRIPTION_HEADER   *Table;\r
+\r
+  EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);\r
+\r
+  EntryPtr = &Rsdt->Entry;\r
+  for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {\r
+    Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));\r
+    if (Table->Signature == Signature) {\r
+      return Table;\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  This function scan ACPI table in XSDT.\r
+\r
+  @param  Xsdt       ACPI XSDT\r
+  @param  Signature  ACPI table signature\r
+\r
+  @return ACPI table\r
+**/\r
+VOID *\r
+ScanTableInXSDT (\r
+  IN XSDT_TABLE                   *Xsdt,\r
+  IN UINT32                       Signature\r
+  )\r
+{\r
+  UINTN                        Index;\r
+  UINT32                       EntryCount;\r
+  UINT64                       EntryPtr;\r
+  UINTN                        BasePtr;\r
+  EFI_ACPI_DESCRIPTION_HEADER  *Table;\r
+\r
+  EntryCount = (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);\r
+\r
+  BasePtr = (UINTN)(&(Xsdt->Entry));\r
+  for (Index = 0; Index < EntryCount; Index ++) {\r
+    CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));\r
+    Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));\r
+    if (Table->Signature == Signature) {\r
+      return Table;\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  This function scan ACPI table in RSDP.\r
+\r
+  @param  Rsdp       ACPI RSDP\r
+  @param  Signature  ACPI table signature\r
+\r
+  @return ACPI table\r
+**/\r
+VOID *\r
+FindAcpiPtr (\r
+  IN EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp,\r
+  IN UINT32                                       Signature\r
+  )\r
+{\r
+  EFI_ACPI_DESCRIPTION_HEADER                    *AcpiTable;\r
+  RSDT_TABLE                                     *Rsdt;\r
+  XSDT_TABLE                                     *Xsdt;\r
+\r
+  AcpiTable = NULL;\r
+\r
+  //\r
+  // Check ACPI2.0 table\r
+  //\r
+  Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;\r
+  Xsdt = NULL;\r
+  if ((Rsdp->Revision >= 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) {\r
+    Xsdt = (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress;\r
+  }\r
+  //\r
+  // Check Xsdt\r
+  //\r
+  if (Xsdt != NULL) {\r
+    AcpiTable = ScanTableInXSDT (Xsdt, Signature);\r
+  }\r
+  //\r
+  // Check Rsdt\r
+  //\r
+  if ((AcpiTable == NULL) && (Rsdt != NULL)) {\r
+    AcpiTable = ScanTableInRSDT (Rsdt, Signature);\r
+  }\r
+\r
+  return AcpiTable;\r
+}\r
+\r
+/**\r
+  Get Boot performance table form Acpi table.\r
+\r
+**/\r
+EFI_STATUS\r
+GetBootPerformanceTable (\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  VOID                        *AcpiTable;\r
+  FIRMWARE_PERFORMANCE_TABLE  *FirmwarePerformanceTable;\r
+\r
+  AcpiTable = NULL;\r
+\r
+  Status = EfiGetSystemConfigurationTable (\r
+             &gEfiAcpi20TableGuid,\r
+             &AcpiTable\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EfiGetSystemConfigurationTable (\r
+               &gEfiAcpi10TableGuid,\r
+               &AcpiTable\r
+                 );\r
+  }\r
+  if (EFI_ERROR(Status)) {\r
+    return Status;\r
+  }\r
+\r
+  FirmwarePerformanceTable = FindAcpiPtr (\r
+                      (EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable,\r
+                      EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE\r
+                      );\r
+  if (FirmwarePerformanceTable == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootPerformanceTable = (UINT8*) (UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;\r
+  mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *) mBootPerformanceTable)->Header.Length;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Get Handle form Module Guid.\r
+\r
+  @param  ModuleGuid     Module Guid.\r
+  @param  Handle         The handle to be returned.\r
+\r
+**/\r
+VOID\r
+GetHandleFormModuleGuid (\r
+  IN      EFI_GUID        *ModuleGuid,\r
+  IN OUT  EFI_HANDLE      *Handle\r
+  )\r
+{\r
+  UINTN                             Index;\r
+\r
+  if (IsZeroGuid (ModuleGuid)) {\r
+    *Handle = NULL;\r
+  }\r
+  //\r
+  // Try to get the Handle form the caached array.\r
+  //\r
+  for (Index = 0; Index < mCachePairCount; Index++) {\r
+    if (CompareGuid (ModuleGuid, &mCacheHandleGuidTable[Index].ModuleGuid)) {\r
+      *Handle = mCacheHandleGuidTable[Index].Handle;\r
+      break;\r
+    }\r
+  }\r
+  if (Index >= mCachePairCount) {\r
+    *Handle = NULL;\r
+  }\r
+}\r
+\r
+/**\r
+Cache the GUID and handle mapping pairs. In order to save time for searching.\r
+\r
+**/\r
+EFI_STATUS\r
+BuildCachedGuidHandleTable (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_HANDLE                        *HandleBuffer;\r
+  UINTN                             HandleCount;\r
+  UINTN                             Index;\r
+  EFI_LOADED_IMAGE_PROTOCOL         *LoadedImage;\r
+  EFI_DRIVER_BINDING_PROTOCOL       *DriverBinding;\r
+  EFI_GUID                          *TempGuid;\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
+\r
+  Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
+  if (EFI_ERROR (Status)) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);\r
+    return Status;\r
+  }\r
+\r
+  mCacheHandleGuidTable = AllocateZeroPool (HandleCount * sizeof (HANDLE_GUID_MAP));\r
+  if (mCacheHandleGuidTable == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    //\r
+    // Try Handle as ImageHandle.\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                  HandleBuffer[Index],\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID**) &LoadedImage\r
+                  );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Try Handle as Controller Handle\r
+      //\r
+      Status = gBS->OpenProtocol (\r
+                    HandleBuffer[Index],\r
+                    &gEfiDriverBindingProtocolGuid,\r
+                    (VOID **) &DriverBinding,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+      if (!EFI_ERROR (Status)) {\r
+        //\r
+        // Get Image protocol from ImageHandle\r
+        //\r
+        Status = gBS->HandleProtocol (\r
+                      DriverBinding->ImageHandle,\r
+                      &gEfiLoadedImageProtocolGuid,\r
+                      (VOID**) &LoadedImage\r
+                      );\r
+      }\r
+    }\r
+\r
+    if (!EFI_ERROR (Status) && LoadedImage != NULL) {\r
+      //\r
+      // Get Module Guid from DevicePath.\r
+      //\r
+      if (LoadedImage->FilePath != NULL &&\r
+          LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&\r
+          LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP\r
+         ) {\r
+        FvFilePath      = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedImage->FilePath;\r
+        TempGuid        = &FvFilePath->FvFileName;\r
+\r
+        mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index];\r
+        CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, TempGuid);\r
+        mCachePairCount ++;\r
+      }\r
+    }\r
+  }\r
+  if (HandleBuffer != NULL) {\r
+    FreePool (HandleBuffer);\r
+    HandleBuffer = NULL;\r
+  }\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Get Measurement form Fpdt records.\r
+\r
+  @param  RecordHeader        Pointer to the start record.\r
+  @param  IsStart             Is start record or End record.\r
+  @param  Measurement         Pointer to the measurement which need to be filled.\r
+\r
+**/\r
+VOID\r
+GetMeasurementInfo (\r
+  IN     EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER  *RecordHeader,\r
+  IN     BOOLEAN                                      IsStart,\r
+  IN OUT MEASUREMENT_RECORD                           *Measurement\r
+  )\r
+{\r
+  VOID                                         *ModuleGuid;\r
+  EFI_HANDLE                                   StartHandle;\r
+\r
+  switch (RecordHeader->Type) {\r
+  case FPDT_GUID_EVENT_TYPE:\r
+    ModuleGuid                    = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);\r
+    Measurement->Identifier       = ((UINT32)((FPDT_GUID_EVENT_RECORD *)RecordHeader)->ProgressID);\r
+    if (IsStart) {\r
+      Measurement->StartTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    } else {\r
+      Measurement->EndTimeStamp   = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    }\r
+    switch (Measurement->Identifier) {\r
+    case MODULE_START_ID:\r
+    case MODULE_END_ID:\r
+      if (mPeiPhase) {\r
+        Measurement->Token        = ALit_PEIM;\r
+        Measurement->Module       = ALit_PEIM;\r
+      } else if (mDxePhase) {\r
+        Measurement->Token        = ALit_START_IMAGE;\r
+        Measurement->Module       = ALit_START_IMAGE;\r
+      }\r
+      break;\r
+    default:\r
+      ASSERT(FALSE);\r
+    }\r
+\r
+    if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {\r
+      Measurement->Handle         = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);\r
+    } else {\r
+      GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
+      Measurement->Handle         = StartHandle;\r
+    }\r
+    break;\r
+\r
+  case FPDT_DYNAMIC_STRING_EVENT_TYPE:\r
+    ModuleGuid                    = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);\r
+    Measurement->Identifier       = ((UINT32)((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);\r
+    if (IsStart) {\r
+      Measurement->StartTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    } else {\r
+      Measurement->EndTimeStamp   = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    }\r
+    switch (Measurement->Identifier) {\r
+    case MODULE_START_ID:\r
+    case MODULE_END_ID:\r
+      if (mPeiPhase) {\r
+        Measurement->Token        = ALit_PEIM;\r
+      } else if (mDxePhase) {\r
+        Measurement->Token        = ALit_START_IMAGE;\r
+      }\r
+      break;\r
+\r
+    case MODULE_LOADIMAGE_START_ID:\r
+    case MODULE_LOADIMAGE_END_ID:\r
+      Measurement->Token          = ALit_LOAD_IMAGE;\r
+      break;\r
+\r
+    case MODULE_DB_START_ID:\r
+    case MODULE_DB_END_ID:\r
+      Measurement->Token          = ALit_DB_START;\r
+      break;\r
+\r
+    case MODULE_DB_SUPPORT_START_ID:\r
+    case MODULE_DB_SUPPORT_END_ID:\r
+      Measurement->Token          = ALit_DB_SUPPORT;\r
+      break;\r
+\r
+    case MODULE_DB_STOP_START_ID:\r
+    case MODULE_DB_STOP_END_ID:\r
+      Measurement->Token          = ALit_DB_STOP;\r
+      break;\r
+\r
+    default:\r
+      Measurement->Token          = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;\r
+      break;\r
+    }\r
+\r
+    Measurement->Module           = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;\r
+\r
+    if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {\r
+      Measurement->Handle         = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);\r
+    } else {\r
+      GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
+      Measurement->Handle = StartHandle;\r
+    }\r
+    break;\r
+\r
+  case FPDT_GUID_QWORD_EVENT_TYPE:\r
+    ModuleGuid                    = &(((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Guid);\r
+    Measurement->Identifier       = ((UINT32)((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->ProgressID);\r
+    if (IsStart) {\r
+      Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    } else {\r
+      Measurement->EndTimeStamp   = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    }\r
+    switch (Measurement->Identifier) {\r
+    case MODULE_DB_START_ID:\r
+      Measurement->Token          = ALit_DB_START;\r
+      Measurement->Module         = ALit_DB_START;\r
+      break;\r
+\r
+    case MODULE_DB_SUPPORT_START_ID:\r
+    case MODULE_DB_SUPPORT_END_ID:\r
+      Measurement->Token          = ALit_DB_SUPPORT;\r
+      Measurement->Module         = ALit_DB_SUPPORT;\r
+      break;\r
+\r
+    case MODULE_DB_STOP_START_ID:\r
+    case MODULE_DB_STOP_END_ID:\r
+      Measurement->Token          = ALit_DB_STOP;\r
+      Measurement->Module         = ALit_DB_STOP;\r
+      break;\r
+\r
+    case MODULE_LOADIMAGE_START_ID:\r
+    case MODULE_LOADIMAGE_END_ID:\r
+      Measurement->Token          = ALit_LOAD_IMAGE;\r
+      Measurement->Module         = ALit_LOAD_IMAGE;\r
+      break;\r
+\r
+    default:\r
+      ASSERT(FALSE);\r
+    }\r
+    GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
+    Measurement->Handle = StartHandle;\r
+    break;\r
+\r
+  case  FPDT_GUID_QWORD_STRING_EVENT_TYPE:\r
+    ModuleGuid                    = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Guid);\r
+    Measurement->Identifier       = ((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);\r
+    if (IsStart) {\r
+      Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD*)RecordHeader)->Timestamp;\r
+    } else {\r
+      Measurement->EndTimeStamp   = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    }\r
+    //\r
+    // Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE.\r
+    //\r
+    switch (Measurement->Identifier) {\r
+    case MODULE_DB_END_ID:\r
+      Measurement->Token          = ALit_DB_START;\r
+      Measurement->Module         = ALit_DB_START;\r
+      break;\r
+    default:\r
+      ASSERT(FALSE);\r
+    }\r
+    GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
+    Measurement->Handle = StartHandle;\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+}\r
+\r
+/**\r
+  Search the start measurement in the mMeasurementList for the end measurement.\r
+\r
+  @param  EndMeasureMent        Measurement for end record.\r
+\r
+**/\r
+VOID\r
+SearchMeasurement (\r
+  IN MEASUREMENT_RECORD                           *EndMeasureMent\r
+  )\r
+{\r
+  INTN                            Index;\r
+\r
+  for (Index = mMeasurementNum - 1; Index >= 0; Index--) {\r
+    if (AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) {\r
+      if (mMeasurementList[Index].EndTimeStamp == 0 && EndMeasureMent->Handle!= NULL && mMeasurementList[Index].Handle != NULL&&\r
+          CompareGuid(mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&\r
+          (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&\r
+          (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {\r
+        mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;\r
+        break;\r
+      }\r
+    } else {\r
+      if (mMeasurementList[Index].EndTimeStamp == 0 && mMeasurementList[Index].Handle == EndMeasureMent->Handle &&\r
+         (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&\r
+         (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {\r
+        mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  Generate the measure record array.\r
+\r
+**/\r
+EFI_STATUS\r
+BuildMeasurementList (\r
+  )\r
+{\r
+  EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER  *RecordHeader;\r
+  UINT8                                        *PerformanceTablePtr;\r
+  UINT16                                       StartProgressId;\r
+  UINTN                                        TableLength;\r
+  UINT8                                        *StartRecordEvent;\r
+  MEASUREMENT_RECORD                           MeasureMent;\r
+\r
+  mMeasurementList = AllocateZeroPool (mBootPerformanceTableSize);\r
+  if (mMeasurementList == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  TableLength         = sizeof (BOOT_PERFORMANCE_TABLE);\r
+  PerformanceTablePtr = (mBootPerformanceTable + TableLength);\r
+\r
+  while (TableLength < mBootPerformanceTableSize) {\r
+    RecordHeader      = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) PerformanceTablePtr;\r
+    StartRecordEvent  = (UINT8 *)RecordHeader;\r
+    StartProgressId   = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;\r
+\r
+    //\r
+    // If the record is the start record, fill the info to the measurement in the mMeasurementList.\r
+    // If the record is the end record, find the related start measurement in the mMeasurementList and fill the EndTimeStamp.\r
+    //\r
+    if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||\r
+        (StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) {\r
+      //\r
+      // Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE\r
+      // So we need to identify these two kinds of record through different phase.\r
+      //\r
+      if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {\r
+        mPeiPhase = TRUE;\r
+      } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {\r
+        mDxePhase = TRUE;\r
+        mPeiPhase = FALSE;\r
+      }\r
+      // Get measurement info form the start record to the mMeasurementList.\r
+      GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));\r
+      mMeasurementNum ++;\r
+    } else {\r
+      GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);\r
+      SearchMeasurement (&MeasureMent);\r
+    }\r
+    TableLength         += RecordHeader->Length;\r
+    PerformanceTablePtr += RecordHeader->Length;\r
+  }\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Initialize the cumulative data.\r
 \r
@@ -155,6 +709,7 @@ RunDp (
   PERF_CUM_DATA             *CustomCumulativeData;\r
   UINTN                     NameSize;\r
   SHELL_STATUS              ShellStatus;\r
+  TIMER_INFO                TimerInfo;\r
 \r
   StringPtr   = NULL;\r
   SummaryMode = FALSE;\r
@@ -174,6 +729,36 @@ RunDp (
   Status = ShellInitialize();\r
   ASSERT_EFI_ERROR(Status);\r
 \r
+  //\r
+  // DP dump performance data by parsing FPDT table in ACPI table.\r
+  // Folloing 3 steps are to get the measurement form the FPDT table.\r
+  //\r
+\r
+  //\r
+  //1. Get FPDT from ACPI table.\r
+  //\r
+  Status = GetBootPerformanceTable ();\r
+  if (EFI_ERROR(Status)) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL), mDpHiiHandle);\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  //2. Cache the ModuleGuid and hanlde mapping table.\r
+  //\r
+  Status = BuildCachedGuidHandleTable();\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  //3. Build the measurement array form the FPDT records.\r
+  //\r
+  Status = BuildMeasurementList ();\r
+  if (EFI_ERROR(Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Process Command Line arguments\r
   //\r
@@ -267,11 +852,9 @@ RunDp (
   }\r
 \r
   TimerInfo.Frequency  = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 1000);\r
-  TimerInfo.StartCount = PerformanceProperty->TimerStartValue;\r
-  TimerInfo.EndCount   = PerformanceProperty->TimerEndValue;\r
-\r
-  // Determine in which direction the performance counter counts.\r
-  TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);\r
+  TimerInfo.StartCount = 0;\r
+  TimerInfo.EndCount   = 0xFFFF;\r
+  TimerInfo.CountUp = TRUE;\r
 \r
   //\r
   // Print header\r
@@ -385,6 +968,12 @@ Done:
   }\r
   SHELL_FREE_NON_NULL (CustomCumulativeData);\r
 \r
+  SHELL_FREE_NON_NULL (mMeasurementList);\r
+\r
+  SHELL_FREE_NON_NULL (mCacheHandleGuidTable);\r
+\r
+  mMeasurementNum = 0;\r
+  mCachePairCount = 0;\r
   return ShellStatus;\r
 }\r
 \r
index 4027b6b84eae73b1087a1e9281a5504535135fea..9fd88578720b89c3c358fd1841206d38e5b9bfd2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file for 'dp' command functions.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -19,6 +19,9 @@
 #include <Uefi.h>\r
 \r
 #include <Guid/Performance.h>\r
+#include <Guid/ExtendedFirmwarePerformance.h>\r
+#include <Guid/FirmwarePerformance.h>\r
+#include <Guid/Acpi.h>\r
 \r
 #include <Protocol/HiiPackageList.h>\r
 #include <Protocol/DevicePath.h>\r
@@ -42,7 +45,7 @@
 extern EFI_HANDLE mDpHiiHandle;\r
 \r
 #define DP_MAJOR_VERSION        2\r
-#define DP_MINOR_VERSION        4\r
+#define DP_MINOR_VERSION        5\r
 \r
 /**\r
   * The value assigned to DP_DEBUG controls which debug output\r
index b77c50771b64b2560d9baade371606874786d115..b6069ae649b362575fb58fe40c6b129f23f8b3d8 100644 (file)
@@ -1,7 +1,7 @@
 // *++\r
 //\r
 // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 // (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
 #string STR_DP_HANDLE_SECTION2         #language en-US  "Index: Handle               Driver Name             Description  Time(us)    ID\n"\r
 #string STR_DP_HANDLE_VARS2            #language en-US  "%5d: [%3x]  %36s  %11s  %L8d %5d\n"\r
 #string STR_DP_SECTION_PEIMS           #language en-US  "PEIMs"\r
-#string STR_DP_PEIM_SECTION            #language en-US  "Index:  Pointer Value              Instance GUID              Token    Time(us)\n"\r
-#string STR_DP_PEIM_VARS               #language en-US  "%5d:  0x%11p   %g   PEIM    %L8d\n"\r
-#string STR_DP_PEIM_SECTION2           #language en-US  "Index: Pointer Value             Instance GUID            Token  Time(us)    ID\n"\r
-#string STR_DP_PEIM_VARS2              #language en-US  "%5d: 0x%11p  %g PEIM  %L8d %5d\n"\r
+#string STR_DP_PEIM_SECTION            #language en-US  "Index:                Instance GUID              Token    Time(us)\n"\r
+#string STR_DP_PEIM_VARS               #language en-US  "%5d:    %g   PEIM    %L8d\n"\r
+#string STR_DP_PEIM_SECTION2           #language en-US  "Index:               Instance GUID            Token  Time(us)    ID\n"\r
+#string STR_DP_PEIM_VARS2              #language en-US  "%5d:   %g PEIM  %L8d %5d\n"\r
 #string STR_DP_SECTION_GENERAL         #language en-US  "General"\r
 #string STR_DP_GLOBAL_SECTION          #language en-US  "Index                      Name                         Description    Time(us)\n"\r
 #string STR_DP_GLOBAL_VARS             #language en-US  "%5d:%25s     %31s    %L8d\n"\r
@@ -90,6 +90,7 @@
 #string STR_DP_INCOMPLETE              #language en-US  " I "\r
 #string STR_DP_COMPLETE                #language en-US  "   "\r
 #string STR_ALIT_UNKNOWN               #language en-US  "Unknown"\r
+#string STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL          #language en-US  "Fail to get boot performance table\n"\r
 \r
 #string STR_GET_HELP_DP         #language en-US ""\r
 ".TH dp 0 "Display performance metrics"\r\n"\r
index b0ed229b495cfe73748ede89d18e25bea15573ab..54fe0017541087e0011089822a817e637dc5bb1b 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 # Provides Shell 'dp' standalone application.\r
 #\r
-# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution. The full text of the license may be found at\r
@@ -25,7 +25,6 @@
   UEFI_HII_RESOURCE_SECTION      = TRUE\r
 \r
 [Sources.common]\r
-  PerformanceTokens.h\r
   Dp.uni\r
   Dp.c\r
   Dp.h\r
@@ -61,6 +60,8 @@
 \r
 [Guids]\r
   gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable\r
+  gEfiAcpi20TableGuid                                     ## CONSUMES ## SystemTable\r
+  gEfiAcpi10TableGuid                                     ## CONSUMES ## SystemTable\r
 \r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
index 31645619581dfa5bd0cba4e14409a26a7c05a49b..e906870bd5e103ab76ccb9e35ad4275a36026044 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 # Provides Shell 'dp' dynamic command.\r
 #\r
-# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution. The full text of the license may be found at\r
@@ -26,7 +26,6 @@
   UEFI_HII_RESOURCE_SECTION      = TRUE\r
 \r
 [Sources.common]\r
-  PerformanceTokens.h\r
   Dp.uni\r
   Dp.c\r
   Dp.h\r
@@ -62,6 +61,8 @@
 \r
 [Guids]\r
   gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable\r
+  gEfiAcpi20TableGuid                                     ## CONSUMES\r
+  gEfiAcpi10TableGuid                                     ## CONSUMES\r
 \r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
index ece1c23aaf36dc3e4e35c2a881c0e94c2c9dc769..eedc377cded0ec53e27534d9b4d1daeae6c40997 100644 (file)
@@ -6,7 +6,7 @@
   Dp application.  In addition to global data, function declarations for\r
   DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -29,12 +29,13 @@ extern CHAR16             mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
 extern CHAR16             mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
 extern UINT64             mInterestThreshold;\r
 extern BOOLEAN            mShowId;\r
+extern UINT8              *mBootPerformanceTable;\r
+extern UINTN              mBootPerformanceTableLength;\r
+extern MEASUREMENT_RECORD *mMeasurementList;\r
+extern UINTN              mMeasurementNum;\r
 \r
 extern PERF_SUMMARY_DATA  SummaryData;    ///< Create the SummaryData structure and init. to ZERO.\r
 \r
-/// Timer Specific Information.\r
-extern TIMER_INFO         TimerInfo;\r
-\r
 /// Items for which to gather cumulative statistics.\r
 extern PERF_CUM_DATA      CumData[];\r
 \r
index bc882be622abc2a0e4bccea6a101982fee79d1ba..7f7d296946fe7ca01fd26846671ae182d15011c1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Trace reporting for the Dp utility.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 #include <Library/HiiLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
-#include <Guid/Performance.h>\r
-\r
 #include "Dp.h"\r
 #include "Literals.h"\r
 #include "DpInternal.h"\r
 \r
+/**\r
+  Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
+\r
+\r
+  @param  LogEntryKey             On entry, the key of the performance measurement log entry to retrieve.\r
+                                  0, then the first performance measurement log entry is retrieved.\r
+                                  On exit, the key of the next performance log entry.\r
+  @param  Handle                  Pointer to environment specific context used to identify the component\r
+                                  being measured.\r
+  @param  Token                   Pointer to a Null-terminated ASCII string that identifies the component\r
+                                  being measured.\r
+  @param  Module                  Pointer to a Null-terminated ASCII string that identifies the module\r
+                                  being measured.\r
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was started.\r
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was ended.\r
+  @param  Identifier              Pointer to the 32-bit identifier that was recorded when the measurement\r
+                                  was ended.\r
+\r
+  @return The key for the next performance log entry (in general case).\r
+\r
+**/\r
+UINTN\r
+GetPerformanceMeasurementRecord (\r
+ IN  UINTN       LogEntryKey,\r
+ OUT CONST VOID  **Handle,\r
+ OUT CONST CHAR8 **Token,\r
+ OUT CONST CHAR8 **Module,\r
+ OUT UINT64      *StartTimeStamp,\r
+ OUT UINT64      *EndTimeStamp,\r
+ OUT UINT32      *Identifier\r
+  )\r
+{\r
+  if (LogEntryKey == mMeasurementNum) {\r
+    return 0;\r
+  }\r
+\r
+  *Handle         = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle;\r
+  *Token          = mMeasurementList[LogEntryKey].Token;\r
+  *Module         = mMeasurementList[LogEntryKey].Module;\r
+  *StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;\r
+  *EndTimeStamp   = mMeasurementList[LogEntryKey].EndTimeStamp;\r
+  *Identifier     = mMeasurementList[LogEntryKey].Identifier;\r
+\r
+  LogEntryKey ++;\r
+\r
+  return LogEntryKey;\r
+}\r
+\r
 /**\r
   Collect verbose statistics about the logged performance measurements.\r
 \r
@@ -57,7 +105,7 @@ GatherStatistics(
   INTN                      TIndex;\r
 \r
   LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                         LogEntryKey,\r
                         &Measurement.Handle,\r
                         &Measurement.Token,\r
@@ -79,13 +127,13 @@ GatherStatistics(
     if (IsPhase( &Measurement)) {\r
       ++SummaryData.NumSummary;       // Count the number of major phases\r
     }\r
-    else {  // !IsPhase(...\r
+    else {  // !IsPhase\r
       if(Measurement.Handle == NULL) {\r
         ++SummaryData.NumGlobal;\r
       }\r
     }\r
 \r
-    if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {\r
+    if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {\r
       ++SummaryData.NumPEIMs;         // Count PEIM measurements\r
     }\r
 \r
@@ -190,7 +238,7 @@ DumpAllTrace(
     Count = 0;\r
     Index = 0;\r
     while ( WITHIN_LIMIT(Count, Limit) &&\r
-            ((LogEntryKey = GetPerformanceMeasurementEx (\r
+            ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                             LogEntryKey,\r
                             &Measurement.Handle,\r
                             &Measurement.Token,\r
@@ -231,7 +279,7 @@ DumpAllTrace(
         }\r
       }\r
 \r
-      if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {\r
+      if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {\r
         UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", Measurement.Handle);\r
       }\r
 \r
@@ -331,7 +379,7 @@ DumpRawTrace(
   Count = 0;\r
   Index = 0;\r
   while ( WITHIN_LIMIT(Count, Limit) &&\r
-          ((LogEntryKey = GetPerformanceMeasurementEx (\r
+          ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
@@ -420,7 +468,7 @@ ProcessPhases(
   FreePool (StringPtrUnknown);\r
 \r
   LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
@@ -434,17 +482,17 @@ ProcessPhases(
     }\r
     Duration = GetDuration (&Measurement);\r
     if (   Measurement.Handle != NULL\r
-        && (AsciiStrnCmp (Measurement.Token, ALit_BdsTO, PERF_TOKEN_LENGTH) == 0)\r
+        && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)\r
        )\r
     {\r
       BdsTimeoutValue = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0) {\r
+    } else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {\r
       SecTime     = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0) {\r
+    } else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {\r
       PeiTime     = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0) {\r
+    } else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {\r
       DxeTime      = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0) {\r
+    } else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {\r
       BdsTime      = Duration;\r
     }\r
   }\r
@@ -462,10 +510,7 @@ ProcessPhases(
   // print PEI phase duration time\r
   //\r
   if (PeiTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    PeiTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
+    ElapsedTime = DivU64x32 (PeiTime, 1000000);\r
     Total += ElapsedTime;\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);\r
   }\r
@@ -473,10 +518,7 @@ ProcessPhases(
   // print DXE phase duration time\r
   //\r
   if (DxeTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    DxeTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
+    ElapsedTime = DivU64x32 (DxeTime, 1000000);\r
     Total += ElapsedTime;\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);\r
   }\r
@@ -484,19 +526,13 @@ ProcessPhases(
   // print BDS phase duration time\r
   //\r
   if (BdsTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    BdsTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
+    ElapsedTime = DivU64x32 (BdsTime, 1000000);\r
     Total += ElapsedTime;\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);\r
   }\r
 \r
   if (BdsTimeoutValue > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    BdsTimeoutValue,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
+    ElapsedTime = DivU64x32 (BdsTimeoutValue, 1000000);\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpHiiHandle, ALit_BdsTO, ElapsedTime);\r
   }\r
 \r
@@ -554,7 +590,7 @@ ProcessHandles(
 \r
     LogEntryKey = 0;\r
     Count   = 0;\r
-    while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+    while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                             LogEntryKey,\r
                             &Measurement.Handle,\r
                             &Measurement.Token,\r
@@ -657,7 +693,7 @@ ProcessPeims(
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
   TIndex  = 0;\r
   LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
@@ -668,7 +704,7 @@ ProcessPeims(
   {\r
     TIndex++;\r
     if ((Measurement.EndTimeStamp == 0) ||\r
-        (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) != 0)\r
+        (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)\r
        ) {\r
       continue;\r
     }\r
@@ -680,7 +716,6 @@ ProcessPeims(
       if (mShowId) {\r
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,\r
               TIndex,   // 1 based, Which measurement record is being printed\r
-              Measurement.Handle,  // base address\r
               Measurement.Handle,  // file guid\r
               ElapsedTime,\r
               Measurement.Identifier\r
@@ -688,7 +723,6 @@ ProcessPeims(
       } else {\r
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,\r
               TIndex,   // 1 based, Which measurement record is being printed\r
-              Measurement.Handle,  // base address\r
               Measurement.Handle,  // file guid\r
               ElapsedTime\r
         );\r
@@ -746,7 +780,7 @@ ProcessGlobal(
   Index = 1;\r
   LogEntryKey = 0;\r
 \r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+  while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
index b98ec4b5bd8764b61dc202acfbc5b6caf59e5ec4..39f71a044c34bf3f59592cf9a31f429299311c32 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Utility functions used by the Dp application.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -71,22 +71,8 @@ GetDuration (
     return 0;\r
   }\r
 \r
-  // PERF_START macros are called with a value of 1 to indicate\r
-  // the beginning of time.  So, adjust the start ticker value\r
-  // to the real beginning of time.\r
-  // Assumes no wraparound.  Even then, there is a very low probability\r
-  // of having a valid StartTicker value of 1.\r
-  if (Measurement->StartTimeStamp == 1) {\r
-    Measurement->StartTimeStamp = TimerInfo.StartCount;\r
-  }\r
-  if (TimerInfo.CountUp) {\r
-    Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;\r
-    Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);\r
-  }\r
-  else {\r
-    Duration = Measurement->StartTimeStamp - Measurement->EndTimeStamp;\r
-    Error = (BOOLEAN)(Duration > Measurement->StartTimeStamp);\r
-  }\r
+  Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;\r
+  Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);\r
 \r
   if (Error) {\r
     DEBUG ((EFI_D_ERROR, ALit_TimerLibError));\r
@@ -113,11 +99,11 @@ IsPhase(
 {\r
   BOOLEAN   RetVal;\r
 \r
-  RetVal = (BOOLEAN)( ( *Measurement->Module == '\0')                               &&\r
-            ((AsciiStrnCmp (Measurement->Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0)    ||\r
-             (AsciiStrnCmp (Measurement->Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0)    ||\r
-             (AsciiStrnCmp (Measurement->Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0)    ||\r
-             (AsciiStrnCmp (Measurement->Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0))\r
+  RetVal = (BOOLEAN)(\r
+            ((AsciiStrCmp (Measurement->Token, ALit_SEC) == 0)    ||\r
+             (AsciiStrCmp (Measurement->Token, ALit_PEI) == 0)    ||\r
+             (AsciiStrCmp (Measurement->Token, ALit_DXE) == 0)    ||\r
+             (AsciiStrCmp (Measurement->Token, ALit_BDS) == 0))\r
             );\r
   return RetVal;\r
 }\r
@@ -378,10 +364,7 @@ DurationInMicroSeconds (
   IN UINT64 Duration\r
   )\r
 {\r
-  UINT64 Temp;\r
-\r
-  Temp = MultU64x32 (Duration, 1000);\r
-  return DivU64x32 (Temp, TimerInfo.Frequency);\r
+  return DivU64x32 (Duration, 1000);\r
 }\r
 \r
 /** \r
@@ -405,7 +388,7 @@ GetCumulativeItem(
   INTN    Index;\r
 \r
   for( Index = 0; Index < (INTN)NumCum; ++Index) {\r
-    if (AsciiStrnCmp (Measurement->Token, CumData[Index].Name, PERF_TOKEN_LENGTH) == 0) {\r
+    if (AsciiStrCmp (Measurement->Token, CumData[Index].Name) == 0) {\r
       return Index;  // Exit, we found a match\r
     }\r
   }\r
index c1cddfb9ffb25f7cdbe6f68e24ffc6b6512fe1a9..69dfc57f6a642481d8ce1b22996ae89dd24de1d8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definitions of ASCII string literals used by DP.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
-#include <PerformanceTokens.h>\r
+#include <Guid/ExtendedFirmwarePerformance.h>\r
 \r
 // ASCII String literals which probably don't need translation\r
-CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";\r
-CHAR8 const ALit_SEC[]    = SEC_TOK;\r
-CHAR8 const ALit_DXE[]    = DXE_TOK;\r
-CHAR8 const ALit_PEI[]    = PEI_TOK;\r
-CHAR8 const ALit_BDS[]    = BDS_TOK;\r
-CHAR8 const ALit_BdsTO[]  = "BdsTimeOut";\r
-CHAR8 const ALit_PEIM[]   = "PEIM";\r
+CHAR8 const ALit_TimerLibError[]  = "Timer library instance error!\n";\r
+CHAR8 const ALit_SEC[]            = SEC_TOK;\r
+CHAR8 const ALit_DXE[]            = DXE_TOK;\r
+CHAR8 const ALit_PEI[]            = PEI_TOK;\r
+CHAR8 const ALit_BDS[]            = BDS_TOK;\r
+CHAR8 const ALit_START_IMAGE[]    = START_IMAGE_TOK;\r
+CHAR8 const ALit_LOAD_IMAGE[]     = LOAD_IMAGE_TOK;\r
+CHAR8 const ALit_DB_START[]       = DRIVERBINDING_START_TOK;\r
+CHAR8 const ALit_DB_SUPPORT[]     = DRIVERBINDING_SUPPORT_TOK;\r
+CHAR8 const ALit_DB_STOP[]        = DRIVERBINDING_STOP_TOK;\r
+\r
+CHAR8 const ALit_BdsTO[]      = "BdsTimeOut";\r
+CHAR8 const ALit_PEIM[]       = "PEIM";\r
index 8aec09c0246bec4477b9c2e1c5e4d39d753a6391..8695b1e65304561119e3e8d5fa57c694c0376238 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Declarations of ASCII string literals used by DP.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,6 +20,12 @@ extern CHAR8 const ALit_DXE[];
 extern CHAR8 const ALit_SHELL[];\r
 extern CHAR8 const ALit_PEI[];\r
 extern CHAR8 const ALit_BDS[];\r
+extern CHAR8 const ALit_PEIM[];\r
+extern CHAR8 const ALit_START_IMAGE[];\r
+extern CHAR8 const ALit_LOAD_IMAGE[];\r
+extern CHAR8 const ALit_DB_START[];\r
+extern CHAR8 const ALit_DB_SUPPORT[];\r
+extern CHAR8 const ALit_DB_STOP[];\r
 extern CHAR8 const ALit_BdsTO[];\r
 extern CHAR8 const ALit_PEIM[];\r
 \r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h b/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h
deleted file mode 100644 (file)
index bbbc48d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file\r
-  ASCII String Literals with special meaning to Performance measurement and the Dp utility.\r
-\r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __PERFORMANCE_TOKENS_H__\r
-#define __PERFORMANCE_TOKENS_H__\r
-\r
-#define SEC_TOK                         "SEC"             ///< SEC Phase\r
-#define DXE_TOK                         "DXE"             ///< DEC Phase\r
-#define SHELL_TOK                       "SHELL"           ///< Shell Phase\r
-#define PEI_TOK                         "PEI"             ///< PEI Phase\r
-#define BDS_TOK                         "BDS"             ///< BDS Phase\r
-#define DRIVERBINDING_START_TOK         "DB:Start:"       ///< Driver Binding Start() function call\r
-#define DRIVERBINDING_SUPPORT_TOK       "DB:Support:"     ///< Driver Binding Support() function call\r
-#define LOAD_IMAGE_TOK                  "LoadImage:"      ///< Load a dispatched module\r
-#define START_IMAGE_TOK                 "StartImage:"     ///< Dispatched Modules Entry Point execution\r
-\r
-#endif  // __PERFORMANCE_TOKENS_H__\r