ShellPkg/dp: Convert from NULL class library to Dynamic Command

UEFI Shell spec defines Shell Dynamic Command protocol which is just
for the purpose to extend internal command.
So dp command is changed from NULL class library to be a driver
producing DynamicCommand protocol.

The guideline is:
1. Only use NULL class library for Shell spec defined commands.
2. New commands can be provided as not only a standalone application
   but also a dynamic command. So it can be used either as an
   internal command, but also as a standalone application.

DpApp.inf is to provide a standalone application.
DpDynamicCommand.inf is to provide a standalone driver producing
Dynamic Command protocol.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Ruiyu Ni
2017-11-24 17:26:24 +08:00
parent 0961002352
commit 92034c4c48
19 changed files with 605 additions and 415 deletions

View File

@ -24,20 +24,13 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "UefiDpLib.h"
#include <Library/ShellLib.h>
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Guid/Performance.h>
#include "PerformanceTokens.h" #include "PerformanceTokens.h"
#include "Dp.h" #include "Dp.h"
#include "Literals.h" #include "Literals.h"
#include "DpInternal.h" #include "DpInternal.h"
EFI_HANDLE mDpHiiHandle;
// //
/// Module-Global Variables /// Module-Global Variables
///@{ ///@{
@ -89,18 +82,18 @@ DumpStatistics( void )
{ {
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), gDpHiiHandle, SummaryData.NumTrace); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle, SummaryData.NumTrace);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), gDpHiiHandle, SummaryData.NumIncomplete); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), gDpHiiHandle, SummaryData.NumSummary); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), gDpHiiHandle, SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle, SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), gDpHiiHandle, SummaryData.NumPEIMs); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle, SummaryData.NumPEIMs);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), gDpHiiHandle, SummaryData.NumGlobal); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle, SummaryData.NumGlobal);
#if PROFILING_IMPLEMENTED #if PROFILING_IMPLEMENTED
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), gDpHiiHandle, SummaryData.NumProfile); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle, SummaryData.NumProfile);
#endif // PROFILING_IMPLEMENTED #endif // PROFILING_IMPLEMENTED
SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtr);
SHELL_FREE_NON_NULL (StringPtrUnknown); SHELL_FREE_NON_NULL (StringPtrUnknown);
@ -137,8 +130,7 @@ InitCumulativeData (
@retval value Unknown error. @retval value Unknown error.
**/ **/
SHELL_STATUS SHELL_STATUS
EFIAPI RunDp (
ShellCommandRunDp (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
@ -182,15 +174,12 @@ ShellCommandRunDp (
Status = ShellInitialize(); Status = ShellInitialize();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
// //
// Process Command Line arguments // Process Command Line arguments
// //
Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE); Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} }
@ -273,7 +262,7 @@ ShellCommandRunDp (
// //
Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty); Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) { if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);
goto Done; goto Done;
} }
@ -288,22 +277,22 @@ ShellCommandRunDp (
// Print header // Print header
// //
// print DP's build version // print DP's build version
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), gDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), mDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
// print performance timer characteristics // print performance timer characteristics
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), gDpHiiHandle, TimerInfo.Frequency); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);
if (VerboseMode && !RawMode) { if (VerboseMode && !RawMode) {
StringPtr = HiiGetString (gDpHiiHandle, StringPtr = HiiGetString (mDpHiiHandle,
(EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL); (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
ASSERT (StringPtr != NULL); ASSERT (StringPtr != NULL);
// Print Timer count range and direction // Print Timer count range and direction
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,
StringPtr, StringPtr,
TimerInfo.StartCount, TimerInfo.StartCount,
TimerInfo.EndCount TimerInfo.EndCount
); );
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), gDpHiiHandle, mInterestThreshold); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold);
} }
/**************************************************************************** /****************************************************************************
@ -398,3 +387,52 @@ Done:
return ShellStatus; return ShellStatus;
} }
/**
Retrive HII package list from ImageHandle and publish to HII database.
@param ImageHandle The image handle of the process.
@return HII handle.
**/
EFI_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
//
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
NULL,
&HiiHandle
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
return HiiHandle;
}

