X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=PerformancePkg%2FDp_App%2FDp.c;h=4cdc39edb42e75ccf0221839550df5fa9fab0f2b;hp=b24a0de72d74c952b285f3f9150273535de87301;hb=9555c09717ee0b1ed4619942257c7b64aeb57f6e;hpb=38ac6bf1a60f107a597390ad9f52cdb4f51194ee
diff --git a/PerformancePkg/Dp_App/Dp.c b/PerformancePkg/Dp_App/Dp.c
index b24a0de72d..4cdc39edb4 100644
--- a/PerformancePkg/Dp_App/Dp.c
+++ b/PerformancePkg/Dp_App/Dp.c
@@ -13,7 +13,7 @@
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 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -25,12 +25,13 @@
**/
#include
+#include
#include
#include
#include
#include
-#include
#include
+#include
#include
#include
@@ -41,6 +42,16 @@
#include "Literals.h"
#include "DpInternal.h"
+//
+// String token ID of help message text.
+// Shell supports to find help message in the resource section of an application image if
+// .MAN file is not found. This global variable is added to make build tool recognizes
+// that the help string is consumed by user and then build tool will add the string into
+// the resource section. Thus the application can use '-?' option to show help message in
+// Shell.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mDpStrEngHelpTokenId = STRING_TOKEN (STR_DP_HELP_INFORMATION);
+
//
/// Module-Global Variables
///@{
@@ -102,7 +113,7 @@ InitialShellParamList( void )
//
// Allocate one more for the end tag.
//
- ListLength = sizeof (ParamList) / sizeof (ParamList[0]) + 1;
+ ListLength = ARRAY_SIZE (ParamList) + 1;
DpParamList = AllocatePool (sizeof (SHELL_PARAM_ITEM) * ListLength);
ASSERT (DpParamList != NULL);
@@ -171,25 +182,6 @@ DumpStatistics( void )
FreePool (StringPtrUnknown);
}
-/**
- Initialize the cumulative data.
-
-**/
-VOID
-InitCumulativeData (
- VOID
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < NumCum; ++Index) {
- CumData[Index].Count = 0;
- CumData[Index].MinDur = PERF_MAXDUR;
- CumData[Index].MaxDur = 0;
- CumData[Index].Duration = 0;
- }
-}
-
/**
Dump performance data.
@@ -208,26 +200,27 @@ InitializeDp (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- UINT64 Freq;
- UINT64 Ticker;
- UINT32 ListIndex;
-
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *CmdLineArg;
- EFI_STRING StringPtr;
- UINTN Number2Display;
-
- EFI_STATUS Status;
- BOOLEAN SummaryMode;
- BOOLEAN VerboseMode;
- BOOLEAN AllMode;
- BOOLEAN RawMode;
- BOOLEAN TraceMode;
- BOOLEAN ProfileMode;
- BOOLEAN ExcludeMode;
- BOOLEAN CumulativeMode;
- CONST CHAR16 *CustomCumulativeToken;
- PERF_CUM_DATA *CustomCumulativeData;
+ PERFORMANCE_PROPERTY *PerformanceProperty;
+ UINT32 ListIndex;
+
+ LIST_ENTRY *ParamPackage;
+ CONST CHAR16 *CmdLineArg;
+ EFI_STRING StringPtr;
+ UINTN Number2Display;
+
+ EFI_STATUS Status;
+ BOOLEAN SummaryMode;
+ BOOLEAN VerboseMode;
+ BOOLEAN AllMode;
+ BOOLEAN RawMode;
+ BOOLEAN TraceMode;
+ BOOLEAN ProfileMode;
+ BOOLEAN ExcludeMode;
+ BOOLEAN CumulativeMode;
+ CONST CHAR16 *CustomCumulativeToken;
+ PERF_CUM_DATA *CustomCumulativeData;
+ UINTN NameSize;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_STRING StringDpOptionQh;
EFI_STRING StringDpOptionLh;
@@ -272,15 +265,35 @@ InitializeDp (
StringDpOptionLc = NULL;
StringPtr = NULL;
- // Get DP's entry time as soon as possible.
- // This is used as the Shell-Phase end time.
//
- Ticker = GetPerformanceCounter ();
+ // Retrieve HII package list from ImageHandle
+ //
+ Status = gBS->OpenProtocol (
+ ImageHandle,
+ &gEfiHiiPackageListProtocolGuid,
+ (VOID **) &PackageList,
+ ImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
- // Register our string package with HII and return the handle to it.
//
- gHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, DPStrings, NULL);
+ // Publish HII package list to HII Database.
+ //
+ Status = gHiiDatabase->NewPackageList (
+ gHiiDatabase,
+ PackageList,
+ NULL,
+ &gHiiHandle
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
ASSERT (gHiiHandle != NULL);
+
// Initial the command list
//
@@ -373,8 +386,9 @@ InitializeDp (
CustomCumulativeData->MaxDur = 0;
CustomCumulativeData->Count = 0;
CustomCumulativeData->Duration = 0;
- CustomCumulativeData->Name = AllocateZeroPool (StrLen (CustomCumulativeToken) + 1);
- UnicodeStrToAsciiStr (CustomCumulativeToken, CustomCumulativeData->Name);
+ NameSize = StrLen (CustomCumulativeToken) + 1;
+ CustomCumulativeData->Name = AllocateZeroPool (NameSize);
+ UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
}
/****************************************************************************
@@ -385,10 +399,16 @@ InitializeDp (
// StartCount = Value loaded into the counter when it starts counting
// EndCount = Value counter counts to before it needs to be reset
//
- Freq = GetPerformanceCounterProperties (&TimerInfo.StartCount, &TimerInfo.EndCount);
+ Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
+ if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
+ PrintToken (STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND));
+ goto Done;
+ }
// Convert the Frequency from Hz to KHz
- TimerInfo.Frequency = (UINT32)DivU64x32 (Freq, 1000);
+ 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);
@@ -466,7 +486,7 @@ InitializeDp (
else {
//------------- Begin Cooked Mode Processing
if (TraceMode) {
- ProcessPhases ( Ticker );
+ ProcessPhases ();
if ( ! SummaryMode) {
Status = ProcessHandles ( ExcludeMode);
if (Status == EFI_ABORTED) {