Move some define code to the uni file. Also fixed some memory leak.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11015 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10 2010-11-09 03:22:42 +00:00
parent 224beee0fa
commit 8835954602
8 changed files with 197 additions and 91 deletions

View File

@ -44,6 +44,7 @@
/// Module-Global Variables /// Module-Global Variables
///@{ ///@{
EFI_HII_HANDLE gHiiHandle; EFI_HII_HANDLE gHiiHandle;
SHELL_PARAM_ITEM *DpParamList = NULL;
CHAR16 *mPrintTokenBuffer = NULL; CHAR16 *mPrintTokenBuffer = NULL;
CHAR16 mGaugeString[DXE_PERFORMANCE_STRING_SIZE]; CHAR16 mGaugeString[DXE_PERFORMANCE_STRING_SIZE];
CHAR16 mUnicodeToken[PERF_TOKEN_LENGTH + 1]; CHAR16 mUnicodeToken[PERF_TOKEN_LENGTH + 1];
@ -65,26 +66,51 @@ PERF_CUM_DATA CumData[] = {
/// Number of items for which we are gathering cumulative statistics. /// Number of items for which we are gathering cumulative statistics.
UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA); UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
SHELL_PARAM_ITEM DpParamList[] = { PARAM_ITEM_LIST ParamList[] = {
{STR_DP_OPTION_QH, TypeFlag}, // -? Help {STRING_TOKEN (STR_DP_OPTION_QH), TypeFlag}, // -? Help
{STR_DP_OPTION_LH, TypeFlag}, // -h Help {STRING_TOKEN (STR_DP_OPTION_LH), TypeFlag}, // -h Help
{STR_DP_OPTION_UH, TypeFlag}, // -H Help {STRING_TOKEN (STR_DP_OPTION_UH), TypeFlag}, // -H Help
{STR_DP_OPTION_LV, TypeFlag}, // -v Verbose Mode {STRING_TOKEN (STR_DP_OPTION_LV), TypeFlag}, // -v Verbose Mode
{STR_DP_OPTION_UA, TypeFlag}, // -A All, Cooked {STRING_TOKEN (STR_DP_OPTION_UA), TypeFlag}, // -A All, Cooked
{STR_DP_OPTION_UR, TypeFlag}, // -R RAW All {STRING_TOKEN (STR_DP_OPTION_UR), TypeFlag}, // -R RAW All
{STR_DP_OPTION_LS, TypeFlag}, // -s Summary {STRING_TOKEN (STR_DP_OPTION_LS), TypeFlag}, // -s Summary
#if PROFILING_IMPLEMENTED #if PROFILING_IMPLEMENTED
{STR_DP_OPTION_UP, TypeFlag}, // -P Dump Profile Data {STRING_TOKEN (STR_DP_OPTION_UP), TypeFlag}, // -P Dump Profile Data
{STR_DP_OPTION_UT, TypeFlag}, // -T Dump Trace Data {STRING_TOKEN (STR_DP_OPTION_UT), TypeFlag}, // -T Dump Trace Data
#endif #endif
{STR_DP_OPTION_LX, TypeFlag}, // -x eXclude Cumulative Items {STRING_TOKEN (STR_DP_OPTION_LX), TypeFlag}, // -x eXclude Cumulative Items
{STR_DP_OPTION_LN, TypeValue}, // -n # Number of records to display for A and R {STRING_TOKEN (STR_DP_OPTION_LN), TypeValue}, // -n # Number of records to display for A and R
{STR_DP_OPTION_LT, TypeValue}, // -t # Threshold of interest {STRING_TOKEN (STR_DP_OPTION_LT), TypeValue} // -t # Threshold of interest
{NULL, TypeMax}
}; };
///@} ///@}
/**
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;
}
/** /**
Display Usage and Help information. Display Usage and Help information.
**/ **/
@ -120,10 +146,11 @@ VOID
DumpStatistics( void ) DumpStatistics( void )
{ {
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown;
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMTRACE), SummaryData.NumTrace); PrintToken( STRING_TOKEN (STR_DP_STATS_NUMTRACE), SummaryData.NumTrace);
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), SummaryData.NumIncomplete); PrintToken( STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), SummaryData.NumIncomplete);
@ -134,6 +161,8 @@ DumpStatistics( void )
#if PROFILING_IMPLEMENTED #if PROFILING_IMPLEMENTED
PrintToken( STRING_TOKEN (STR_DP_STATS_NUMPROFILE), SummaryData.NumProfile); PrintToken( STRING_TOKEN (STR_DP_STATS_NUMPROFILE), SummaryData.NumProfile);
#endif // PROFILING_IMPLEMENTED #endif // PROFILING_IMPLEMENTED
FreePool (StringPtr);
FreePool (StringPtrUnknown);
} }
/** /**
@ -156,7 +185,8 @@ InitializeDp (
{ {
UINT64 Freq; UINT64 Freq;
UINT64 Ticker; UINT64 Ticker;
UINT32 ListIndex;
LIST_ENTRY *ParamPackage; LIST_ENTRY *ParamPackage;
CONST CHAR16 *CmdLineArg; CONST CHAR16 *CmdLineArg;
EFI_STRING StringPtr; EFI_STRING StringPtr;
@ -171,6 +201,20 @@ InitializeDp (
BOOLEAN ProfileMode; BOOLEAN ProfileMode;
BOOLEAN ExcludeMode; BOOLEAN ExcludeMode;
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;
SummaryMode = FALSE; SummaryMode = FALSE;
VerboseMode = FALSE; VerboseMode = FALSE;
AllMode = FALSE; AllMode = FALSE;
@ -178,6 +222,22 @@ InitializeDp (
TraceMode = FALSE; TraceMode = FALSE;
ProfileMode = FALSE; ProfileMode = FALSE;
ExcludeMode = FALSE; ExcludeMode = FALSE;
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;
StringPtr = NULL;
// Get DP's entry time as soon as possible. // Get DP's entry time as soon as possible.
// This is used as the Shell-Phase end time. // This is used as the Shell-Phase end time.
// //
@ -188,6 +248,10 @@ InitializeDp (
gHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, DPStrings, NULL); gHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, DPStrings, NULL);
ASSERT (gHiiHandle != NULL); ASSERT (gHiiHandle != NULL);
// Initial the command list
//
InitialShellParamList ();
/**************************************************************************** /****************************************************************************
**** Process Command Line arguments **** **** Process Command Line arguments ****
****************************************************************************/ ****************************************************************************/
@ -198,27 +262,43 @@ InitializeDp (
ShowHelp(); ShowHelp();
} }
else { else {
if (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_QH) || StringDpOptionQh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_QH), NULL);
ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_LH) || StringDpOptionLh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LH), NULL);
ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_UH)) StringDpOptionUh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UH), NULL);
if (ShellCommandLineGetFlag (ParamPackage, StringDpOptionQh) ||
ShellCommandLineGetFlag (ParamPackage, StringDpOptionLh) ||
ShellCommandLineGetFlag (ParamPackage, StringDpOptionUh))
{ {
ShowHelp(); ShowHelp();
} }
else { else {
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);
// Boolean Options // Boolean Options
VerboseMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_LV)); //
SummaryMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_US) || VerboseMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLv);
ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_LS)); SummaryMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUs) ||
AllMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_UA)); ShellCommandLineGetFlag (ParamPackage, StringDpOptionLs);
RawMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_UR)); AllMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUa);
RawMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUr);
#if PROFILING_IMPLEMENTED #if PROFILING_IMPLEMENTED
TraceMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_UT)); TraceMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUt);
ProfileMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_UP)); ProfileMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUp);
#endif // PROFILING_IMPLEMENTED #endif // PROFILING_IMPLEMENTED
ExcludeMode = (ShellCommandLineGetFlag (ParamPackage, STR_DP_OPTION_LX)); ExcludeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLx);
// Options with Values // Options with Values
CmdLineArg = ( ShellCommandLineGetValue (ParamPackage, STR_DP_OPTION_LN)); CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLn);
if (CmdLineArg == NULL) { if (CmdLineArg == NULL) {
Number2Display = DEFAULT_DISPLAYCOUNT; Number2Display = DEFAULT_DISPLAYCOUNT;
} }
@ -228,7 +308,7 @@ InitializeDp (
Number2Display = MAXIMUM_DISPLAYCOUNT; Number2Display = MAXIMUM_DISPLAYCOUNT;
} }
} }
CmdLineArg = (ShellCommandLineGetValue (ParamPackage, STR_DP_OPTION_LT)); CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLt);
if (CmdLineArg == NULL) { if (CmdLineArg == NULL) {
mInterestThreshold = DEFAULT_THRESHOLD; // 1ms := 1,000 us mInterestThreshold = DEFAULT_THRESHOLD; // 1ms := 1,000 us
} }
@ -344,7 +424,32 @@ InitializeDp (
} }
} }
} }
(void) FreePool (mPrintTokenBuffer);
// Free the memory allocate from HiiGetString
//
ListIndex = 0;
while (DpParamList[ListIndex].Name != NULL) {
FreePool (DpParamList[ListIndex].Name);
ListIndex ++;
}
FreePool (DpParamList);
FreePool (StringDpOptionQh);
FreePool (StringDpOptionLh);
FreePool (StringDpOptionUh);
FreePool (StringDpOptionLv);
FreePool (StringDpOptionUs);
FreePool (StringDpOptionLs);
FreePool (StringDpOptionUa);
FreePool (StringDpOptionUr);
FreePool (StringDpOptionUt);
FreePool (StringDpOptionUp);
FreePool (StringDpOptionLx);
FreePool (StringDpOptionLn);
FreePool (StringDpOptionLt);
FreePool (StringPtr);
FreePool (mPrintTokenBuffer);
HiiRemovePackages (gHiiHandle); HiiRemovePackages (gHiiHandle);
return Status; return Status;
} }