View File

@ -1,7 +1,7 @@
/** @file /** @file
Common declarations for the Dp Performance Reporting Utility. Header file for 'dp' command functions.
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved. Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -9,12 +9,37 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _EFI_APP_DP_H_ #ifndef _DP_H_
#define _EFI_APP_DP_H_ #define _DP_H_
#include <Uefi.h>
#include <Guid/Performance.h>
#include <Protocol/HiiPackageList.h>
#include <Protocol/DevicePath.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/UnicodeCollation.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/ShellLib.h> #include <Library/ShellLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/SortLib.h>
#include <Library/HiiLib.h>
#include <Library/FileHandleLib.h>
#include <Library/UefiHiiServicesLib.h>
extern EFI_HANDLE mDpHiiHandle;
#define DP_MAJOR_VERSION 2 #define DP_MAJOR_VERSION 2
#define DP_MINOR_VERSION 4 #define DP_MINOR_VERSION 4
@ -94,4 +119,32 @@ typedef struct {
UINT32 Count; ///< Number of measurements accumulated. UINT32 Count; ///< Number of measurements accumulated.
} PROFILE_RECORD; } PROFILE_RECORD;
#endif // _EFI_APP_DP_H_ /**
Dump performance data.
@param[in] ImageHandle The image handle.
@param[in] SystemTable The system table.
@retval SHELL_SUCCESS Command completed successfully.
@retval SHELL_INVALID_PARAMETER Command usage error.
@retval SHELL_ABORTED The user aborts the operation.
@retval value Unknown error.
**/
SHELL_STATUS
RunDp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Retrive HII package list from ImageHandle and publish to HII database.
@param ImageHandle The image handle of the process.
@return HII handle.
**/
EFI_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
);
#endif // _DP_H_

View File

@ -0,0 +1,53 @@
/** @file
Entrypoint of "dp" shell standalone application.
Copyright (c) 2017, 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 "Dp.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 mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_DP);
/**
Entry point of Tftp standalone application.
@param ImageHandle The image handle of the process.
@param SystemTable The EFI System Table pointer.
@retval EFI_SUCCESS Tftp command is executed sucessfully.
@retval EFI_ABORTED HII package was failed to initialize.
@retval others Other errors when executing tftp command.
**/
EFI_STATUS
EFIAPI
DpAppInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) {
return EFI_ABORTED;
}
Status = (EFI_STATUS)RunDp (ImageHandle, SystemTable);
HiiRemovePackages (mDpHiiHandle);
return Status;
}

View File

@ -0,0 +1,73 @@
## @file
# Provides Shell 'dp' standalone application.
#
# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
##
[Defines]
INF_VERSION = 0x00010006
BASE_NAME = dp
FILE_GUID = 1831A379-2D48-45BD-9744-D4059D93815D
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = DpAppInitialize
#
# 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
DpInternal.h
DpUtilities.c
DpTrace.c
DpProfile.c
DpApp.c
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
MemoryAllocationLib
BaseLib
BaseMemoryLib
DebugLib
ShellLib
UefiLib
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
UefiApplicationEntryPoint
SortLib
PrintLib
DevicePathLib
PerformanceLib
DxeServicesLib
PeCoffGetEntryPointLib
[Guids]
gPerformanceProtocolGuid ## CONSUMES ## SystemTable
[Protocols]
gEfiLoadedImageProtocolGuid ## CONSUMES
gEfiDriverBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiComponentName2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiLoadedImageDevicePathProtocolGuid ## SOMETIMES_CONSUMES
gEfiHiiPackageListProtocolGuid ## CONSUMES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize ## CONSUMES

View File

