2010-04-23 19:00:32 +02:00
|
|
|
/** @file
|
2011-12-01 05:31:46 +01:00
|
|
|
Shell application for Displaying Performance Metrics.
|
|
|
|
|
|
|
|
The Dp application reads performance data and presents it in several
|
|
|
|
different formats depending upon the needs of the user. Both
|
|
|
|
Trace and Measured Profiling information is processed and presented.
|
|
|
|
|
|
|
|
Dp uses the "PerformanceLib" to read the measurement records.
|
|
|
|
The "TimerLib" provides information about the timer, such as frequency,
|
|
|
|
beginning, and ending counter values.
|
|
|
|
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.
|
|
|
|
|
2016-04-12 09:06:07 +02:00
|
|
|
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
2016-03-07 04:23:07 +01:00
|
|
|
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
|
2011-12-01 05:31:46 +01:00
|
|
|
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.
|
2010-04-23 19:00:32 +02:00
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Library/UefiApplicationEntryPoint.h>
|
2016-04-12 09:06:07 +02:00
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
2010-04-23 19:00:32 +02:00
|
|
|
#include <Library/ShellLib.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/TimerLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
2016-04-12 09:06:07 +02:00
|
|
|
#include <Library/UefiHiiServicesLib.h>
|
2010-04-23 19:00:32 +02:00
|
|
|
#include <Library/HiiLib.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
|
|
|
|
#include <Guid/Performance.h>
|
|
|
|
|
|
|
|
#include <PerformanceTokens.h>
|
|
|
|
#include "Dp.h"
|
|
|
|
#include "Literals.h"
|
|
|
|
#include "DpInternal.h"
|
|
|
|
|
2016-04-12 09:06:07 +02:00
|
|
|
//
|
|
|
|
// 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);
|
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
//
|
|
|
|
/// Module-Global Variables
|
2010-11-08 06:28:01 +01:00
|
|
|
///@{
|
2010-04-23 19:00:32 +02:00
|
|
|
EFI_HII_HANDLE gHiiHandle;
|
2010-11-09 04:22:42 +01:00
|
|
|
SHELL_PARAM_ITEM *DpParamList = NULL;
|
2010-04-23 19:00:32 +02:00
|
|
|
CHAR16 *mPrintTokenBuffer = NULL;
|
2011-11-25 03:24:07 +01:00
|
|
|
CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
|
|
|
|
CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
|
2010-04-23 19:00:32 +02:00
|
|
|
UINT64 mInterestThreshold;
|
2012-04-24 11:15:10 +02:00
|
|
|
BOOLEAN mShowId = FALSE;
|
2010-04-23 19:00:32 +02:00
|
|
|
|
|
|
|
PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the SummaryData structure and init. to ZERO.
|
|
|
|
|
|
|
|
/// Timer Specific Information.
|
|
|
|
TIMER_INFO TimerInfo;
|
|
|
|
|
|
|
|
/// 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),
|
|
|
|
PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),
|
|
|
|
PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK)
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Number of items for which we are gathering cumulative statistics.
|
|
|
|
UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
|
|
|
|
|
2010-11-09 04:22:42 +01:00
|
|
|
PARAM_ITEM_LIST ParamList[] = {
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_QH), TypeFlag}, // -? Help
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LH), TypeFlag}, // -h Help
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_UH), TypeFlag}, // -H Help
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LV), TypeFlag}, // -v Verbose Mode
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_UA), TypeFlag}, // -A All, Cooked
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_UR), TypeFlag}, // -R RAW All
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LS), TypeFlag}, // -s Summary
|
2010-04-23 19:00:32 +02:00
|
|
|
#if PROFILING_IMPLEMENTED
|
2010-11-09 04:22:42 +01:00
|
|
|
{STRING_TOKEN (STR_DP_OPTION_UP), TypeFlag}, // -P Dump Profile Data
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_UT), TypeFlag}, // -T Dump Trace Data
|
2010-04-23 19:00:32 +02:00
|
|
|
#endif
|
2010-11-09 04:22:42 +01:00
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LX), TypeFlag}, // -x eXclude Cumulative Items
|
2012-04-24 11:15:10 +02:00
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LI), TypeFlag}, // -i Display Identifier
|
2015-11-10 05:57:14 +01:00
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LC), TypeValue}, // -c Display cumulative data.
|
2010-11-09 04:22:42 +01:00
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LN), TypeValue}, // -n # Number of records to display for A and R
|
|
|
|
{STRING_TOKEN (STR_DP_OPTION_LT), TypeValue} // -t # Threshold of interest
|
2010-04-23 19:00:32 +02:00
|
|
|
};
|
|
|
|
|
2010-11-08 06:28:01 +01:00
|
|
|
///@}
|
2010-04-23 19:00:32 +02:00
|
|
|
|
2010-11-09 04:22:42 +01:00
|
|
|
/**
|
|
|
|
Transfer the param list value and get the command line parse.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
InitialShellParamList( void )
|
|
|
|
{
|
|
|
|
UINT32 ListIndex;
|
|
|
|
UINT32 ListLength;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate one more for the end tag.
|
|
|
|
//
|
|
|
|
ListLength = sizeof (ParamList) / sizeof (ParamList[0]) + 1;
|
|
|
|
DpParamList = AllocatePool (sizeof (SHELL_PARAM_ITEM) * ListLength);
|
|
|
|
ASSERT (DpParamList != NULL);
|
|
|
|
|
|
|
|
for (ListIndex = 0; ListIndex < ListLength - 1; ListIndex ++)
|
|
|
|
{
|
|
|
|
DpParamList[ListIndex].Name = HiiGetString (gHiiHandle, ParamList[ListIndex].Token, NULL);
|
|
|
|
DpParamList[ListIndex].Type = ParamList[ListIndex].Type;
|
|
|
|
}
|
|
|
|
DpParamList[ListIndex].Name = NULL;
|
|
|
|
DpParamList[ListIndex].Type = TypeMax;
|
|
|
|
}
|
|
|
|
|
2010-11-08 06:28:01 +01:00
|
|
|
/**
|
|
|
|
Display Usage and Help information.
|
|
|
|
**/
|
2010-04-23 19:00:32 +02:00
|
|
|
VOID
|
|
|
|
ShowHelp( void )
|
|
|
|
{
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_HEAD));
|
|
|
|
#if PROFILING_IMPLEMENTED
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_FLAGS));
|
|
|
|
#else
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_FLAGS_2));
|
|
|
|
#endif // PROFILING_IMPLEMENTED
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_PAGINATE));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_VERBOSE));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_EXCLUDE));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_STAT));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_ALL));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_RAW));
|
|
|
|
#if PROFILING_IMPLEMENTED
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_TRACE));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_PROFILE));
|
|
|
|
#endif // PROFILING_IMPLEMENTED
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_THRESHOLD));
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_COUNT));
|
2012-04-24 11:15:10 +02:00
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_ID));
|
2015-11-10 05:57:14 +01:00
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_CUM_DATA));
|
2010-04-23 19:00:32 +02:00
|
|
|
PrintToken (STRING_TOKEN (STR_DP_HELP_HELP));
|
|
|
|
Print(L"\n");
|
|
|
|
}
|
|
|
|
|
2010-11-08 06:28:01 +01:00
|
|
|
/**
|
|
|
|
Display the trailing Verbose information.
|
|
|
|
**/
|
2010-04-23 19:00:32 +02:00
|
|
|
VOID
|
|
|
|
DumpStatistics( void )
|
|
|
|
{
|
|
|
|
EFI_STRING StringPtr;
|
2010-11-09 04:22:42 +01:00
|
|
|
EFI_STRING StringPtrUnknown;
|
|
|
|
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
|
|
|
|
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
2010-04-23 19:00:32 +02:00
|
|
|
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
|
2010-11-09 04:22:42 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
2010-04-23 19:00:32 +02:00
|
|
|
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMTRACE), SummaryData.NumTrace);
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), SummaryData.NumIncomplete);
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMPHASES), SummaryData.NumSummary);
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMHANDLES), SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMPEIMS), SummaryData.NumPEIMs);
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), SummaryData.NumGlobal);
|
|
|
|
#if PROFILING_IMPLEMENTED
|
|
|
|
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMPROFILE), SummaryData.NumProfile);
|
|
|
|
#endif // PROFILING_IMPLEMENTED
|
2010-11-09 04:22:42 +01:00
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
2010-04-23 19:00:32 +02:00
|
|
|
}
|
|
|
|
|
2015-11-10 05:57:14 +01:00
|
|
|
/**
|
2010-11-08 06:28:01 +01:00
|
|
|
Dump performance data.
|
|
|
|
|
|
|
|
@param[in] ImageHandle The image handle.
|
|
|
|
@param[in] SystemTable The system table.
|
2016-03-07 04:23:07 +01:00
|
|
|
|
2010-11-08 06:28:01 +01:00
|
|
|
@retval EFI_SUCCESS Command completed successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Command usage error.
|
2016-03-07 04:23:07 +01:00
|
|
|
@retval EFI_ABORTED The user aborts the operation.
|
2010-11-08 06:28:01 +01:00
|
|
|
@retval value Unknown error.
|
2010-04-23 19:00:32 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializeDp (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT64 Freq;
|
|
|
|
UINT64 Ticker;
|
2010-11-09 04:22:42 +01:00
|
|
|
UINT32 ListIndex;
|
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
LIST_ENTRY *ParamPackage;
|
|
|
|
CONST CHAR16 *CmdLineArg;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
UINTN Number2Display;
|
|
|
|
|
2016-04-12 09:06:07 +02:00
|
|
|
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;
|
2016-06-15 07:38:35 +02:00
|
|
|
UINTN NameSize;
|
2016-04-12 09:06:07 +02:00
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
|
2010-11-08 06:28:01 +01:00
|
|
|
|
2010-11-09 04:22:42 +01:00
|
|
|
EFI_STRING StringDpOptionQh;
|
|
|
|
EFI_STRING StringDpOptionLh;
|
|
|
|
EFI_STRING StringDpOptionUh;
|
|
|
|
EFI_STRING StringDpOptionLv;
|
|
|
|
EFI_STRING StringDpOptionUs;
|
|
|
|
EFI_STRING StringDpOptionLs;
|
|
|
|
EFI_STRING StringDpOptionUa;
|
|
|
|
EFI_STRING StringDpOptionUr;
|
|
|
|
EFI_STRING StringDpOptionUt;
|
|
|
|
EFI_STRING StringDpOptionUp;
|
|
|
|
EFI_STRING StringDpOptionLx;
|
|
|
|
EFI_STRING StringDpOptionLn;
|
|
|
|
EFI_STRING StringDpOptionLt;
|
2012-04-24 11:15:10 +02:00
|
|
|
EFI_STRING StringDpOptionLi;
|
2015-11-10 05:57:14 +01:00
|
|
|
EFI_STRING StringDpOptionLc;
|
2010-11-09 04:22:42 +01:00
|
|
|
|
2010-11-08 06:28:01 +01:00
|
|
|
SummaryMode = FALSE;
|
|
|
|
VerboseMode = FALSE;
|
|
|
|
AllMode = FALSE;
|
|
|
|
RawMode = FALSE;
|
|
|
|
TraceMode = FALSE;
|
|
|
|
ProfileMode = FALSE;
|
|
|
|
ExcludeMode = FALSE;
|
2015-11-10 05:57:14 +01:00
|
|
|
CumulativeMode = FALSE;
|
|
|
|
CustomCumulativeData = NULL;
|
2010-11-09 04:22:42 +01:00
|
|
|
|
|
|
|
StringDpOptionQh = NULL;
|
|
|
|
StringDpOptionLh = NULL;
|
|
|
|
StringDpOptionUh = NULL;
|
|
|
|
StringDpOptionLv = NULL;
|
|
|
|
StringDpOptionUs = NULL;
|
|
|
|
StringDpOptionLs = NULL;
|
|
|
|
StringDpOptionUa = NULL;
|
|
|
|
StringDpOptionUr = NULL;
|
|
|
|
StringDpOptionUt = NULL;
|
|
|
|
StringDpOptionUp = NULL;
|
|
|
|
StringDpOptionLx = NULL;
|
|
|
|
StringDpOptionLn = NULL;
|
|
|
|
StringDpOptionLt = NULL;
|
2012-04-24 11:15:10 +02:00
|
|
|
StringDpOptionLi = NULL;
|
2015-11-10 05:57:14 +01:00
|
|
|
StringDpOptionLc = NULL;
|
2010-11-09 04:22:42 +01:00
|
|
|
StringPtr = NULL;
|
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
// Get DP's entry time as soon as possible.
|
|
|
|
// This is used as the Shell-Phase end time.
|
|
|
|
//
|
|
|
|
Ticker = GetPerformanceCounter ();
|
|
|
|
|
|
|
|
//
|
2016-04-12 09:06:07 +02:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Publish HII package list to HII Database.
|
|
|
|
//
|
|
|
|
Status = gHiiDatabase->NewPackageList (
|
|
|
|
gHiiDatabase,
|
|
|
|
PackageList,
|
|
|
|
NULL,
|
|
|
|
&gHiiHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2010-04-23 19:00:32 +02:00
|
|
|
ASSERT (gHiiHandle != NULL);
|
2016-04-12 09:06:07 +02:00
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
|
2010-11-09 04:22:42 +01:00
|
|
|
// Initial the command list
|
|
|
|
//
|
|
|
|
InitialShellParamList ();
|
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**** Process Command Line arguments ****
|
|
|
|
****************************************************************************/
|
|
|
|
Status = ShellCommandLineParse (DpParamList, &ParamPackage, NULL, TRUE);
|
|
|
|
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_INVALID_ARG));
|
|
|
|
ShowHelp();
|
|
|
|
}
|
|
|
|
else {
|
2010-11-09 04:22:42 +01:00
|
|
|
StringDpOptionQh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_QH), NULL);
|
|
|
|
StringDpOptionLh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LH), NULL);
|
|
|
|
StringDpOptionUh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UH), NULL);
|
|
|
|
|
|
|
|
if (ShellCommandLineGetFlag (ParamPackage, StringDpOptionQh) ||
|
|
|
|
ShellCommandLineGetFlag (ParamPackage, StringDpOptionLh) ||
|
|
|
|
ShellCommandLineGetFlag (ParamPackage, StringDpOptionUh))
|
2010-04-23 19:00:32 +02:00
|
|
|
{
|
|
|
|
ShowHelp();
|
|
|
|
}
|
|
|
|
else {
|
2010-11-09 04:22:42 +01:00
|
|
|
StringDpOptionLv = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LV), NULL);
|
|
|
|
StringDpOptionUs = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_US), NULL);
|
|
|
|
StringDpOptionLs = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LS), NULL);
|
|
|
|
StringDpOptionUa = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UA), NULL);
|
|
|
|
StringDpOptionUr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UR), NULL);
|
|
|
|
StringDpOptionUt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UT), NULL);
|
|
|
|
StringDpOptionUp = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UP), NULL);
|
|
|
|
StringDpOptionLx = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LX), NULL);
|
|
|
|
StringDpOptionLn = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LN), NULL);
|
|
|
|
StringDpOptionLt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LT), NULL);
|
2012-04-24 11:15:10 +02:00
|
|
|
StringDpOptionLi = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LI), NULL);
|
2015-11-10 05:57:14 +01:00
|
|
|
StringDpOptionLc = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LC), NULL);
|
2010-11-09 04:22:42 +01:00
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
// Boolean Options
|
2010-11-09 04:22:42 +01:00
|
|
|
//
|
|
|
|
VerboseMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLv);
|
2010-11-12 08:35:37 +01:00
|
|
|
SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, StringDpOptionUs) ||
|
|
|
|
ShellCommandLineGetFlag (ParamPackage, StringDpOptionLs));
|
2010-11-09 04:22:42 +01:00
|
|
|
AllMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUa);
|
|
|
|
RawMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUr);
|
2010-04-23 19:00:32 +02:00
|
|
|
#if PROFILING_IMPLEMENTED
|
2010-11-09 04:22:42 +01:00
|
|
|
TraceMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUt);
|
|
|
|
ProfileMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUp);
|
2010-04-23 19:00:32 +02:00
|
|
|
#endif // PROFILING_IMPLEMENTED
|
2010-11-09 04:22:42 +01:00
|
|
|
ExcludeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLx);
|
2012-04-24 11:15:10 +02:00
|
|
|
mShowId = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLi);
|
2015-11-10 05:57:14 +01:00
|
|
|
CumulativeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLc);
|
2010-04-23 19:00:32 +02:00
|
|
|
|
|
|
|
// Options with Values
|
2010-11-09 04:22:42 +01:00
|
|
|
CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLn);
|
2010-04-23 19:00:32 +02:00
|
|
|
if (CmdLineArg == NULL) {
|
|
|
|
Number2Display = DEFAULT_DISPLAYCOUNT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Number2Display = StrDecimalToUintn(CmdLineArg);
|
|
|
|
if (Number2Display == 0) {
|
|
|
|
Number2Display = MAXIMUM_DISPLAYCOUNT;
|
|
|
|
}
|
|
|
|
}
|
2010-11-09 04:22:42 +01:00
|
|
|
CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLt);
|
2010-04-23 19:00:32 +02:00
|
|
|
if (CmdLineArg == NULL) {
|
|
|
|
mInterestThreshold = DEFAULT_THRESHOLD; // 1ms := 1,000 us
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mInterestThreshold = StrDecimalToUint64(CmdLineArg);
|
|
|
|
}
|
|
|
|
// Handle Flag combinations and default behaviors
|
|
|
|
// If both TraceMode and ProfileMode are FALSE, set them both to TRUE
|
|
|
|
if ((! TraceMode) && (! ProfileMode)) {
|
|
|
|
TraceMode = TRUE;
|
|
|
|
#if PROFILING_IMPLEMENTED
|
|
|
|
ProfileMode = TRUE;
|
|
|
|
#endif // PROFILING_IMPLEMENTED
|
|
|
|
}
|
|
|
|
|
2015-11-10 05:57:14 +01:00
|
|
|
//
|
|
|
|
// Init the custom cumulative data.
|
|
|
|
//
|
|
|
|
CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, StringDpOptionLc);
|
|
|
|
if (CustomCumulativeToken != NULL) {
|
|
|
|
CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
|
2015-11-26 02:47:14 +01:00
|
|
|
ASSERT (CustomCumulativeData != NULL);
|
2015-11-10 05:57:14 +01:00
|
|
|
CustomCumulativeData->MinDur = 0;
|
|
|
|
CustomCumulativeData->MaxDur = 0;
|
|
|
|
CustomCumulativeData->Count = 0;
|
|
|
|
CustomCumulativeData->Duration = 0;
|
2016-06-15 07:38:35 +02:00
|
|
|
NameSize = StrLen (CustomCumulativeToken) + 1;
|
|
|
|
CustomCumulativeData->Name = AllocateZeroPool (NameSize);
|
|
|
|
UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
|
2015-11-10 05:57:14 +01:00
|
|
|
}
|
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**** Timer specific processing ****
|
|
|
|
****************************************************************************/
|
|
|
|
// Get the Performance counter characteristics:
|
|
|
|
// Freq = Frequency in Hz
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
// Convert the Frequency from Hz to KHz
|
|
|
|
TimerInfo.Frequency = (UINT32)DivU64x32 (Freq, 1000);
|
|
|
|
|
|
|
|
// Determine in which direction the performance counter counts.
|
|
|
|
TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
**** Print heading ****
|
|
|
|
****************************************************************************/
|
|
|
|
// print DP's build version
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_BUILD_REVISION), DP_MAJOR_VERSION, DP_MINOR_VERSION);
|
|
|
|
|
|
|
|
// print performance timer characteristics
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_KHZ), TimerInfo.Frequency); // Print Timer frequency in KHz
|
|
|
|
|
|
|
|
if ((VerboseMode) &&
|
|
|
|
(! RawMode)
|
|
|
|
) {
|
|
|
|
StringPtr = HiiGetString (gHiiHandle,
|
2010-11-12 08:35:37 +01:00
|
|
|
(EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)),
|
2010-04-23 19:00:32 +02:00
|
|
|
NULL);
|
|
|
|
ASSERT (StringPtr != NULL);
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_TIMER_PROPERTIES), // Print Timer count range and direction
|
|
|
|
StringPtr,
|
|
|
|
TimerInfo.StartCount,
|
|
|
|
TimerInfo.EndCount
|
|
|
|
);
|
|
|
|
PrintToken (STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mInterestThreshold);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* **************************************************************************
|
|
|
|
**** Print Sections based on command line options
|
|
|
|
****
|
|
|
|
**** Option modes have the following priority:
|
|
|
|
**** v Verbose -- Valid in combination with any other options
|
|
|
|
**** t Threshold -- Modifies All, Raw, and Cooked output
|
|
|
|
**** Default is 0 for All and Raw mode
|
|
|
|
**** Default is DEFAULT_THRESHOLD for "Cooked" mode
|
|
|
|
**** n Number2Display Used by All and Raw mode. Otherwise ignored.
|
|
|
|
**** A All -- R and S options are ignored
|
|
|
|
**** R Raw -- S option is ignored
|
|
|
|
**** s Summary -- Modifies "Cooked" output only
|
|
|
|
**** Cooked (Default)
|
|
|
|
****
|
|
|
|
**** The All, Raw, and Cooked modes are modified by the Trace and Profile
|
|
|
|
**** options.
|
|
|
|
**** !T && !P := (0) Default, Both are displayed
|
|
|
|
**** T && !P := (1) Only Trace records are displayed
|
|
|
|
**** !T && P := (2) Only Profile records are displayed
|
|
|
|
**** T && P := (3) Same as Default, both are displayed
|
|
|
|
****************************************************************************/
|
2015-11-10 05:57:14 +01:00
|
|
|
GatherStatistics (CustomCumulativeData);
|
|
|
|
if (CumulativeMode) {
|
|
|
|
ProcessCumulative (CustomCumulativeData);
|
|
|
|
} else if (AllMode) {
|
2010-04-23 19:00:32 +02:00
|
|
|
if (TraceMode) {
|
2016-03-07 04:23:07 +01:00
|
|
|
Status = DumpAllTrace( Number2Display, ExcludeMode);
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-04-23 19:00:32 +02:00
|
|
|
}
|
|
|
|
if (ProfileMode) {
|
|
|
|
DumpAllProfile( Number2Display, ExcludeMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (RawMode) {
|
|
|
|
if (TraceMode) {
|
2016-03-07 04:23:07 +01:00
|
|
|
Status = DumpRawTrace( Number2Display, ExcludeMode);
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-04-23 19:00:32 +02:00
|
|
|
}
|
|
|
|
if (ProfileMode) {
|
|
|
|
DumpRawProfile( Number2Display, ExcludeMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//------------- Begin Cooked Mode Processing
|
|
|
|
if (TraceMode) {
|
|
|
|
ProcessPhases ( Ticker );
|
|
|
|
if ( ! SummaryMode) {
|
|
|
|
Status = ProcessHandles ( ExcludeMode);
|
2016-03-07 04:23:07 +01:00
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
goto Done;
|
2010-04-23 19:00:32 +02:00
|
|
|
}
|
2016-03-07 04:23:07 +01:00
|
|
|
|
|
|
|
Status = ProcessPeims ();
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = ProcessGlobal ();
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessCumulative (NULL);
|
2010-04-23 19:00:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ProfileMode) {
|
|
|
|
DumpAllProfile( Number2Display, ExcludeMode);
|
|
|
|
}
|
|
|
|
} //------------- End of Cooked Mode Processing
|
|
|
|
if ( VerboseMode || SummaryMode) {
|
|
|
|
DumpStatistics();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-09 04:22:42 +01:00
|
|
|
|
2016-03-07 04:23:07 +01:00
|
|
|
Done:
|
|
|
|
|
2015-11-10 05:57:14 +01:00
|
|
|
//
|
2010-11-09 04:22:42 +01:00
|
|
|
// Free the memory allocate from HiiGetString
|
|
|
|
//
|
|
|
|
ListIndex = 0;
|
|
|
|
while (DpParamList[ListIndex].Name != NULL) {
|
|
|
|
FreePool (DpParamList[ListIndex].Name);
|
|
|
|
ListIndex ++;
|
|
|
|
}
|
|
|
|
FreePool (DpParamList);
|
2011-11-03 03:45:25 +01:00
|
|
|
|
|
|
|
SafeFreePool (StringDpOptionQh);
|
|
|
|
SafeFreePool (StringDpOptionLh);
|
|
|
|
SafeFreePool (StringDpOptionUh);
|
|
|
|
SafeFreePool (StringDpOptionLv);
|
|
|
|
SafeFreePool (StringDpOptionUs);
|
|
|
|
SafeFreePool (StringDpOptionLs);
|
|
|
|
SafeFreePool (StringDpOptionUa);
|
|
|
|
SafeFreePool (StringDpOptionUr);
|
|
|
|
SafeFreePool (StringDpOptionUt);
|
|
|
|
SafeFreePool (StringDpOptionUp);
|
|
|
|
SafeFreePool (StringDpOptionLx);
|
|
|
|
SafeFreePool (StringDpOptionLn);
|
|
|
|
SafeFreePool (StringDpOptionLt);
|
2012-04-24 11:15:10 +02:00
|
|
|
SafeFreePool (StringDpOptionLi);
|
2015-11-10 05:57:14 +01:00
|
|
|
SafeFreePool (StringDpOptionLc);
|
2011-11-03 03:45:25 +01:00
|
|
|
SafeFreePool (StringPtr);
|
|
|
|
SafeFreePool (mPrintTokenBuffer);
|
|
|
|
|
2016-03-28 05:03:22 +02:00
|
|
|
if (ParamPackage != NULL) {
|
|
|
|
ShellCommandLineFreeVarList (ParamPackage);
|
|
|
|
}
|
2015-11-10 05:57:14 +01:00
|
|
|
if (CustomCumulativeData != NULL) {
|
|
|
|
SafeFreePool (CustomCumulativeData->Name);
|
|
|
|
}
|
|
|
|
SafeFreePool (CustomCumulativeData);
|
|
|
|
|
2010-04-23 19:00:32 +02:00
|
|
|
HiiRemovePackages (gHiiHandle);
|
|
|
|
return Status;
|
|
|
|
}
|