View File

@ -14,6 +14,8 @@
#ifndef _EFI_APP_DP_H_ #ifndef _EFI_APP_DP_H_
#define _EFI_APP_DP_H_ #define _EFI_APP_DP_H_
#include <Library/ShellLib.h>
#define DP_MAJOR_VERSION 2 #define DP_MAJOR_VERSION 2
#define DP_MINOR_VERSION 3 #define DP_MINOR_VERSION 3
@ -91,4 +93,8 @@ typedef struct {
UINT32 Count; ///< Number of measurements accumulated. UINT32 Count; ///< Number of measurements accumulated.
} PROFILE_RECORD; } PROFILE_RECORD;
typedef struct {
UINT16 Token;
SHELL_PARAM_TYPE Type;
} PARAM_ITEM_LIST;
#endif // _EFI_APP_DP_H_ #endif // _EFI_APP_DP_H_

View File

@ -54,10 +54,15 @@ DumpAllProfile(
) )
{ {
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
return; return;
} }
@ -86,9 +91,13 @@ DumpRawProfile(
) )
{ {
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
return; return;
} }

Binary file not shown.

View File

@ -137,10 +137,13 @@ DumpAllTrace(
UINTN Size; UINTN Size;
EFI_HANDLE TempHandle; EFI_HANDLE TempHandle;
EFI_STATUS Status; EFI_STATUS Status;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL); IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(IncFlag == NULL) ? ALit_UNKNOWN: IncFlag); (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
FreePool (StringPtrUnknown);
// Get Handle information // Get Handle information
// //
@ -183,13 +186,16 @@ DumpAllTrace(
{ {
++Index; // Count every record. First record is 1. ++Index; // Count every record. First record is 1.
ElapsedTime = 0; ElapsedTime = 0;
if (IncFlag != NULL) {
FreePool ((void *)IncFlag);
}
if (Measurement.EndTimeStamp != 0) { if (Measurement.EndTimeStamp != 0) {
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds ( Duration );
IncFlag = STR_DP_COMPLETE; IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
} }
else { else {
IncFlag = STR_DP_INCOMPLETE; // Mark incomplete records IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
} }
if ((ElapsedTime < mInterestThreshold) || if ((ElapsedTime < mInterestThreshold) ||
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0)) ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
@ -230,6 +236,7 @@ DumpAllTrace(
if (HandleBuffer != &TempHandle) { if (HandleBuffer != &TempHandle) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
} }
FreePool ((void *)IncFlag);
} }
/** /**
@ -264,10 +271,14 @@ DumpRawTrace(
UINTN Index; UINTN Index;
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) ); PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) );
PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) ); PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) );
@ -331,6 +342,7 @@ ProcessPhases(
UINT64 Total; UINT64 Total;
EFI_STRING StringPtr; EFI_STRING StringPtr;
UINTN LogEntryKey; UINTN LogEntryKey;
EFI_STRING StringPtrUnknown;
BdsTimeoutValue = 0; BdsTimeoutValue = 0;
SecTime = 0; SecTime = 0;
@ -341,9 +353,12 @@ ProcessPhases(
// //
// Get Execution Phase Statistics // Get Execution Phase Statistics
// //
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
LogEntryKey = 0; LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurement ( while ((LogEntryKey = GetPerformanceMeasurement (
@ -467,10 +482,14 @@ ProcessHandles(
UINTN Size; UINTN Size;
EFI_HANDLE TempHandle; EFI_HANDLE TempHandle;
EFI_STATUS Status; EFI_STATUS Status;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
Size = 0; Size = 0;
HandleBuffer = &TempHandle; HandleBuffer = &TempHandle;
@ -562,11 +581,14 @@ ProcessPeims(
EFI_STRING StringPtr; EFI_STRING StringPtr;
UINTN LogEntryKey; UINTN LogEntryKey;
UINTN TIndex; UINTN TIndex;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION)); PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION));
PrintToken (STRING_TOKEN (STR_DP_DASHES)); PrintToken (STRING_TOKEN (STR_DP_DASHES));
@ -621,10 +643,14 @@ ProcessGlobal(
EFI_STRING StringPtr; EFI_STRING StringPtr;
UINTN LogEntryKey; UINTN LogEntryKey;
UINTN Index; // Index, or number, of the measurement record being processed UINTN Index; // Index, or number, of the measurement record being processed
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION)); PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION));
PrintToken (STRING_TOKEN (STR_DP_DASHES)); PrintToken (STRING_TOKEN (STR_DP_DASHES));
@ -680,11 +706,14 @@ ProcessCumulative(
UINT64 Avgval; // the computed average duration UINT64 Avgval; // the computed average duration
EFI_STRING StringPtr; EFI_STRING StringPtr;
UINTN TIndex; UINTN TIndex;
EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
(StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
FreePool (StringPtr);
FreePool (StringPtrUnknown);
PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1)); PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1));
PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2)); PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2));

View File

@ -206,6 +206,7 @@ GetNameFromHandle (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
StrCpy (mGaugeString, StringPtr); StrCpy (mGaugeString, StringPtr);
FreePool (StringPtr);
return ; return ;
} }
@ -225,6 +226,7 @@ GetNameFromHandle (
} else { } else {
StrCpy (mGaugeString, StringPtr); StrCpy (mGaugeString, StringPtr);
} }
FreePool (StringPtr);
return ; return ;
} }
@ -289,6 +291,7 @@ PrintToken (
if (Return > 0 && gST->ConOut != NULL) { if (Return > 0 && gST->ConOut != NULL) {
gST->ConOut->OutputString (gST->ConOut, mPrintTokenBuffer); gST->ConOut->OutputString (gST->ConOut, mPrintTokenBuffer);
} }
FreePool (StringPtr);
return Return; return Return;
} }

View File

@ -21,26 +21,3 @@ CHAR8 const ALit_PEI[] = PEI_TOK;
CHAR8 const ALit_BDS[] = BDS_TOK; CHAR8 const ALit_BDS[] = BDS_TOK;
CHAR8 const ALit_BdsTO[] = "BdsTimeOut"; CHAR8 const ALit_BdsTO[] = "BdsTimeOut";
CHAR8 const ALit_PEIM[] = "PEIM"; CHAR8 const ALit_PEIM[] = "PEIM";
/// UNICODE String literals which should probably be translated
CHAR16 STR_DP_OPTION_UA[] = L"-A";
CHAR16 STR_DP_OPTION_LA[] = L"-a";
CHAR16 STR_DP_OPTION_LN[] = L"-n";
CHAR16 STR_DP_OPTION_LT[] = L"-t";
CHAR16 STR_DP_OPTION_UP[] = L"-P";
CHAR16 STR_DP_OPTION_UR[] = L"-R";
CHAR16 STR_DP_OPTION_LS[] = L"-s";
CHAR16 STR_DP_OPTION_US[] = L"-S";
CHAR16 STR_DP_OPTION_UT[] = L"-T";
CHAR16 STR_DP_OPTION_LV[] = L"-v";
CHAR16 STR_DP_OPTION_QH[] = L"-?";
CHAR16 STR_DP_OPTION_LH[] = L"-h";
CHAR16 STR_DP_OPTION_UH[] = L"-H";
CHAR16 STR_DP_OPTION_LX[] = L"-x";
CHAR16 const ALit_UNKNOWN[] = L"Unknown";
CHAR16 const STR_DP_INCOMPLETE[] = L" I ";
CHAR16 const STR_DP_COMPLETE[] = L" ";
CHAR8 const ALit_TRUE[] = "TRUE";
CHAR8 const ALit_FALSE[] = "FALSE";

View File

@ -23,27 +23,4 @@ extern CHAR8 const ALit_BDS[];
extern CHAR8 const ALit_BdsTO[]; extern CHAR8 const ALit_BdsTO[];
extern CHAR8 const ALit_PEIM[]; extern CHAR8 const ALit_PEIM[];
/// UNICODE String literals which should probably be translated
extern CHAR16 STR_DP_OPTION_UA[];
extern CHAR16 STR_DP_OPTION_LA[];
extern CHAR16 STR_DP_OPTION_LN[];
extern CHAR16 STR_DP_OPTION_LT[];
extern CHAR16 STR_DP_OPTION_UP[];
extern CHAR16 STR_DP_OPTION_UR[];
extern CHAR16 STR_DP_OPTION_LS[];
extern CHAR16 STR_DP_OPTION_US[];
extern CHAR16 STR_DP_OPTION_UT[];
extern CHAR16 STR_DP_OPTION_LV[];
extern CHAR16 STR_DP_OPTION_QH[];
extern CHAR16 STR_DP_OPTION_LH[];
extern CHAR16 STR_DP_OPTION_UH[];
extern CHAR16 STR_DP_OPTION_LX[];
extern CHAR16 const ALit_UNKNOWN[];
extern CHAR16 const STR_DP_INCOMPLETE[];
extern CHAR16 const STR_DP_COMPLETE[];
extern CHAR8 const ALit_TRUE[];
extern CHAR8 const ALit_FALSE[];
#endif // _LITERALS_H_ #endif // _LITERALS_H_