@ -0,0 +1,130 @@
/** @file
Produce "dp" shell dynamic command.
Copyright (c) 2017, 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 "Dp.h"
#include <Protocol/ShellDynamicCommand.h>
/**
This is the shell command handler function pointer callback type. This
function handles the command when it is invoked in the shell.
@param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
@param[in] SystemTable The pointer to the system table.
@param[in] ShellParameters The parameters associated with the command.
@param[in] Shell The instance of the shell protocol used in the context
of processing this command.
@return EFI_SUCCESS the operation was sucessful
@return other the operation failed.
**/
SHELL_STATUS
EFIAPI
DpCommandHandler (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
)
{
gEfiShellParametersProtocol = ShellParameters;
return RunDp (gImageHandle, SystemTable);
}
/**
This is the command help handler function pointer callback type. This
function is responsible for displaying help information for the associated
command.
@param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
@param[in] Language The pointer to the language string to use.
@return string Pool allocated help string, must be freed by caller
**/
CHAR16 *
EFIAPI
DpCommandGetHelp (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
)
{
return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);
}
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
L"dp",
DpCommandHandler,
DpCommandGetHelp
};
/**
Entry point of Tftp Dynamic Command.
Produce the DynamicCommand protocol to handle "tftp" command.
@param ImageHandle The image handle of the process.
@param SystemTable The EFI System Table pointer.
@retval EFI_SUCCESS Tftp command is executed sucessfully.
@retval EFI_ABORTED HII package was failed to initialize.
@retval others Other errors when executing tftp command.
**/
EFI_STATUS
EFIAPI
DpCommandInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) {
return EFI_ABORTED;
}
Status = gBS->InstallProtocolInterface (
&ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
EFI_NATIVE_INTERFACE,
&mDpDynamicCommand
);
ASSERT_EFI_ERROR (Status);
return Status;
}
/**
Tftp driver unload handler.
@param ImageHandle The image handle of the process.
@retval EFI_SUCCESS The image is unloaded.
@retval Others Failed to unload the image.
**/
EFI_STATUS
EFIAPI
DpUnload (
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface (
ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
&mDpDynamicCommand
);
if (EFI_ERROR (Status)) {
return Status;
}
HiiRemovePackages (mDpHiiHandle);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,78 @@
## @file
# Provides Shell 'dp' dynamic command.
#
# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
##
[Defines]
INF_VERSION = 0x00010006
BASE_NAME = dpDynamicCommand
FILE_GUID = 0253F9FA-129A-4A8D-B12E-7DC2B6376302
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = DpCommandInitialize
UNLOAD_IMAGE = DpUnload
#
# 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
DpInternal.h
DpUtilities.c
DpTrace.c
DpProfile.c
DpDynamicCommand.c
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
MemoryAllocationLib
BaseLib
BaseMemoryLib
DebugLib
ShellLib
UefiLib
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
UefiDriverEntryPoint
SortLib
PrintLib
DevicePathLib
PerformanceLib
DxeServicesLib
PeCoffGetEntryPointLib
[Guids]
gPerformanceProtocolGuid ## CONSUMES ## SystemTable
[Protocols]
gEfiLoadedImageProtocolGuid ## CONSUMES
gEfiDriverBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiComponentName2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiLoadedImageDevicePathProtocolGuid ## SOMETIMES_CONSUMES
gEfiHiiPackageListProtocolGuid ## CONSUMES
gEfiShellDynamicCommandProtocolGuid ## PRODUCES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize ## CONSUMES
[DEPEX]
TRUE

View File

@ -24,7 +24,7 @@
// //
/// Module-Global Variables /// Module-Global Variables
///@{ ///@{
extern EFI_HII_HANDLE gDpHiiHandle; extern EFI_HII_HANDLE mDpHiiHandle;
extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
extern UINT64 mInterestThreshold; extern UINT64 mInterestThreshold;

View File

@ -55,10 +55,10 @@ DumpAllProfile(
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -91,9 +91,9 @@ DumpRawProfile(
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);

View File

@ -159,9 +159,9 @@ DumpAllTrace(
EFI_STATUS Status; EFI_STATUS Status;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL); IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(IncFlag == NULL) ? StringPtrUnknown : IncFlag); (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -169,7 +169,7 @@ DumpAllTrace(
// //
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
} }
else { else {
// We have successfully populated the HandleBuffer // We have successfully populated the HandleBuffer
@ -179,11 +179,11 @@ DumpAllTrace(
// Display driver names in Module field for records with Handles. // Display driver names in Module field for records with Handles.
// //
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), mDpHiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), mDpHiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), mDpHiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
} }
LogEntryKey = 0; LogEntryKey = 0;
@ -206,10 +206,10 @@ DumpAllTrace(
if (Measurement.EndTimeStamp != 0) { if (Measurement.EndTimeStamp != 0) {
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds ( Duration );
IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL); IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
} }
else { else {
IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
} }
if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) || if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0)) ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
@ -240,7 +240,7 @@ DumpAllTrace(
mUnicodeToken[13] = 0; mUnicodeToken[13] = 0;
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed Index, // 1 based, Which measurement record is being printed
IncFlag, IncFlag,
Measurement.Handle, Measurement.Handle,
@ -250,7 +250,7 @@ DumpAllTrace(
Measurement.Identifier Measurement.Identifier
); );
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed Index, // 1 based, Which measurement record is being printed
IncFlag, IncFlag,
Measurement.Handle, Measurement.Handle,
@ -312,19 +312,19 @@ DumpRawTrace(
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), mDpHiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), mDpHiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), mDpHiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), mDpHiiHandle);
} }
LogEntryKey = 0; LogEntryKey = 0;
@ -355,7 +355,7 @@ DumpRawTrace(
++Count; // Count the number of records printed ++Count; // Count the number of records printed
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed Index, // 1 based, Which measurement record is being printed
Measurement.Handle, Measurement.Handle,
Measurement.StartTimeStamp, Measurement.StartTimeStamp,
@ -365,7 +365,7 @@ DumpRawTrace(
Measurement.Identifier Measurement.Identifier
); );
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed Index, // 1 based, Which measurement record is being printed
Measurement.Handle, Measurement.Handle,
Measurement.StartTimeStamp, Measurement.StartTimeStamp,
@ -412,9 +412,9 @@ ProcessPhases(
// //
// Get Execution Phase Statistics // Get Execution Phase Statistics
// //
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -456,7 +456,7 @@ ProcessPhases(
if (SecTime > 0) { if (SecTime > 0) {
ElapsedTime = DurationInMicroSeconds ( SecTime ); // Calculate elapsed time in microseconds ElapsedTime = DurationInMicroSeconds ( SecTime ); // Calculate elapsed time in microseconds
Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), gDpHiiHandle, ElapsedTime); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);
} }
// print PEI phase duration time // print PEI phase duration time
@ -467,7 +467,7 @@ ProcessPhases(
(UINT32)TimerInfo.Frequency (UINT32)TimerInfo.Frequency
); );
Total += ElapsedTime; Total += ElapsedTime;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_PEI, ElapsedTime); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);
} }
// print DXE phase duration time // print DXE phase duration time
@ -478,7 +478,7 @@ ProcessPhases(
(UINT32)TimerInfo.Frequency (UINT32)TimerInfo.Frequency
); );
Total += ElapsedTime; Total += ElapsedTime;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_DXE, ElapsedTime); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);
} }
// print BDS phase duration time // print BDS phase duration time
@ -489,7 +489,7 @@ ProcessPhases(
(UINT32)TimerInfo.Frequency (UINT32)TimerInfo.Frequency
); );
Total += ElapsedTime; Total += ElapsedTime;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_BDS, ElapsedTime); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);
} }
if (BdsTimeoutValue > 0) { if (BdsTimeoutValue > 0) {
@ -497,10 +497,10 @@ ProcessPhases(
BdsTimeoutValue, BdsTimeoutValue,
(UINT32)TimerInfo.Frequency (UINT32)TimerInfo.Frequency
); );
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), gDpHiiHandle, ALit_BdsTO, ElapsedTime); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpHiiHandle, ALit_BdsTO, ElapsedTime);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), gDpHiiHandle, Total); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), mDpHiiHandle, Total);
} }
/** /**
@ -529,16 +529,16 @@ ProcessHandles(
EFI_STATUS Status; EFI_STATUS Status;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
} }
else { else {
#if DP_DEBUG == 2 #if DP_DEBUG == 2
@ -546,11 +546,11 @@ ProcessHandles(
#endif #endif
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
LogEntryKey = 0; LogEntryKey = 0;
Count = 0; Count = 0;
@ -588,7 +588,7 @@ ProcessHandles(
if (mGaugeString[0] != 0) { if (mGaugeString[0] != 0) {
// Display the record if it has a valid handle. // Display the record if it has a valid handle.
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), mDpHiiHandle,
Count, // 1 based, Which measurement record is being printed Count, // 1 based, Which measurement record is being printed
Index + 1, // 1 based, Which handle is being printed Index + 1, // 1 based, Which handle is being printed
mGaugeString, mGaugeString,
@ -597,7 +597,7 @@ ProcessHandles(
Measurement.Identifier Measurement.Identifier
); );
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), mDpHiiHandle,
Count, // 1 based, Which measurement record is being printed Count, // 1 based, Which measurement record is being printed
Index + 1, // 1 based, Which handle is being printed Index + 1, // 1 based, Which handle is being printed
mGaugeString, mGaugeString,
@ -642,19 +642,19 @@ ProcessPeims(
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), mDpHiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
TIndex = 0; TIndex = 0;
LogEntryKey = 0; LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementEx ( while ((LogEntryKey = GetPerformanceMeasurementEx (
@ -678,7 +678,7 @@ ProcessPeims(
if (ElapsedTime >= mInterestThreshold) { if (ElapsedTime >= mInterestThreshold) {
// PEIM FILE Handle is the start address of its FFS file that contains its file guid. // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,
TIndex, // 1 based, Which measurement record is being printed TIndex, // 1 based, Which measurement record is being printed
Measurement.Handle, // base address Measurement.Handle, // base address
Measurement.Handle, // file guid Measurement.Handle, // file guid
@ -686,7 +686,7 @@ ProcessPeims(
Measurement.Identifier Measurement.Identifier
); );
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,
TIndex, // 1 based, Which measurement record is being printed TIndex, // 1 based, Which measurement record is being printed
Measurement.Handle, // base address Measurement.Handle, // base address
Measurement.Handle, // file guid Measurement.Handle, // file guid
@ -729,19 +729,19 @@ ProcessGlobal(
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), mDpHiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
Index = 1; Index = 1;
LogEntryKey = 0; LogEntryKey = 0;
@ -768,7 +768,7 @@ ProcessGlobal(
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds ( Duration );
if (ElapsedTime >= mInterestThreshold) { if (ElapsedTime >= mInterestThreshold) {
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
Index, Index,
mGaugeString, mGaugeString,
mUnicodeToken, mUnicodeToken,
@ -776,7 +776,7 @@ ProcessGlobal(
Measurement.Identifier Measurement.Identifier
); );
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle,
Index, Index,
mGaugeString, mGaugeString,
mUnicodeToken, mUnicodeToken,
@ -818,16 +818,16 @@ ProcessCumulative(
UINTN TIndex; UINTN TIndex;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), mDpHiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), mDpHiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
for ( TIndex = 0; TIndex < NumCum; ++TIndex) { for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
if (CumData[TIndex].Count != 0) { if (CumData[TIndex].Count != 0) {
@ -837,7 +837,7 @@ ProcessCumulative(
MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur); MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur); MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
CumData[TIndex].Name, CumData[TIndex].Name,
CumData[TIndex].Count, CumData[TIndex].Count,
Dur, Dur,
@ -864,7 +864,7 @@ ProcessCumulative(
MaxDur = 0; MaxDur = 0;
MinDur = 0; MinDur = 0;
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle, ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
CustomCumulativeData->Name, CustomCumulativeData->Name,
CustomCumulativeData->Count, CustomCumulativeData->Count,
Dur, Dur,

View File

@ -207,6 +207,7 @@ DpGetNameFromHandle (
CHAR16 *NameString; CHAR16 *NameString;
UINTN StringSize; UINTN StringSize;
CHAR8 *PlatformLanguage; CHAR8 *PlatformLanguage;
CHAR8 *BestLanguage;
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
Image = NULL; Image = NULL;
@ -259,16 +260,25 @@ DpGetNameFromHandle (
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Get the current platform language setting // Firstly use platform language setting, secondly use driver's first supported language.
// //
PlatformLanguage = GetBestLanguageForDriver(ComponentName2->SupportedLanguages, NULL, FALSE); GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&PlatformLanguage, NULL);
BestLanguage = GetBestLanguage(
ComponentName2->SupportedLanguages,
FALSE,
(PlatformLanguage != NULL) ? PlatformLanguage : "",
ComponentName2->SupportedLanguages,
NULL
);
SHELL_FREE_NON_NULL (PlatformLanguage);
Status = ComponentName2->GetDriverName ( Status = ComponentName2->GetDriverName (
ComponentName2, ComponentName2,
PlatformLanguage != NULL ? PlatformLanguage : "en-US", BestLanguage != NULL ? BestLanguage : "en-US",
&StringPtr &StringPtr
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL (PlatformLanguage); SHELL_FREE_NON_NULL (BestLanguage);
StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH); StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
return; return;
@ -344,7 +354,7 @@ DpGetNameFromHandle (
// //
// Method 6: Unknown Driver Name // Method 6: Unknown Driver Name
// //
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);
ASSERT (StringPtr != NULL); ASSERT (StringPtr != NULL);
StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH); StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);
FreePool (StringPtr); FreePool (StringPtr);

View File

@ -1,2 +0,0 @@
from PerformancePkg\Dp_App
SVN 13406

View File

@ -1,101 +0,0 @@
/** @file
Main file for NULL named library for install1 shell command functions.
Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiDpLib.h"
STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
EFI_HANDLE gDpHiiHandle = NULL;
#define DP_HII_GUID \
{ \
0xeb832fd9, 0x9089, 0x4898, { 0x83, 0xc9, 0x41, 0x61, 0x8f, 0x5c, 0x48, 0xb9 } \
}
EFI_GUID gDpHiiGuid = DP_HII_GUID;
/**
Function to get the filename with help context if HII will not be used.
@return The filename with help text in it.
**/
CONST CHAR16*
EFIAPI
UefiDpLibGetManFileName (
VOID
)
{
return (mFileName);
}
/**
Constructor for the Shell Level 1 Commands library.
Install the handlers for level 1 UEFI Shell 2.0 commands.
@param ImageHandle the image handle of the process
@param SystemTable the EFI System Table pointer
@retval EFI_SUCCESS the shell command handlers were installed sucessfully
@retval EFI_UNSUPPORTED the shell level required was not found.
**/
EFI_STATUS
EFIAPI
UefiDpLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
// check our bit of the profiles mask
//
if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
return (EFI_SUCCESS);
}
//
// 3rd parameter 'HII strings array' must be name of .uni strings file followed by 'Strings', e.g. mycommands.uni must be
// specified as 'mycommandsStrings' because the build Autogen process defines this as a string array for the strings in your
// .uni file. Examine your Build folder under your package's DEBUG folder and you will find it defined in a xxxStrDefs.h file.
//
gDpHiiHandle = HiiAddPackages (&gDpHiiGuid, gImageHandle, UefiDpLibStrings, NULL);
if (gDpHiiHandle == NULL) {
return (EFI_DEVICE_ERROR);
}
//
// install our shell command handlers that are always installed
//
ShellCommandRegisterCommandName(L"dp", ShellCommandRunDp , UefiDpLibGetManFileName, 0, L"", FALSE, gDpHiiHandle, STRING_TOKEN(STR_GET_HELP_DP));
return (EFI_SUCCESS);
}
/**
Destructor for the library. free any resources.
@param ImageHandle The image handle of the process.
@param SystemTable The EFI System Table pointer.
**/
EFI_STATUS
EFIAPI
UefiDpLibDestructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
if (gDpHiiHandle != NULL) {
HiiRemovePackages(gDpHiiHandle);
}
return (EFI_SUCCESS);
}

View File

@ -1,64 +0,0 @@
/** @file
Main file for NULL named library for dp command functions.
Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 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.
**/
#ifndef _UEFI_DP_LIB_H_
#define _UEFI_DP_LIB_H_
#include <Uefi.h>
extern EFI_GUID gDpHiiGuid;
#include <Protocol/Shell.h>
#include <Protocol/ShellParameters.h>
#include <Protocol/DevicePath.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/UnicodeCollation.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/ShellCommandLib.h>
#include <Library/ShellLib.h>
#include <Library/SortLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/HiiLib.h>
#include <Library/FileHandleLib.h>
extern EFI_HANDLE gDpHiiHandle;
/**
Function for 'dp' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
@retval SHELL_SUCCESS Command completed successfully.
@retval SHELL_INVALID_PARAMETER Command usage error.
@retval SHELL_ABORTED The user aborts the operation.
@retval value Unknown error.
**/
SHELL_STATUS
EFIAPI
ShellCommandRunDp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
#endif

View File

@ -1,77 +0,0 @@
## @file
# Display Performance Application, Module information file.
#
# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
[Defines]
INF_VERSION = 0x00010006
BASE_NAME = UefiDpLib
FILE_GUID = 9DF262F7-CF81-4294-B5A5-B2E3CAFE5618
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
CONSTRUCTOR = UefiDpLibConstructor
DESTRUCTOR = UefiDpLibDestructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
PerformanceTokens.h
UefiDpLib.c
UefiDpLib.h
UefiDpLib.uni
Dp.c
Dp.h
Literals.h
Literals.c
DpInternal.h
DpUtilities.c
DpTrace.c
DpProfile.c
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
PerformanceLib
DxeServicesLib
MemoryAllocationLib
BaseLib
BaseMemoryLib
DebugLib
ShellCommandLib
ShellLib
UefiLib
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
SortLib
PrintLib
DevicePathLib
[Guids]
gPerformanceProtocolGuid ## CONSUMES ## SystemTable
[Protocols]
gEfiLoadedImageProtocolGuid ## CONSUMES
gEfiDriverBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiComponentName2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiLoadedImageDevicePathProtocolGuid ## SOMETIMES_CONSUMES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize ## UNDEFINED
gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES

View File

@ -104,12 +104,6 @@
ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
ShellPkg/Library/UefiDpLib/UefiDpLib.inf {
<LibraryClasses>
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
}
ShellPkg/Application/Shell/Shell.inf { ShellPkg/Application/Shell/Shell.inf {
<PcdsFixedAtBuild> <PcdsFixedAtBuild>
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
@ -123,14 +117,19 @@
NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
!ifdef $(INCLUDE_DP)
NULL|ShellPkg/Library/UefiDpLib/UefiDpLib.inf
!endif #$(INCLUDE_DP)
!endif #$(NO_SHELL_PROFILES) !endif #$(NO_SHELL_PROFILES)
} }
ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
<LibraryClasses>
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
}
ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf {
<LibraryClasses>
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
}
[BuildOptions] [BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES