summaryrefslogtreecommitdiff
path: root/ShellPkg/DynamicCommand
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:13 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commit47d20b54f9a65b08aa602a1866c1b59a69088dfc (patch)
treee3241dd169bda79544a36248e834a4bebe298418 /ShellPkg/DynamicCommand
parentc411b485b63a671a1e276700cff025c73997233c (diff)
downloadedk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.zip
edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.tar.gz
edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.tar.bz2
ShellPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ShellPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'ShellPkg/DynamicCommand')
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c766
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h82
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c9
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c29
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h79
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c645
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c149
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c24
-rw-r--r--ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h31
-rw-r--r--ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c479
-rw-r--r--ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h37
-rw-r--r--ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c10
-rw-r--r--ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c26
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c429
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h11
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c9
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c29
17 files changed, 1580 insertions, 1264 deletions
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index f7f3676..1799ab1 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -25,18 +25,18 @@
#pragma pack(1)
typedef struct {
- EFI_ACPI_DESCRIPTION_HEADER Header;
- UINT32 Entry;
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 Entry;
} RSDT_TABLE;
typedef struct {
- EFI_ACPI_DESCRIPTION_HEADER Header;
- UINT64 Entry;
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT64 Entry;
} XSDT_TABLE;
#pragma pack()
-EFI_HII_HANDLE mDpHiiHandle;
+EFI_HII_HANDLE mDpHiiHandle;
typedef struct {
EFI_HANDLE Handle;
@@ -49,21 +49,21 @@ UINTN mCachePairCount = 0;
//
/// Module-Global Variables
///@{
-CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
-CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
-UINT64 mInterestThreshold;
-BOOLEAN mShowId = FALSE;
-UINT8 *mBootPerformanceTable;
-UINTN mBootPerformanceTableSize;
-BOOLEAN mPeiPhase = FALSE;
-BOOLEAN mDxePhase = FALSE;
-
-PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the SummaryData structure and init. to ZERO.
+CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
+CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
+UINT64 mInterestThreshold;
+BOOLEAN mShowId = FALSE;
+UINT8 *mBootPerformanceTable;
+UINTN mBootPerformanceTableSize;
+BOOLEAN mPeiPhase = FALSE;
+BOOLEAN mDxePhase = FALSE;
+
+PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the SummaryData structure and init. to ZERO.
MEASUREMENT_RECORD *mMeasurementList = NULL;
-UINTN mMeasurementNum = 0;
+UINTN mMeasurementNum = 0;
/// Items for which to gather cumulative statistics.
-PERF_CUM_DATA CumData[] = {
+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),
@@ -72,20 +72,20 @@ PERF_CUM_DATA CumData[] = {
};
/// Number of items for which we are gathering cumulative statistics.
-UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-v", TypeFlag}, // -v Verbose Mode
- {L"-A", TypeFlag}, // -A All, Cooked
- {L"-R", TypeFlag}, // -R RAW All
- {L"-s", TypeFlag}, // -s Summary
- {L"-x", TypeFlag}, // -x eXclude Cumulative Items
- {L"-i", TypeFlag}, // -i Display Identifier
- {L"-c", TypeValue}, // -c Display cumulative data.
- {L"-n", TypeValue}, // -n # Number of records to display for A and R
- {L"-t", TypeValue}, // -t # Threshold of interest
- {NULL, TypeMax}
- };
+UINT32 const NumCum = sizeof (CumData) / sizeof (PERF_CUM_DATA);
+
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-v", TypeFlag }, // -v Verbose Mode
+ { L"-A", TypeFlag }, // -A All, Cooked
+ { L"-R", TypeFlag }, // -R RAW All
+ { L"-s", TypeFlag }, // -s Summary
+ { L"-x", TypeFlag }, // -x eXclude Cumulative Items
+ { L"-i", TypeFlag }, // -i Display Identifier
+ { L"-c", TypeValue }, // -c Display cumulative data.
+ { L"-n", TypeValue }, // -n # Number of records to display for A and R
+ { L"-t", TypeValue }, // -t # Threshold of interest
+ { NULL, TypeMax }
+};
///@}
@@ -93,20 +93,29 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
Display the trailing Verbose information.
**/
VOID
-DumpStatistics( void )
+DumpStatistics (
+ void
+ )
{
- EFI_STRING StringPtr;
- EFI_STRING StringPtrUnknown;
+ EFI_STRING StringPtr;
+ EFI_STRING StringPtrUnknown;
+
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle, SummaryData.NumTrace);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle, SummaryData.NumTrace);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary);
- 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), mDpHiiHandle, SummaryData.NumPEIMs);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle, SummaryData.NumGlobal);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary);
+ 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), mDpHiiHandle, SummaryData.NumPEIMs);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle, SummaryData.NumGlobal);
SHELL_FREE_NON_NULL (StringPtr);
SHELL_FREE_NON_NULL (StringPtrUnknown);
}
@@ -121,16 +130,16 @@ GetBootPerformanceTable (
{
FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable;
- FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *) EfiLocateFirstAcpiTable (
- EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
- );
+ FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *)EfiLocateFirstAcpiTable (
+ EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
+ );
if (FirmwarePerformanceTable == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle);
return EFI_NOT_FOUND;
}
- mBootPerformanceTable = (UINT8*) (UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
- mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *) mBootPerformanceTable)->Header.Length;
+ mBootPerformanceTable = (UINT8 *)(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
+ mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *)mBootPerformanceTable)->Header.Length;
return EFI_SUCCESS;
}
@@ -144,15 +153,16 @@ GetBootPerformanceTable (
**/
VOID
GetHandleFormModuleGuid (
- IN EFI_GUID *ModuleGuid,
- IN OUT EFI_HANDLE *Handle
+ IN EFI_GUID *ModuleGuid,
+ IN OUT EFI_HANDLE *Handle
)
{
- UINTN Index;
+ UINTN Index;
if (IsZeroGuid (ModuleGuid)) {
*Handle = NULL;
}
+
//
// Try to get the Handle from the cached array.
//
@@ -162,6 +172,7 @@ GetHandleFormModuleGuid (
break;
}
}
+
if (Index >= mCachePairCount) {
*Handle = NULL;
}
@@ -176,14 +187,14 @@ BuildCachedGuidHandleTable (
VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- UINTN Index;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- EFI_GUID *TempGuid;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ EFI_GUID *TempGuid;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) {
@@ -201,55 +212,58 @@ BuildCachedGuidHandleTable (
// Try Handle as ImageHandle.
//
Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiLoadedImageProtocolGuid,
- (VOID**) &LoadedImage
- );
+ HandleBuffer[Index],
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
if (EFI_ERROR (Status)) {
//
// Try Handle as Controller Handle
//
Status = gBS->OpenProtocol (
- HandleBuffer[Index],
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ HandleBuffer[Index],
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **)&DriverBinding,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
//
// Get Image protocol from ImageHandle
//
Status = gBS->HandleProtocol (
- DriverBinding->ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**) &LoadedImage
- );
+ DriverBinding->ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
}
}
- if (!EFI_ERROR (Status) && LoadedImage != NULL) {
+ if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
//
// Get Module Guid from DevicePath.
//
- if (LoadedImage->FilePath != NULL &&
- LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
- LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
- ) {
- FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedImage->FilePath;
- TempGuid = &FvFilePath->FvFileName;
+ if ((LoadedImage->FilePath != NULL) &&
+ (LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
+ (LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
+ )
+ {
+ FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath;
+ TempGuid = &FvFilePath->FvFileName;
mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index];
CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, TempGuid);
- mCachePairCount ++;
+ mCachePairCount++;
}
}
}
+
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
HandleBuffer = NULL;
}
+
return EFI_SUCCESS;
}
@@ -268,198 +282,209 @@ GetMeasurementInfo (
IN OUT MEASUREMENT_RECORD *Measurement
)
{
- VOID *ModuleGuid;
- EFI_HANDLE StartHandle;
+ VOID *ModuleGuid;
+ EFI_HANDLE StartHandle;
switch (RecordHeader->Type) {
- case FPDT_GUID_EVENT_TYPE:
- ModuleGuid = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);
- Measurement->Identifier = ((UINT32)((FPDT_GUID_EVENT_RECORD *)RecordHeader)->ProgressID);
- if (IsStart) {
- Measurement->StartTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
- } else {
- Measurement->EndTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
- }
- switch (Measurement->Identifier) {
- case MODULE_START_ID:
- case MODULE_END_ID:
- if (mPeiPhase) {
- Measurement->Token = ALit_PEIM;
- Measurement->Module = ALit_PEIM;
- } else if (mDxePhase) {
- Measurement->Token = ALit_START_IMAGE;
- Measurement->Module = ALit_START_IMAGE;
+ case FPDT_GUID_EVENT_TYPE:
+ ModuleGuid = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);
+ Measurement->Identifier = ((UINT32)((FPDT_GUID_EVENT_RECORD *)RecordHeader)->ProgressID);
+ if (IsStart) {
+ Measurement->StartTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
+ } else {
+ Measurement->EndTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
}
- break;
- default:
- ASSERT(FALSE);
- }
- if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
- Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
- } else {
- GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
- Measurement->Handle = StartHandle;
- //
- // When no perf entry to record the PEI and DXE phase,
- // For start image, we need detect the PEIM and non PEIM here.
- //
- if (Measurement->Token == NULL) {
- if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
- Measurement->Token = ALit_PEIM;
- Measurement->Module = ALit_PEIM;
- Measurement->Handle = ModuleGuid;
- } else {
- Measurement->Token = ALit_START_IMAGE;
- Measurement->Module = ALit_START_IMAGE;
- }
+ switch (Measurement->Identifier) {
+ case MODULE_START_ID:
+ case MODULE_END_ID:
+ if (mPeiPhase) {
+ Measurement->Token = ALit_PEIM;
+ Measurement->Module = ALit_PEIM;
+ } else if (mDxePhase) {
+ Measurement->Token = ALit_START_IMAGE;
+ Measurement->Module = ALit_START_IMAGE;
+ }
+
+ break;
+ default:
+ ASSERT (FALSE);
}
- }
- break;
- case FPDT_DYNAMIC_STRING_EVENT_TYPE:
- ModuleGuid = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
- Measurement->Identifier = ((UINT32)((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
- if (IsStart) {
- Measurement->StartTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
- } else {
- Measurement->EndTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
- }
- switch (Measurement->Identifier) {
- case MODULE_START_ID:
- case MODULE_END_ID:
- if (mPeiPhase) {
- Measurement->Token = ALit_PEIM;
- } else if (mDxePhase) {
- Measurement->Token = ALit_START_IMAGE;
+ if ((Measurement->Token != NULL) && (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0)) {
+ Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
+ } else {
+ GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
+ Measurement->Handle = StartHandle;
+ //
+ // When no perf entry to record the PEI and DXE phase,
+ // For start image, we need detect the PEIM and non PEIM here.
+ //
+ if (Measurement->Token == NULL) {
+ if ((StartHandle == NULL) && !IsZeroGuid (ModuleGuid)) {
+ Measurement->Token = ALit_PEIM;
+ Measurement->Module = ALit_PEIM;
+ Measurement->Handle = ModuleGuid;
+ } else {
+ Measurement->Token = ALit_START_IMAGE;
+ Measurement->Module = ALit_START_IMAGE;
+ }
+ }
}
- break;
- case MODULE_LOADIMAGE_START_ID:
- case MODULE_LOADIMAGE_END_ID:
- Measurement->Token = ALit_LOAD_IMAGE;
break;
- case MODULE_DB_START_ID:
- case MODULE_DB_END_ID:
- Measurement->Token = ALit_DB_START;
- break;
+ case FPDT_DYNAMIC_STRING_EVENT_TYPE:
+ ModuleGuid = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
+ Measurement->Identifier = ((UINT32)((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+ if (IsStart) {
+ Measurement->StartTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
+ } else {
+ Measurement->EndTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
+ }
- case MODULE_DB_SUPPORT_START_ID:
- case MODULE_DB_SUPPORT_END_ID:
- Measurement->Token = ALit_DB_SUPPORT;
- break;
+ switch (Measurement->Identifier) {
+ case MODULE_START_ID:
+ case MODULE_END_ID:
+ if (mPeiPhase) {
+ Measurement->Token = ALit_PEIM;
+ } else if (mDxePhase) {
+ Measurement->Token = ALit_START_IMAGE;
+ }
+
+ break;
+
+ case MODULE_LOADIMAGE_START_ID:
+ case MODULE_LOADIMAGE_END_ID:
+ Measurement->Token = ALit_LOAD_IMAGE;
+ break;
+
+ case MODULE_DB_START_ID:
+ case MODULE_DB_END_ID:
+ Measurement->Token = ALit_DB_START;
+ break;
+
+ case MODULE_DB_SUPPORT_START_ID:
+ case MODULE_DB_SUPPORT_END_ID:
+ Measurement->Token = ALit_DB_SUPPORT;
+ break;
+
+ case MODULE_DB_STOP_START_ID:
+ case MODULE_DB_STOP_END_ID:
+ Measurement->Token = ALit_DB_STOP;
+ break;
+
+ default:
+ Measurement->Token = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
+ break;
+ }
- case MODULE_DB_STOP_START_ID:
- case MODULE_DB_STOP_END_ID:
- Measurement->Token = ALit_DB_STOP;
- break;
+ Measurement->Module = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
+
+ if ((Measurement->Token != NULL) && (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0)) {
+ Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
+ } else {
+ GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
+ Measurement->Handle = StartHandle;
+ //
+ // When no perf entry to record the PEI and DXE phase,
+ // For start image, we need detect the PEIM and non PEIM here.
+ //
+ if ((Measurement->Token == NULL) && ((Measurement->Identifier == MODULE_START_ID) || (Measurement->Identifier == MODULE_END_ID))) {
+ if ((StartHandle == NULL) && !IsZeroGuid (ModuleGuid)) {
+ Measurement->Token = ALit_PEIM;
+ Measurement->Handle = ModuleGuid;
+ } else {
+ Measurement->Token = ALit_START_IMAGE;
+ }
+ }
+ }
- default:
- Measurement->Token = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
break;
- }
- Measurement->Module = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
+ case FPDT_GUID_QWORD_EVENT_TYPE:
+ ModuleGuid = &(((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Guid);
+ Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->ProgressID);
+ if (IsStart) {
+ Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
+ } else {
+ Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
+ }
- if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
- Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
- } else {
- GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
+ switch (Measurement->Identifier) {
+ case MODULE_DB_START_ID:
+ Measurement->Token = ALit_DB_START;
+ Measurement->Module = ALit_DB_START;
+ break;
+
+ case MODULE_DB_SUPPORT_START_ID:
+ case MODULE_DB_SUPPORT_END_ID:
+ Measurement->Token = ALit_DB_SUPPORT;
+ Measurement->Module = ALit_DB_SUPPORT;
+ break;
+
+ case MODULE_DB_STOP_START_ID:
+ case MODULE_DB_STOP_END_ID:
+ Measurement->Token = ALit_DB_STOP;
+ Measurement->Module = ALit_DB_STOP;
+ break;
+
+ case MODULE_LOADIMAGE_START_ID:
+ case MODULE_LOADIMAGE_END_ID:
+ Measurement->Token = ALit_LOAD_IMAGE;
+ Measurement->Module = ALit_LOAD_IMAGE;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ }
+
+ GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle;
+ break;
+
+ case FPDT_GUID_QWORD_STRING_EVENT_TYPE:
+ ModuleGuid = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Guid);
+ Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+ if (IsStart) {
+ Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
+ } else {
+ Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
+ }
+
//
- // When no perf entry to record the PEI and DXE phase,
- // For start image, we need detect the PEIM and non PEIM here.
+ // Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE.
//
- if (Measurement->Token == NULL && (Measurement->Identifier == MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {
- if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
- Measurement->Token = ALit_PEIM;
- Measurement->Handle = ModuleGuid;
- } else {
- Measurement->Token = ALit_START_IMAGE;
- }
+ switch (Measurement->Identifier) {
+ case MODULE_DB_END_ID:
+ Measurement->Token = ALit_DB_START;
+ Measurement->Module = ALit_DB_START;
+ break;
+ default:
+ ASSERT (FALSE);
}
- }
- break;
- case FPDT_GUID_QWORD_EVENT_TYPE:
- ModuleGuid = &(((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Guid);
- Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->ProgressID);
- if (IsStart) {
- Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
- } else {
- Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
- }
- switch (Measurement->Identifier) {
- case MODULE_DB_START_ID:
- Measurement->Token = ALit_DB_START;
- Measurement->Module = ALit_DB_START;
- break;
-
- case MODULE_DB_SUPPORT_START_ID:
- case MODULE_DB_SUPPORT_END_ID:
- Measurement->Token = ALit_DB_SUPPORT;
- Measurement->Module = ALit_DB_SUPPORT;
+ GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
+ Measurement->Handle = StartHandle;
break;
- case MODULE_DB_STOP_START_ID:
- case MODULE_DB_STOP_END_ID:
- Measurement->Token = ALit_DB_STOP;
- Measurement->Module = ALit_DB_STOP;
- break;
+ case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
+ ModuleGuid = &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Guid1);
+ Measurement->Identifier = ((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
+ if (IsStart) {
+ Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
+ } else {
+ Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
+ }
- case MODULE_LOADIMAGE_START_ID:
- case MODULE_LOADIMAGE_END_ID:
- Measurement->Token = ALit_LOAD_IMAGE;
- Measurement->Module = ALit_LOAD_IMAGE;
+ Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
+ Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
+ GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
+ Measurement->Handle = StartHandle;
break;
default:
- ASSERT(FALSE);
- }
- GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
- Measurement->Handle = StartHandle;
- break;
-
- case FPDT_GUID_QWORD_STRING_EVENT_TYPE:
- ModuleGuid = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Guid);
- Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
- if (IsStart) {
- Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD*)RecordHeader)->Timestamp;
- } else {
- Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
- }
- //
- // Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE.
- //
- switch (Measurement->Identifier) {
- case MODULE_DB_END_ID:
- Measurement->Token = ALit_DB_START;
- Measurement->Module = ALit_DB_START;
break;
- default:
- ASSERT(FALSE);
- }
- GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
- Measurement->Handle = StartHandle;
- break;
-
- case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
- ModuleGuid = &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Guid1);
- Measurement->Identifier = ((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
- if (IsStart) {
- Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
- } else {
- Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
- }
- Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
- Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
- GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
- Measurement->Handle = StartHandle;
- break;
-
- default:
- break;
}
}
@@ -471,32 +496,35 @@ GetMeasurementInfo (
**/
VOID
SearchMeasurement (
- IN MEASUREMENT_RECORD *EndMeasureMent
+ IN MEASUREMENT_RECORD *EndMeasureMent
)
{
- INTN Index;
+ INTN Index;
for (Index = mMeasurementNum - 1; Index >= 0; Index--) {
if (AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) {
- if (mMeasurementList[Index].EndTimeStamp == 0 && EndMeasureMent->Handle!= NULL && mMeasurementList[Index].Handle != NULL&&
- CompareGuid(mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&
+ if ((mMeasurementList[Index].EndTimeStamp == 0) && (EndMeasureMent->Handle != NULL) && (mMeasurementList[Index].Handle != NULL) &&
+ CompareGuid (mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
- (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {
+ (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0))
+ {
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break;
}
} else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {
- if (mMeasurementList[Index].EndTimeStamp == 0 &&
- (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
- (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0) &&
- mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID) {
+ if ((mMeasurementList[Index].EndTimeStamp == 0) &&
+ (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
+ (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0) &&
+ (mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID))
+ {
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break;
}
} else {
- if (mMeasurementList[Index].EndTimeStamp == 0 && mMeasurementList[Index].Handle == EndMeasureMent->Handle &&
- (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
- (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {
+ if ((mMeasurementList[Index].EndTimeStamp == 0) && (mMeasurementList[Index].Handle == EndMeasureMent->Handle) &&
+ (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
+ (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0))
+ {
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break;
}
@@ -528,9 +556,9 @@ BuildMeasurementList (
PerformanceTablePtr = (mBootPerformanceTable + TableLength);
while (TableLength < mBootPerformanceTableSize) {
- RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) PerformanceTablePtr;
- StartRecordEvent = (UINT8 *)RecordHeader;
- StartProgressId = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;
+ RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)PerformanceTablePtr;
+ StartRecordEvent = (UINT8 *)RecordHeader;
+ StartProgressId = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;
//
// If the record with ProgressId 0, the record doesn't appear in pairs. The timestamp in the record is the EndTimeStamp, its StartTimeStamp is 0.
@@ -539,14 +567,15 @@ BuildMeasurementList (
//
if (StartProgressId == 0) {
GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum]));
- mMeasurementNum ++;
- } else if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||
- (StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) {
+ mMeasurementNum++;
+ } else if ((((StartProgressId >= PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x000F) == 0)) ||
+ ((StartProgressId < PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x0001) != 0))))
+ {
//
// Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE
// So we need to identify these two kinds of record through different phase.
//
- if(StartProgressId == PERF_CROSSMODULE_START_ID ){
+ if (StartProgressId == PERF_CROSSMODULE_START_ID ) {
if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {
mPeiPhase = TRUE;
} else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {
@@ -554,17 +583,20 @@ BuildMeasurementList (
mPeiPhase = FALSE;
}
}
+
// Get measurement info form the start record to the mMeasurementList.
GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));
- mMeasurementNum ++;
+ mMeasurementNum++;
} else {
- ZeroMem(&MeasureMent, sizeof(MEASUREMENT_RECORD));
+ ZeroMem (&MeasureMent, sizeof (MEASUREMENT_RECORD));
GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);
SearchMeasurement (&MeasureMent);
}
+
TableLength += RecordHeader->Length;
PerformanceTablePtr += RecordHeader->Length;
}
+
return EFI_SUCCESS;
}
@@ -577,12 +609,12 @@ InitCumulativeData (
VOID
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < NumCum; ++Index) {
- CumData[Index].Count = 0;
- CumData[Index].MinDur = PERF_MAXDUR;
- CumData[Index].MaxDur = 0;
+ CumData[Index].Count = 0;
+ CumData[Index].MinDur = PERF_MAXDUR;
+ CumData[Index].MaxDur = 0;
CumData[Index].Duration = 0;
}
}
@@ -617,55 +649,55 @@ InitSummaryData (
**/
SHELL_STATUS
RunDp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *CmdLineArg;
- EFI_STATUS Status;
-
- PERFORMANCE_PROPERTY *PerformanceProperty;
- UINTN Number2Display;
-
- EFI_STRING StringPtr;
- BOOLEAN SummaryMode;
- BOOLEAN VerboseMode;
- BOOLEAN AllMode;
- BOOLEAN RawMode;
- BOOLEAN ExcludeMode;
- BOOLEAN CumulativeMode;
- CONST CHAR16 *CustomCumulativeToken;
- PERF_CUM_DATA *CustomCumulativeData;
- UINTN NameSize;
- SHELL_STATUS ShellStatus;
- TIMER_INFO TimerInfo;
- UINT64 Intermediate;
-
- StringPtr = NULL;
- SummaryMode = FALSE;
- VerboseMode = FALSE;
- AllMode = FALSE;
- RawMode = FALSE;
- ExcludeMode = FALSE;
- CumulativeMode = FALSE;
+ LIST_ENTRY *ParamPackage;
+ CONST CHAR16 *CmdLineArg;
+ EFI_STATUS Status;
+
+ PERFORMANCE_PROPERTY *PerformanceProperty;
+ UINTN Number2Display;
+
+ EFI_STRING StringPtr;
+ BOOLEAN SummaryMode;
+ BOOLEAN VerboseMode;
+ BOOLEAN AllMode;
+ BOOLEAN RawMode;
+ BOOLEAN ExcludeMode;
+ BOOLEAN CumulativeMode;
+ CONST CHAR16 *CustomCumulativeToken;
+ PERF_CUM_DATA *CustomCumulativeData;
+ UINTN NameSize;
+ SHELL_STATUS ShellStatus;
+ TIMER_INFO TimerInfo;
+ UINT64 Intermediate;
+
+ StringPtr = NULL;
+ SummaryMode = FALSE;
+ VerboseMode = FALSE;
+ AllMode = FALSE;
+ RawMode = FALSE;
+ ExcludeMode = FALSE;
+ CumulativeMode = FALSE;
CustomCumulativeData = NULL;
- ShellStatus = SHELL_SUCCESS;
+ ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// Process Command Line arguments
//
Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);
return SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(ParamPackage) > 1){
+ } else if (ShellCommandLineGetCount (ParamPackage) > 1) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_MANY), mDpHiiHandle);
return SHELL_INVALID_PARAMETER;
}
@@ -673,12 +705,12 @@ RunDp (
//
// Boolean options
//
- VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
- SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));
- AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A");
- RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R");
- ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
- mShowId = ShellCommandLineGetFlag (ParamPackage, L"-i");
+ VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
+ SummaryMode = (BOOLEAN)(ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));
+ AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A");
+ RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R");
+ ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
+ mShowId = ShellCommandLineGetFlag (ParamPackage, L"-i");
CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");
if (AllMode && RawMode) {
@@ -688,7 +720,7 @@ RunDp (
// Options with Values
if (ShellCommandLineGetFlag (ParamPackage, L"-n")) {
- CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-n");
+ CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-n");
if (CmdLineArg == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);
return SHELL_INVALID_PARAMETER;
@@ -697,13 +729,14 @@ RunDp (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), mDpHiiHandle);
return SHELL_INVALID_PARAMETER;
}
- Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);
+
+ Status = ShellConvertStringToUint64 (CmdLineArg, &Intermediate, FALSE, TRUE);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-n");
return SHELL_INVALID_PARAMETER;
} else {
Number2Display = (UINTN)Intermediate;
- if (Number2Display == 0 || Number2Display > MAXIMUM_DISPLAYCOUNT) {
+ if ((Number2Display == 0) || (Number2Display > MAXIMUM_DISPLAYCOUNT)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_RANGE), mDpHiiHandle, L"-n", 0, MAXIMUM_DISPLAYCOUNT);
return SHELL_INVALID_PARAMETER;
}
@@ -714,12 +747,12 @@ RunDp (
}
if (ShellCommandLineGetFlag (ParamPackage, L"-t")) {
- CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-t");
+ CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-t");
if (CmdLineArg == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);
return SHELL_INVALID_PARAMETER;
} else {
- Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);
+ Status = ShellConvertStringToUint64 (CmdLineArg, &Intermediate, FALSE, TRUE);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-t");
return SHELL_INVALID_PARAMETER;
@@ -742,16 +775,18 @@ RunDp (
ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Done;
}
- CustomCumulativeData->MinDur = PERF_MAXDUR;
- CustomCumulativeData->MaxDur = 0;
- CustomCumulativeData->Count = 0;
+
+ CustomCumulativeData->MinDur = PERF_MAXDUR;
+ CustomCumulativeData->MaxDur = 0;
+ CustomCumulativeData->Count = 0;
CustomCumulativeData->Duration = 0;
- NameSize = StrLen (CustomCumulativeToken) + 1;
- CustomCumulativeData->Name = AllocateZeroPool (NameSize);
+ NameSize = StrLen (CustomCumulativeToken) + 1;
+ CustomCumulativeData->Name = AllocateZeroPool (NameSize);
if (CustomCumulativeData->Name == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Done;
}
+
UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
}
}
@@ -762,7 +797,7 @@ RunDp (
//
//
- //1. Get FPDT from ACPI table.
+ // 1. Get FPDT from ACPI table.
//
Status = GetBootPerformanceTable ();
if (EFI_ERROR (Status)) {
@@ -771,16 +806,16 @@ RunDp (
}
//
- //2. Cache the ModuleGuid and hanlde mapping table.
+ // 2. Cache the ModuleGuid and hanlde mapping table.
//
- Status = BuildCachedGuidHandleTable();
+ Status = BuildCachedGuidHandleTable ();
if (EFI_ERROR (Status)) {
ShellStatus = Status;
goto Done;
}
//
- //3. Build the measurement array form the FPDT records.
+ // 3. Build the measurement array form the FPDT records.
//
Status = BuildMeasurementList ();
if (EFI_ERROR (Status)) {
@@ -806,7 +841,7 @@ RunDp (
// StartCount = Value loaded into the counter when it starts counting
// EndCount = Value counter counts to before it needs to be reset
//
- Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
+ Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **)&PerformanceProperty);
if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);
goto Done;
@@ -815,7 +850,7 @@ RunDp (
TimerInfo.Frequency = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 1000);
TimerInfo.StartCount = 0;
TimerInfo.EndCount = 0xFFFF;
- TimerInfo.CountUp = TRUE;
+ TimerInfo.CountUp = TRUE;
//
// Print header
@@ -827,52 +862,60 @@ RunDp (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);
if (VerboseMode && !RawMode) {
- StringPtr = HiiGetString (mDpHiiHandle,
- (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
+ StringPtr = HiiGetString (
+ mDpHiiHandle,
+ (EFI_STRING_ID)(TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)),
+ NULL
+ );
ASSERT (StringPtr != NULL);
// Print Timer count range and direction
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,
- StringPtr,
- TimerInfo.StartCount,
- TimerInfo.EndCount
- );
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_TIMER_PROPERTIES),
+ mDpHiiHandle,
+ StringPtr,
+ TimerInfo.StartCount,
+ TimerInfo.EndCount
+ );
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, 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)
-****************************************************************************/
+ /****************************************************************************
+ **** 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)
+ ****************************************************************************/
GatherStatistics (CustomCumulativeData);
if (CumulativeMode) {
ProcessCumulative (CustomCumulativeData);
} else if (AllMode) {
- Status = DumpAllTrace( Number2Display, ExcludeMode);
+ Status = DumpAllTrace (Number2Display, ExcludeMode);
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
}
} else if (RawMode) {
- Status = DumpRawTrace( Number2Display, ExcludeMode);
+ Status = DumpRawTrace (Number2Display, ExcludeMode);
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
}
} else {
- //------------- Begin Cooked Mode Processing
+ // ------------- Begin Cooked Mode Processing
ProcessPhases ();
- if ( ! SummaryMode) {
- Status = ProcessHandles ( ExcludeMode);
+ if ( !SummaryMode) {
+ Status = ProcessHandles (ExcludeMode);
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
@@ -890,21 +933,24 @@ RunDp (
goto Done;
}
- ProcessCumulative (NULL);
+ ProcessCumulative (NULL);
}
- } //------------- End of Cooked Mode Processing
+ } // ------------- End of Cooked Mode Processing
+
if ( VerboseMode || SummaryMode) {
- DumpStatistics();
+ DumpStatistics ();
}
Done:
if (ParamPackage != NULL) {
ShellCommandLineFreeVarList (ParamPackage);
}
+
SHELL_FREE_NON_NULL (StringPtr);
if (CustomCumulativeData != NULL) {
SHELL_FREE_NON_NULL (CustomCumulativeData->Name);
}
+
SHELL_FREE_NON_NULL (CustomCumulativeData);
SHELL_FREE_NON_NULL (mMeasurementList);
@@ -916,7 +962,6 @@ Done:
return ShellStatus;
}
-
/**
Retrieve HII package list from ImageHandle and publish to HII database.
@@ -926,12 +971,12 @@ Done:
**/
EFI_HII_HANDLE
InitializeHiiPackage (
- EFI_HANDLE ImageHandle
+ EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_HII_HANDLE HiiHandle;
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+ EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
@@ -962,5 +1007,6 @@ InitializeHiiPackage (
if (EFI_ERROR (Status)) {
return NULL;
}
+
return HiiHandle;
}
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
index 84fe0b5..ee09ca4 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
@@ -9,7 +9,6 @@
#ifndef _DP_H_
#define _DP_H_
-
#include <Uefi.h>
#include <Guid/Performance.h>
@@ -36,32 +35,32 @@
#include <Library/UefiHiiServicesLib.h>
#include <Library/PerformanceLib.h>
-extern EFI_HII_HANDLE mDpHiiHandle;
+extern EFI_HII_HANDLE mDpHiiHandle;
-#define DP_MAJOR_VERSION 2
-#define DP_MINOR_VERSION 5
+#define DP_MAJOR_VERSION 2
+#define DP_MINOR_VERSION 5
/**
* The value assigned to DP_DEBUG controls which debug output
* is generated. Set it to ZERO to disable.
**/
-#define DP_DEBUG 0
+#define DP_DEBUG 0
-#define DEFAULT_THRESHOLD 1000 ///< One millisecond.
-#define DEFAULT_DISPLAYCOUNT 50
-#define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
+#define DEFAULT_THRESHOLD 1000 ///< One millisecond.
+#define DEFAULT_DISPLAYCOUNT 50
+#define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
-#define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
+#define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
/// Determine whether 0 <= C < L. If L == 0, return true regardless of C.
-#define WITHIN_LIMIT( C, L) ( ((L) == 0) || ((C) < (L)) )
+#define WITHIN_LIMIT(C, L) ( ((L) == 0) || ((C) < (L)) )
/// Structure for storing Timer specific information.
typedef struct {
- UINT64 StartCount; ///< Value timer is initialized with.
- UINT64 EndCount; ///< Value timer has just before it wraps.
- UINT32 Frequency; ///< Timer count frequency in KHz.
- BOOLEAN CountUp; ///< TRUE if the counter counts up.
+ UINT64 StartCount; ///< Value timer is initialized with.
+ UINT64 EndCount; ///< Value timer has just before it wraps.
+ UINT32 Frequency; ///< Timer count frequency in KHz.
+ BOOLEAN CountUp; ///< TRUE if the counter counts up.
} TIMER_INFO;
/** Initialize one PERF_CUM_DATA structure instance for token t.
@@ -73,40 +72,40 @@ typedef struct {
* - PERF_INIT_CUM_DATA(pointer) A pointer -- CHAR8 *pointer;
* - PERF_INIT_CUM_DATA(array) Address of an array -- CHAR8 array[N];
**/
-#define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
+#define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
typedef struct {
- UINT64 Duration; ///< Cumulative duration for this item.
- UINT64 MinDur; ///< Smallest duration encountered.
- UINT64 MaxDur; ///< Largest duration encountered.
- CHAR8 *Name; ///< ASCII name of this item.
- UINT32 Count; ///< Total number of measurements accumulated.
+ UINT64 Duration; ///< Cumulative duration for this item.
+ UINT64 MinDur; ///< Smallest duration encountered.
+ UINT64 MaxDur; ///< Largest duration encountered.
+ CHAR8 *Name; ///< ASCII name of this item.
+ UINT32 Count; ///< Total number of measurements accumulated.
} PERF_CUM_DATA;
typedef struct {
- UINT32 NumTrace; ///< Number of recorded TRACE performance measurements.
- UINT32 NumIncomplete; ///< Number of measurements with no END value.
- UINT32 NumSummary; ///< Number of summary section measurements.
- UINT32 NumHandles; ///< Number of measurements with handles.
- UINT32 NumPEIMs; ///< Number of measurements of PEIMs.
- UINT32 NumGlobal; ///< Number of measurements with END value and NULL handle.
+ UINT32 NumTrace; ///< Number of recorded TRACE performance measurements.
+ UINT32 NumIncomplete; ///< Number of measurements with no END value.
+ UINT32 NumSummary; ///< Number of summary section measurements.
+ UINT32 NumHandles; ///< Number of measurements with handles.
+ UINT32 NumPEIMs; ///< Number of measurements of PEIMs.
+ UINT32 NumGlobal; ///< Number of measurements with END value and NULL handle.
} PERF_SUMMARY_DATA;
typedef struct {
- CONST VOID *Handle;
- CONST CHAR8 *Token; ///< Measured token string name.
- CONST CHAR8 *Module; ///< Module string name.
- UINT64 StartTimeStamp; ///< Start time point.
- UINT64 EndTimeStamp; ///< End time point.
- UINT32 Identifier; ///< Identifier.
+ CONST VOID *Handle;
+ CONST CHAR8 *Token; ///< Measured token string name.
+ CONST CHAR8 *Module; ///< Module string name.
+ UINT64 StartTimeStamp; ///< Start time point.
+ UINT64 EndTimeStamp; ///< End time point.
+ UINT32 Identifier; ///< Identifier.
} MEASUREMENT_RECORD;
typedef struct {
- CHAR8 *Name; ///< Measured token string name.
- UINT64 CumulativeTime; ///< Accumulated Elapsed Time.
- UINT64 MinTime; ///< Minimum Elapsed Time.
- UINT64 MaxTime; ///< Maximum Elapsed Time.
- UINT32 Count; ///< Number of measurements accumulated.
+ CHAR8 *Name; ///< Measured token string name.
+ UINT64 CumulativeTime; ///< Accumulated Elapsed Time.
+ UINT64 MinTime; ///< Minimum Elapsed Time.
+ UINT64 MaxTime; ///< Maximum Elapsed Time.
+ UINT32 Count; ///< Number of measurements accumulated.
} PROFILE_RECORD;
/**
@@ -122,8 +121,8 @@ typedef struct {
**/
SHELL_STATUS
RunDp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@@ -135,6 +134,7 @@ RunDp (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
- EFI_HANDLE ImageHandle
+ EFI_HANDLE ImageHandle
);
-#endif // _DP_H_
+
+#endif // _DP_H_
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
index b4b242a..f148583 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
@@ -16,7 +16,7 @@
// 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);
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_DP);
/**
Entry point of Tftp standalone application.
@@ -31,11 +31,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (S
EFI_STATUS
EFIAPI
DpAppInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) {
return EFI_ABORTED;
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
index 50fcc6e..e4ee4cc 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
@@ -25,10 +25,10 @@
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
+ 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;
@@ -49,14 +49,14 @@ DpCommandHandler (
CHAR16 *
EFIAPI
DpCommandGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
+ 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 = {
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
L"dp",
DpCommandHandler,
DpCommandGetHelp
@@ -77,11 +77,12 @@ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
EFI_STATUS
EFIAPI
DpCommandInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) {
return EFI_ABORTED;
@@ -108,10 +109,11 @@ DpCommandInitialize (
EFI_STATUS
EFIAPI
DpUnload (
- IN EFI_HANDLE ImageHandle
-)
+ IN EFI_HANDLE ImageHandle
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
Status = gBS->UninstallProtocolInterface (
ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
@@ -120,6 +122,7 @@ DpUnload (
if (EFI_ERROR (Status)) {
return Status;
}
+
HiiRemovePackages (mDpHiiHandle);
return EFI_SUCCESS;
}
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
index 75a3dba..39878c6 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
@@ -10,31 +10,32 @@
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef _DP_INTELNAL_H_
#define _DP_INTELNAL_H_
-#define DP_GAUGE_STRING_LENGTH 36
+#define DP_GAUGE_STRING_LENGTH 36
//
/// Module-Global Variables
///@{
-extern EFI_HII_HANDLE mDpHiiHandle;
-extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
-extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
-extern UINT64 mInterestThreshold;
-extern BOOLEAN mShowId;
-extern UINT8 *mBootPerformanceTable;
-extern UINTN mBootPerformanceTableLength;
-extern MEASUREMENT_RECORD *mMeasurementList;
-extern UINTN mMeasurementNum;
+extern EFI_HII_HANDLE mDpHiiHandle;
+extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
+extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
+extern UINT64 mInterestThreshold;
+extern BOOLEAN mShowId;
+extern UINT8 *mBootPerformanceTable;
+extern UINTN mBootPerformanceTableLength;
+extern MEASUREMENT_RECORD *mMeasurementList;
+extern UINTN mMeasurementNum;
extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO.
/// Items for which to gather cumulative statistics.
-extern PERF_CUM_DATA CumData[];
+extern PERF_CUM_DATA CumData[];
/// Number of items for which we are gathering cumulative statistics.
-extern UINT32 const NumCum;
+extern UINT32 const NumCum;
///@}
@@ -60,7 +61,7 @@ extern UINT32 const NumCum;
**/
UINT64
GetDuration (
- IN OUT MEASUREMENT_RECORD *Measurement
+ IN OUT MEASUREMENT_RECORD *Measurement
);
/**
@@ -75,8 +76,8 @@ GetDuration (
@retval FALSE The measurement record is NOT for an EFI Phase.
**/
BOOLEAN
-IsPhase(
- IN MEASUREMENT_RECORD *Measurement
+IsPhase (
+ IN MEASUREMENT_RECORD *Measurement
);
/**
@@ -89,8 +90,8 @@ IsPhase(
**/
BOOLEAN
-IsCorePerf(
- IN MEASUREMENT_RECORD *Measurement
+IsCorePerf (
+ IN MEASUREMENT_RECORD *Measurement
);
/**
@@ -107,8 +108,8 @@ IsCorePerf(
**/
VOID
DpGetShortPdbFileName (
- IN CHAR8 *PdbFileName,
- OUT CHAR16 *UnicodeBuffer
+ IN CHAR8 *PdbFileName,
+ OUT CHAR16 *UnicodeBuffer
);
/**
@@ -129,7 +130,7 @@ DpGetShortPdbFileName (
**/
VOID
DpGetNameFromHandle (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
);
/**
@@ -147,7 +148,7 @@ DpGetNameFromHandle (
**/
UINT64
DurationInMicroSeconds (
- IN UINT64 Duration
+ IN UINT64 Duration
);
/**
@@ -164,8 +165,8 @@ DurationInMicroSeconds (
@retval >=0 Return value is the index into CumData where Token is found.
**/
INTN
-GetCumulativeItem(
- IN MEASUREMENT_RECORD *Measurement
+GetCumulativeItem (
+ IN MEASUREMENT_RECORD *Measurement
);
/**
@@ -186,8 +187,8 @@ GetCumulativeItem(
**/
VOID
-GatherStatistics(
- IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
+GatherStatistics (
+ IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
);
/**
@@ -212,9 +213,9 @@ GatherStatistics(
@return Others from a call to gBS->LocateHandleBuffer().
**/
EFI_STATUS
-DumpAllTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
+DumpAllTrace (
+ IN UINTN Limit,
+ IN BOOLEAN ExcludeFlag
);
/**
@@ -237,9 +238,9 @@ DumpAllTrace(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
-DumpRawTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
+DumpRawTrace (
+ IN UINTN Limit,
+ IN BOOLEAN ExcludeFlag
);
/**
@@ -247,11 +248,10 @@ DumpRawTrace(
**/
VOID
-ProcessPhases(
+ProcessPhases (
VOID
);
-
/**
Gather and print Handle data.
@@ -262,11 +262,10 @@ ProcessPhases(
@return Others from a call to gBS->LocateHandleBuffer().
**/
EFI_STATUS
-ProcessHandles(
- IN BOOLEAN ExcludeFlag
+ProcessHandles (
+ IN BOOLEAN ExcludeFlag
);
-
/**
Gather and print PEIM data.
@@ -276,7 +275,7 @@ ProcessHandles(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
-ProcessPeims(
+ProcessPeims (
VOID
);
@@ -292,7 +291,7 @@ ProcessPeims(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
-ProcessGlobal(
+ProcessGlobal (
VOID
);
@@ -308,8 +307,8 @@ ProcessGlobal(
**/
VOID
-ProcessCumulative(
- IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
+ProcessCumulative (
+ IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
);
#endif
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
index 1a247d4..0abb879 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
@@ -46,27 +46,27 @@
**/
UINTN
GetPerformanceMeasurementRecord (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp,
- OUT UINT32 *Identifier
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
if (LogEntryKey == mMeasurementNum) {
return 0;
}
- *Handle = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle;
+ *Handle = (VOID *)(UINTN)mMeasurementList[LogEntryKey].Handle;
*Token = mMeasurementList[LogEntryKey].Token;
*Module = mMeasurementList[LogEntryKey].Module;
*StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;
*EndTimeStamp = mMeasurementList[LogEntryKey].EndTimeStamp;
*Identifier = mMeasurementList[LogEntryKey].Identifier;
- LogEntryKey ++;
+ LogEntryKey++;
return LogEntryKey;
}
@@ -89,24 +89,25 @@ GetPerformanceMeasurementRecord (
**/
VOID
-GatherStatistics(
- IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
+GatherStatistics (
+ IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
)
{
- MEASUREMENT_RECORD Measurement;
- UINT64 Duration;
- UINTN LogEntryKey;
- INTN TIndex;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 Duration;
+ UINTN LogEntryKey;
+ INTN TIndex;
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementRecord (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
+ LogEntryKey,
+ &Measurement.Handle,
+ &Measurement.Token,
+ &Measurement.Module,
+ &Measurement.StartTimeStamp,
+ &Measurement.EndTimeStamp,
+ &Measurement.Identifier
+ )) != 0)
{
++SummaryData.NumTrace; // Count the number of TRACE Measurement records
if (Measurement.EndTimeStamp == 0) {
@@ -118,11 +119,11 @@ GatherStatistics(
++SummaryData.NumHandles; // Count the number of measurements with non-NULL handles
}
- if (IsPhase( &Measurement)) {
+ if (IsPhase (&Measurement)) {
++SummaryData.NumSummary; // Count the number of major phases
- }
- else { // !IsPhase
- if(Measurement.Handle == NULL) {
+ } else {
+ // !IsPhase
+ if (Measurement.Handle == NULL) {
++SummaryData.NumGlobal;
}
}
@@ -132,13 +133,14 @@ GatherStatistics(
}
Duration = GetDuration (&Measurement);
- TIndex = GetCumulativeItem (&Measurement);
+ TIndex = GetCumulativeItem (&Measurement);
if (TIndex >= 0) {
CumData[TIndex].Duration += Duration;
CumData[TIndex].Count++;
if ( Duration < CumData[TIndex].MinDur ) {
CumData[TIndex].MinDur = Duration;
}
+
if ( Duration > CumData[TIndex].MaxDur ) {
CumData[TIndex].MaxDur = Duration;
}
@@ -153,6 +155,7 @@ GatherStatistics(
if (Duration < CustomCumulativeData->MinDur) {
CustomCumulativeData->MinDur = Duration;
}
+
if (Duration > CustomCumulativeData->MaxDur) {
CustomCumulativeData->MaxDur = Duration;
}
@@ -182,38 +185,43 @@ GatherStatistics(
@return Others from a call to gBS->LocateHandleBuffer().
**/
EFI_STATUS
-DumpAllTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
+DumpAllTrace (
+ IN UINTN Limit,
+ IN BOOLEAN ExcludeFlag
)
{
- MEASUREMENT_RECORD Measurement;
- UINT64 ElapsedTime;
- UINT64 Duration;
- CHAR16 *IncFlag;
- UINTN LogEntryKey;
- UINTN Count;
- UINTN Index;
- UINTN TIndex;
-
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- EFI_STATUS Status;
- EFI_STRING StringPtrUnknown;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 ElapsedTime;
+ UINT64 Duration;
+ CHAR16 *IncFlag;
+ UINTN LogEntryKey;
+ UINTN Count;
+ UINTN Index;
+ UINTN TIndex;
+
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ EFI_STATUS Status;
+ EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
+ IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (IncFlag == NULL) ? StringPtrUnknown : IncFlag
+ );
FreePool (StringPtrUnknown);
// Get Handle information
//
- Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
+ Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
- }
- else {
+ } else {
// We have successfully populated the HandleBuffer
// Display ALL Measurement Records
// Up to Limit lines displayed
@@ -229,35 +237,38 @@ DumpAllTrace(
}
LogEntryKey = 0;
- Count = 0;
- Index = 0;
- while ( WITHIN_LIMIT(Count, Limit) &&
+ Count = 0;
+ Index = 0;
+ while ( WITHIN_LIMIT (Count, Limit) &&
((LogEntryKey = GetPerformanceMeasurementRecord (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- )
+ LogEntryKey,
+ &Measurement.Handle,
+ &Measurement.Token,
+ &Measurement.Module,
+ &Measurement.StartTimeStamp,
+ &Measurement.EndTimeStamp,
+ &Measurement.Identifier
+ )) != 0)
+ )
{
++Index; // Count every record. First record is 1.
ElapsedTime = 0;
SHELL_FREE_NON_NULL (IncFlag);
if (Measurement.EndTimeStamp != 0) {
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
- IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
- }
- else {
+ Duration = GetDuration (&Measurement);
+ ElapsedTime = DurationInMicroSeconds (Duration);
+ IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
+ } else {
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
}
+
if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
- ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
- ) { // Ignore "uninteresting" or excluded records
+ ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
+ ) // Ignore "uninteresting" or excluded records
+ {
continue;
}
+
++Count; // Count the number of records printed
// If Handle is non-zero, see if we can determine a name for the driver
@@ -279,10 +290,15 @@ DumpAllTrace(
// Ensure that the argument strings are not too long.
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- mUnicodeToken[13] = 0;
+ mUnicodeToken[13] = 0;
if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_ALL_VARS2),
+ mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed
IncFlag,
Measurement.Handle,
@@ -290,26 +306,34 @@ DumpAllTrace(
mUnicodeToken,
ElapsedTime,
Measurement.Identifier
- );
+ );
} else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_ALL_VARS),
+ mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed
IncFlag,
Measurement.Handle,
mGaugeString,
mUnicodeToken,
ElapsedTime
- );
+ );
}
+
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
}
}
+
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
+
SHELL_FREE_NON_NULL (IncFlag);
return Status;
@@ -336,28 +360,34 @@ DumpAllTrace(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
-DumpRawTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
+DumpRawTrace (
+ IN UINTN Limit,
+ IN BOOLEAN ExcludeFlag
)
{
- MEASUREMENT_RECORD Measurement;
- UINT64 ElapsedTime;
- UINT64 Duration;
- UINTN LogEntryKey;
- UINTN Count;
- UINTN Index;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 ElapsedTime;
+ UINT64 Duration;
+ UINTN LogEntryKey;
+ UINTN Count;
+ UINTN Index;
- EFI_STRING StringPtr;
- EFI_STRING StringPtrUnknown;
- EFI_STATUS Status;
+ EFI_STRING StringPtr;
+ EFI_STRING StringPtrUnknown;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
+ StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
FreePool (StringPtr);
FreePool (StringPtrUnknown);
@@ -370,34 +400,43 @@ DumpRawTrace(
}
LogEntryKey = 0;
- Count = 0;
- Index = 0;
- while ( WITHIN_LIMIT(Count, Limit) &&
+ Count = 0;
+ Index = 0;
+ while ( WITHIN_LIMIT (Count, Limit) &&
((LogEntryKey = GetPerformanceMeasurementRecord (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- )
+ LogEntryKey,
+ &Measurement.Handle,
+ &Measurement.Token,
+ &Measurement.Module,
+ &Measurement.StartTimeStamp,
+ &Measurement.EndTimeStamp,
+ &Measurement.Identifier
+ )) != 0)
+ )
{
++Index; // Count every record. First record is 1.
ElapsedTime = 0;
if (Measurement.EndTimeStamp != 0) {
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
+ Duration = GetDuration (&Measurement);
+ ElapsedTime = DurationInMicroSeconds (Duration);
}
+
if ((ElapsedTime < mInterestThreshold) ||
- ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
- ) { // Ignore "uninteresting" or Excluded records
+ ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
+ ) // Ignore "uninteresting" or Excluded records
+ {
continue;
}
+
++Count; // Count the number of records printed
if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_RAW_VARS2),
+ mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed
Measurement.Handle,
Measurement.StartTimeStamp,
@@ -405,22 +444,29 @@ DumpRawTrace(
Measurement.Token,
Measurement.Module,
Measurement.Identifier
- );
+ );
} else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_RAW_VARS),
+ mDpHiiHandle,
Index, // 1 based, Which measurement record is being printed
Measurement.Handle,
Measurement.StartTimeStamp,
Measurement.EndTimeStamp,
Measurement.Token,
Measurement.Module
- );
+ );
}
+
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
}
+
return Status;
}
@@ -429,22 +475,22 @@ DumpRawTrace(
**/
VOID
-ProcessPhases(
+ProcessPhases (
VOID
)
{
- MEASUREMENT_RECORD Measurement;
- UINT64 BdsTimeoutValue;
- UINT64 SecTime;
- UINT64 PeiTime;
- UINT64 DxeTime;
- UINT64 BdsTime;
- UINT64 ElapsedTime;
- UINT64 Duration;
- UINT64 Total;
- EFI_STRING StringPtr;
- UINTN LogEntryKey;
- EFI_STRING StringPtrUnknown;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 BdsTimeoutValue;
+ UINT64 SecTime;
+ UINT64 PeiTime;
+ UINT64 DxeTime;
+ UINT64 BdsTime;
+ UINT64 ElapsedTime;
+ UINT64 Duration;
+ UINT64 Total;
+ EFI_STRING StringPtr;
+ UINTN LogEntryKey;
+ EFI_STRING StringPtrUnknown;
BdsTimeoutValue = 0;
SecTime = 0;
@@ -455,9 +501,15 @@ ProcessPhases(
// Get Execution Phase Statistics
//
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
+ StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
FreePool (StringPtr);
FreePool (StringPtrUnknown);
@@ -469,25 +521,28 @@ ProcessPhases(
&Measurement.Module,
&Measurement.StartTimeStamp,
&Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
+ &Measurement.Identifier
+ )) != 0)
{
- if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records
+ if (Measurement.EndTimeStamp == 0) {
+ // Skip "incomplete" records
continue;
}
+
Duration = GetDuration (&Measurement);
- if ( Measurement.Handle != NULL
- && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
- )
+ if ( (Measurement.Handle != NULL)
+ && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
+ )
{
BdsTimeoutValue = Duration;
} else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {
- SecTime = Duration;
+ SecTime = Duration;
} else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {
- PeiTime = Duration;
+ PeiTime = Duration;
} else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {
- DxeTime = Duration;
+ DxeTime = Duration;
} else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {
- BdsTime = Duration;
+ BdsTime = Duration;
}
}
@@ -496,8 +551,8 @@ ProcessPhases(
// print SEC phase duration time
//
if (SecTime > 0) {
- ElapsedTime = DurationInMicroSeconds ( SecTime ); // Calculate elapsed time in microseconds
- Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds
+ ElapsedTime = DurationInMicroSeconds (SecTime); // Calculate elapsed time in microseconds
+ Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);
}
@@ -505,7 +560,7 @@ ProcessPhases(
//
if (PeiTime > 0) {
ElapsedTime = DivU64x32 (PeiTime, 1000000);
- Total += ElapsedTime;
+ Total += ElapsedTime;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);
}
@@ -513,7 +568,7 @@ ProcessPhases(
//
if (DxeTime > 0) {
ElapsedTime = DivU64x32 (DxeTime, 1000000);
- Total += ElapsedTime;
+ Total += ElapsedTime;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);
}
@@ -521,7 +576,7 @@ ProcessPhases(
//
if (BdsTime > 0) {
ElapsedTime = DivU64x32 (BdsTime, 1000000);
- Total += ElapsedTime;
+ Total += ElapsedTime;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);
}
@@ -543,47 +598,53 @@ ProcessPhases(
@return Others from a call to gBS->LocateHandleBuffer().
**/
EFI_STATUS
-ProcessHandles(
- IN BOOLEAN ExcludeFlag
+ProcessHandles (
+ IN BOOLEAN ExcludeFlag
)
{
- MEASUREMENT_RECORD Measurement;
- UINT64 ElapsedTime;
- UINT64 Duration;
- EFI_HANDLE *HandleBuffer;
- EFI_STRING StringPtr;
- UINTN Index;
- UINTN LogEntryKey;
- UINTN Count;
- UINTN HandleCount;
- EFI_STATUS Status;
- EFI_STRING StringPtrUnknown;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 ElapsedTime;
+ UINT64 Duration;
+ EFI_HANDLE *HandleBuffer;
+ EFI_STRING StringPtr;
+ UINTN Index;
+ UINTN LogEntryKey;
+ UINTN Count;
+ UINTN HandleCount;
+ EFI_STATUS Status;
+ EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
+ StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
FreePool (StringPtr);
FreePool (StringPtrUnknown);
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
- }
- else {
-#if DP_DEBUG == 2
- Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0])));
-#endif
+ } else {
+ #if DP_DEBUG == 2
+ Print (L"There are %,d Handles defined.\n", (Size / sizeof (HandleBuffer[0])));
+ #endif
if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
}
+
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
LogEntryKey = 0;
- Count = 0;
+ Count = 0;
while ((LogEntryKey = GetPerformanceMeasurementRecord (
LogEntryKey,
&Measurement.Handle,
@@ -591,18 +652,21 @@ ProcessHandles(
&Measurement.Module,
&Measurement.StartTimeStamp,
&Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
+ &Measurement.Identifier
+ )) != 0)
{
Count++;
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
+ Duration = GetDuration (&Measurement);
+ ElapsedTime = DurationInMicroSeconds (Duration);
if ((ElapsedTime < mInterestThreshold) ||
(Measurement.EndTimeStamp == 0) ||
(!IsCorePerf (&Measurement)) ||
- ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
- ) { // Ignore "uninteresting" or excluded records
+ ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
+ ) // Ignore "uninteresting" or excluded records
+ {
continue;
}
+
mGaugeString[0] = 0; // Empty driver name by default
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
// See if the Handle is in the HandleBuffer
@@ -612,39 +676,53 @@ ProcessHandles(
break;
}
}
+
// Ensure that the argument strings are not too long.
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- mUnicodeToken[11] = 0;
+ mUnicodeToken[11] = 0;
if (mGaugeString[0] != 0) {
// Display the record if it has a valid handle.
if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_HANDLE_VARS2),
+ mDpHiiHandle,
Count, // 1 based, Which measurement record is being printed
Index + 1, // 1 based, Which handle is being printed
mGaugeString,
mUnicodeToken,
ElapsedTime,
Measurement.Identifier
- );
+ );
} else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_HANDLE_VARS),
+ mDpHiiHandle,
Count, // 1 based, Which measurement record is being printed
Index + 1, // 1 based, Which handle is being printed
mGaugeString,
mUnicodeToken,
ElapsedTime
- );
+ );
}
}
+
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
}
}
+
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
+
return Status;
}
@@ -657,25 +735,31 @@ ProcessHandles(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
-ProcessPeims(
+ProcessPeims (
VOID
-)
+ )
{
- MEASUREMENT_RECORD Measurement;
- UINT64 Duration;
- UINT64 ElapsedTime;
- EFI_STRING StringPtr;
- UINTN LogEntryKey;
- UINTN TIndex;
- EFI_STRING StringPtrUnknown;
- EFI_STATUS Status;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 Duration;
+ UINT64 ElapsedTime;
+ EFI_STRING StringPtr;
+ UINTN LogEntryKey;
+ UINTN TIndex;
+ EFI_STRING StringPtrUnknown;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
+ StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
FreePool (StringPtr);
FreePool (StringPtrUnknown);
@@ -684,8 +768,9 @@ ProcessPeims(
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
}
+
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
- TIndex = 0;
+ TIndex = 0;
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementRecord (
LogEntryKey,
@@ -694,39 +779,53 @@ ProcessPeims(
&Measurement.Module,
&Measurement.StartTimeStamp,
&Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
+ &Measurement.Identifier
+ )) != 0)
{
TIndex++;
if ((Measurement.EndTimeStamp == 0) ||
(AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)
- ) {
+ )
+ {
continue;
}
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration ); // Calculate elapsed time in microseconds
+ Duration = GetDuration (&Measurement);
+ ElapsedTime = DurationInMicroSeconds (Duration); // Calculate elapsed time in microseconds
if (ElapsedTime >= mInterestThreshold) {
// PEIM FILE Handle is the start address of its FFS file that contains its file guid.
if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,
- TIndex, // 1 based, Which measurement record is being printed
- Measurement.Handle, // file guid
- ElapsedTime,
- Measurement.Identifier
- );
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_PEIM_VARS2),
+ mDpHiiHandle,
+ TIndex, // 1 based, Which measurement record is being printed
+ Measurement.Handle, // file guid
+ ElapsedTime,
+ Measurement.Identifier
+ );
} else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,
- TIndex, // 1 based, Which measurement record is being printed
- Measurement.Handle, // file guid
- ElapsedTime
- );
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_PEIM_VARS),
+ mDpHiiHandle,
+ TIndex, // 1 based, Which measurement record is being printed
+ Measurement.Handle, // file guid
+ ElapsedTime
+ );
}
}
+
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
}
+
return Status;
}
@@ -742,25 +841,31 @@ ProcessPeims(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
-ProcessGlobal(
+ProcessGlobal (
VOID
-)
+ )
{
- MEASUREMENT_RECORD Measurement;
- UINT64 Duration;
- UINT64 ElapsedTime;
- EFI_STRING StringPtr;
- UINTN LogEntryKey;
- UINTN Index; // Index, or number, of the measurement record being processed
- EFI_STRING StringPtrUnknown;
- EFI_STATUS Status;
+ MEASUREMENT_RECORD Measurement;
+ UINT64 Duration;
+ UINT64 ElapsedTime;
+ EFI_STRING StringPtr;
+ UINTN LogEntryKey;
+ UINTN Index; // Index, or number, of the measurement record being processed
+ EFI_STRING StringPtrUnknown;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
+ StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
FreePool (StringPtr);
FreePool (StringPtrUnknown);
@@ -769,9 +874,10 @@ ProcessGlobal(
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
}
+
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
- Index = 1;
+ Index = 1;
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementRecord (
@@ -781,22 +887,28 @@ ProcessGlobal(
&Measurement.Module,
&Measurement.StartTimeStamp,
&Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
+ &Measurement.Identifier
+ )) != 0)
{
AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
- mGaugeString[25] = 0;
+ mGaugeString[25] = 0;
mUnicodeToken[31] = 0;
- if ( ! ( IsPhase( &Measurement) ||
- IsCorePerf (&Measurement) ||
- (Measurement.EndTimeStamp == 0)
- ))
+ if ( !(IsPhase (&Measurement) ||
+ IsCorePerf (&Measurement) ||
+ (Measurement.EndTimeStamp == 0)
+ ))
{
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
+ Duration = GetDuration (&Measurement);
+ ElapsedTime = DurationInMicroSeconds (Duration);
if (ElapsedTime >= mInterestThreshold) {
if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_GLOBAL_VARS2),
+ mDpHiiHandle,
Index,
mGaugeString,
mUnicodeToken,
@@ -804,7 +916,12 @@ ProcessGlobal(
Measurement.Identifier
);
} else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_GLOBAL_VARS),
+ mDpHiiHandle,
Index,
mGaugeString,
mUnicodeToken,
@@ -813,12 +930,15 @@ ProcessGlobal(
}
}
}
+
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
+
Index++;
}
+
return Status;
}
@@ -834,22 +954,28 @@ ProcessGlobal(
**/
VOID
-ProcessCumulative(
- IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
+ProcessCumulative (
+ IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
)
{
- UINT64 AvgDur; // the computed average duration
- UINT64 Dur;
- UINT64 MinDur;
- UINT64 MaxDur;
- EFI_STRING StringPtr;
- UINTN TIndex;
- EFI_STRING StringPtrUnknown;
+ UINT64 AvgDur; // the computed average duration
+ UINT64 Dur;
+ UINT64 MinDur;
+ UINT64 MaxDur;
+ EFI_STRING StringPtr;
+ UINTN TIndex;
+ EFI_STRING StringPtrUnknown;
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
+ StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_SECTION_HEADER),
+ mDpHiiHandle,
+ (StringPtr == NULL) ? StringPtrUnknown : StringPtr
+ );
FreePool (StringPtr);
FreePool (StringPtrUnknown);
@@ -860,19 +986,24 @@ ProcessCumulative(
for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
if (CumData[TIndex].Count != 0) {
AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);
- AvgDur = DurationInMicroSeconds(AvgDur);
- Dur = DurationInMicroSeconds(CumData[TIndex].Duration);
- MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
- MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
- CumData[TIndex].Name,
- CumData[TIndex].Count,
- Dur,
- AvgDur,
- MinDur,
- MaxDur
- );
+ AvgDur = DurationInMicroSeconds (AvgDur);
+ Dur = DurationInMicroSeconds (CumData[TIndex].Duration);
+ MaxDur = DurationInMicroSeconds (CumData[TIndex].MaxDur);
+ MinDur = DurationInMicroSeconds (CumData[TIndex].MinDur);
+
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
+ mDpHiiHandle,
+ CumData[TIndex].Name,
+ CumData[TIndex].Count,
+ Dur,
+ AvgDur,
+ MinDur,
+ MaxDur
+ );
}
}
@@ -892,13 +1023,19 @@ ProcessCumulative(
MaxDur = 0;
MinDur = 0;
}
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
- CustomCumulativeData->Name,
- CustomCumulativeData->Count,
- Dur,
- AvgDur,
- MinDur,
- MaxDur
- );
+
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
+ mDpHiiHandle,
+ CustomCumulativeData->Name,
+ CustomCumulativeData->Count,
+ Dur,
+ AvgDur,
+ MinDur,
+ MaxDur
+ );
}
}
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
index 418b852..60c886c 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
@@ -55,23 +55,24 @@
**/
UINT64
GetDuration (
- IN OUT MEASUREMENT_RECORD *Measurement
+ IN OUT MEASUREMENT_RECORD *Measurement
)
{
- UINT64 Duration;
- BOOLEAN Error;
+ UINT64 Duration;
+ BOOLEAN Error;
if (Measurement->EndTimeStamp == 0) {
return 0;
}
Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;
- Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
+ Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
if (Error) {
DEBUG ((DEBUG_ERROR, ALit_TimerLibError));
Duration = 0;
}
+
return Duration;
}
@@ -87,18 +88,18 @@ GetDuration (
@retval FALSE The measurement record is NOT for an EFI Phase.
**/
BOOLEAN
-IsPhase(
- IN MEASUREMENT_RECORD *Measurement
+IsPhase (
+ IN MEASUREMENT_RECORD *Measurement
)
{
- BOOLEAN RetVal;
+ BOOLEAN RetVal;
RetVal = (BOOLEAN)(
- ((AsciiStrCmp (Measurement->Token, ALit_SEC) == 0) ||
- (AsciiStrCmp (Measurement->Token, ALit_PEI) == 0) ||
- (AsciiStrCmp (Measurement->Token, ALit_DXE) == 0) ||
- (AsciiStrCmp (Measurement->Token, ALit_BDS) == 0))
- );
+ ((AsciiStrCmp (Measurement->Token, ALit_SEC) == 0) ||
+ (AsciiStrCmp (Measurement->Token, ALit_PEI) == 0) ||
+ (AsciiStrCmp (Measurement->Token, ALit_DXE) == 0) ||
+ (AsciiStrCmp (Measurement->Token, ALit_BDS) == 0))
+ );
return RetVal;
}
@@ -112,24 +113,24 @@ IsPhase(
**/
BOOLEAN
-IsCorePerf(
- IN MEASUREMENT_RECORD *Measurement
+IsCorePerf (
+ IN MEASUREMENT_RECORD *Measurement
)
{
- BOOLEAN RetVal;
+ BOOLEAN RetVal;
RetVal = (BOOLEAN)(
- ((Measurement->Identifier == MODULE_START_ID) ||
- (Measurement->Identifier == MODULE_END_ID) ||
- (Measurement->Identifier == MODULE_LOADIMAGE_START_ID) ||
- (Measurement->Identifier == MODULE_LOADIMAGE_END_ID) ||
- (Measurement->Identifier == MODULE_DB_START_ID) ||
- (Measurement->Identifier == MODULE_DB_END_ID) ||
- (Measurement->Identifier == MODULE_DB_SUPPORT_START_ID) ||
- (Measurement->Identifier == MODULE_DB_SUPPORT_END_ID) ||
- (Measurement->Identifier == MODULE_DB_STOP_START_ID) ||
- (Measurement->Identifier == MODULE_DB_STOP_START_ID))
- );
+ ((Measurement->Identifier == MODULE_START_ID) ||
+ (Measurement->Identifier == MODULE_END_ID) ||
+ (Measurement->Identifier == MODULE_LOADIMAGE_START_ID) ||
+ (Measurement->Identifier == MODULE_LOADIMAGE_END_ID) ||
+ (Measurement->Identifier == MODULE_DB_START_ID) ||
+ (Measurement->Identifier == MODULE_DB_END_ID) ||
+ (Measurement->Identifier == MODULE_DB_SUPPORT_START_ID) ||
+ (Measurement->Identifier == MODULE_DB_SUPPORT_END_ID) ||
+ (Measurement->Identifier == MODULE_DB_STOP_START_ID) ||
+ (Measurement->Identifier == MODULE_DB_STOP_START_ID))
+ );
return RetVal;
}
@@ -147,14 +148,14 @@ IsCorePerf(
**/
VOID
DpGetShortPdbFileName (
- IN CHAR8 *PdbFileName,
- OUT CHAR16 *UnicodeBuffer
+ IN CHAR8 *PdbFileName,
+ OUT CHAR16 *UnicodeBuffer
)
{
- UINTN IndexA; // Current work location within an ASCII string.
- UINTN IndexU; // Current work location within a Unicode string.
- UINTN StartIndex;
- UINTN EndIndex;
+ UINTN IndexA; // Current work location within an ASCII string.
+ UINTN IndexU; // Current work location within a Unicode string.
+ UINTN StartIndex;
+ UINTN EndIndex;
ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));
@@ -162,8 +163,9 @@ DpGetShortPdbFileName (
StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);
} else {
StartIndex = 0;
- for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
- ;
+ for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) {
+ }
+
for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {
StartIndex = IndexA + 1;
@@ -176,7 +178,7 @@ DpGetShortPdbFileName (
IndexU = 0;
for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {
- UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];
+ UnicodeBuffer[IndexU] = (CHAR16)PdbFileName[IndexA];
IndexU++;
if (IndexU >= DP_GAUGE_STRING_LENGTH) {
UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;
@@ -204,26 +206,26 @@ DpGetShortPdbFileName (
**/
VOID
DpGetNameFromHandle (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *Image;
- CHAR8 *PdbFileName;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- EFI_STRING StringPtr;
- EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_GUID *NameGuid;
- CHAR16 *NameString;
- UINTN StringSize;
- CHAR8 *PlatformLanguage;
- CHAR8 *BestLanguage;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
-
- Image = NULL;
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *Image;
+ CHAR8 *PdbFileName;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ EFI_STRING StringPtr;
+ EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_GUID *NameGuid;
+ CHAR16 *NameString;
+ UINTN StringSize;
+ CHAR8 *PlatformLanguage;
+ CHAR8 *BestLanguage;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+
+ Image = NULL;
LoadedImageDevicePath = NULL;
- DevicePath = NULL;
+ DevicePath = NULL;
//
// Method 1: Get the name string from image PDB
@@ -231,14 +233,14 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
Handle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &Image
+ (VOID **)&Image
);
if (EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
Handle,
&gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding,
+ (VOID **)&DriverBinding,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -247,7 +249,7 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
DriverBinding->ImageHandle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &Image
+ (VOID **)&Image
);
}
}
@@ -267,14 +269,14 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
Handle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
//
// Firstly use platform language setting, secondly use driver's first supported language.
//
- GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&PlatformLanguage, NULL);
- BestLanguage = GetBestLanguage(
+ GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID **)&PlatformLanguage, NULL);
+ BestLanguage = GetBestLanguage (
ComponentName2->SupportedLanguages,
FALSE,
(PlatformLanguage != NULL) ? PlatformLanguage : "",
@@ -299,7 +301,7 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
Handle,
&gEfiLoadedImageDevicePathProtocolGuid,
- (VOID **) &LoadedImageDevicePath
+ (VOID **)&LoadedImageDevicePath
);
if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {
DevicePath = LoadedImageDevicePath;
@@ -313,10 +315,11 @@ DpGetNameFromHandle (
//
NameGuid = NULL;
while (!IsDevicePathEndType (DevicePath)) {
- NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePath);
if (NameGuid != NULL) {
break;
}
+
DevicePath = NextDevicePathNode (DevicePath);
}
@@ -326,13 +329,13 @@ DpGetNameFromHandle (
//
NameString = NULL;
StringSize = 0;
- Status = GetSectionFromAnyFv (
- NameGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **) &NameString,
- &StringSize
- );
+ Status = GetSectionFromAnyFv (
+ NameGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&NameString,
+ &StringSize
+ );
if (!EFI_ERROR (Status)) {
//
@@ -347,6 +350,7 @@ DpGetNameFromHandle (
//
UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);
}
+
return;
} else {
//
@@ -386,7 +390,7 @@ DpGetNameFromHandle (
**/
UINT64
DurationInMicroSeconds (
- IN UINT64 Duration
+ IN UINT64 Duration
)
{
return DivU64x32 (Duration, 1000);
@@ -406,17 +410,18 @@ DurationInMicroSeconds (
@retval >=0 Return value is the index into CumData where Token is found.
**/
INTN
-GetCumulativeItem(
- IN MEASUREMENT_RECORD *Measurement
+GetCumulativeItem (
+ IN MEASUREMENT_RECORD *Measurement
)
{
- INTN Index;
+ INTN Index;
- for( Index = 0; Index < (INTN)NumCum; ++Index) {
+ for ( Index = 0; Index < (INTN)NumCum; ++Index) {
if (AsciiStrCmp (Measurement->Token, CumData[Index].Name) == 0) {
return Index; // Exit, we found a match
}
}
+
// If the for loop exits, Token was not found.
return -1; // Indicate failure
}
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
index abf5be6..4bb73af 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
@@ -7,16 +7,16 @@
#include <Guid/ExtendedFirmwarePerformance.h>
// ASCII String literals which probably don't need translation
-CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";
-CHAR8 const ALit_SEC[] = SEC_TOK;
-CHAR8 const ALit_DXE[] = DXE_TOK;
-CHAR8 const ALit_PEI[] = PEI_TOK;
-CHAR8 const ALit_BDS[] = BDS_TOK;
-CHAR8 const ALit_START_IMAGE[] = START_IMAGE_TOK;
-CHAR8 const ALit_LOAD_IMAGE[] = LOAD_IMAGE_TOK;
-CHAR8 const ALit_DB_START[] = DRIVERBINDING_START_TOK;
-CHAR8 const ALit_DB_SUPPORT[] = DRIVERBINDING_SUPPORT_TOK;
-CHAR8 const ALit_DB_STOP[] = DRIVERBINDING_STOP_TOK;
+CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";
+CHAR8 const ALit_SEC[] = SEC_TOK;
+CHAR8 const ALit_DXE[] = DXE_TOK;
+CHAR8 const ALit_PEI[] = PEI_TOK;
+CHAR8 const ALit_BDS[] = BDS_TOK;
+CHAR8 const ALit_START_IMAGE[] = START_IMAGE_TOK;
+CHAR8 const ALit_LOAD_IMAGE[] = LOAD_IMAGE_TOK;
+CHAR8 const ALit_DB_START[] = DRIVERBINDING_START_TOK;
+CHAR8 const ALit_DB_SUPPORT[] = DRIVERBINDING_SUPPORT_TOK;
+CHAR8 const ALit_DB_STOP[] = DRIVERBINDING_STOP_TOK;
-CHAR8 const ALit_BdsTO[] = "BdsTimeOut";
-CHAR8 const ALit_PEIM[] = "PEIM";
+CHAR8 const ALit_BdsTO[] = "BdsTimeOut";
+CHAR8 const ALit_PEIM[] = "PEIM";
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
index e03fb3f..7174251 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
@@ -4,23 +4,24 @@
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef _LITERALS_H_
#define _LITERALS_H_
// ASCII String literals which probably don't need translation
-extern CHAR8 const ALit_TimerLibError[];
-extern CHAR8 const ALit_SEC[];
-extern CHAR8 const ALit_DXE[];
-extern CHAR8 const ALit_SHELL[];
-extern CHAR8 const ALit_PEI[];
-extern CHAR8 const ALit_BDS[];
-extern CHAR8 const ALit_PEIM[];
-extern CHAR8 const ALit_START_IMAGE[];
-extern CHAR8 const ALit_LOAD_IMAGE[];
-extern CHAR8 const ALit_DB_START[];
-extern CHAR8 const ALit_DB_SUPPORT[];
-extern CHAR8 const ALit_DB_STOP[];
-extern CHAR8 const ALit_BdsTO[];
-extern CHAR8 const ALit_PEIM[];
+extern CHAR8 const ALit_TimerLibError[];
+extern CHAR8 const ALit_SEC[];
+extern CHAR8 const ALit_DXE[];
+extern CHAR8 const ALit_SHELL[];
+extern CHAR8 const ALit_PEI[];
+extern CHAR8 const ALit_BDS[];
+extern CHAR8 const ALit_PEIM[];
+extern CHAR8 const ALit_START_IMAGE[];
+extern CHAR8 const ALit_LOAD_IMAGE[];
+extern CHAR8 const ALit_DB_START[];
+extern CHAR8 const ALit_DB_SUPPORT[];
+extern CHAR8 const ALit_DB_STOP[];
+extern CHAR8 const ALit_BdsTO[];
+extern CHAR8 const ALit_PEIM[];
-#endif // _LITERALS_H_
+#endif // _LITERALS_H_
diff --git a/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c b/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c
index 7b9b2d2..b4e88e7 100644
--- a/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c
+++ b/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c
@@ -11,7 +11,7 @@
#include "Http.h"
-#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
+#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
//
// Constant strings and definitions related to the message
@@ -37,17 +37,17 @@
//
// Buffer size. Note that larger buffer does not mean better speed.
//
-#define DEFAULT_BUF_SIZE SIZE_32KB
-#define MAX_BUF_SIZE SIZE_4MB
+#define DEFAULT_BUF_SIZE SIZE_32KB
+#define MAX_BUF_SIZE SIZE_4MB
-#define MIN_PARAM_COUNT 2
-#define MAX_PARAM_COUNT 4
+#define MIN_PARAM_COUNT 2
+#define MAX_PARAM_COUNT 4
#define NEED_REDIRECTION(Code) \
(((Code >= HTTP_STATUS_300_MULTIPLE_CHOICES) \
&& (Code <= HTTP_STATUS_307_TEMPORARY_REDIRECT)) \
|| (Code == HTTP_STATUS_308_PERMANENT_REDIRECT))
-#define CLOSE_HTTP_HANDLE(ControllerHandle,HttpChildHandle) \
+#define CLOSE_HTTP_HANDLE(ControllerHandle, HttpChildHandle) \
do { \
if (HttpChildHandle) { \
CloseProtocolAndDestroyServiceChild ( \
@@ -69,13 +69,13 @@ typedef enum {
#define USER_AGENT_HDR "Mozilla/5.0 (EDK2; Linux) Gecko/20100101 Firefox/79.0"
-#define TIMER_MAX_TIMEOUT_S 10
+#define TIMER_MAX_TIMEOUT_S 10
//
// File name to use when Uri ends with "/".
//
-#define DEFAULT_HTML_FILE L"index.html"
-#define DEFAULT_HTTP_PROTO L"http"
+#define DEFAULT_HTML_FILE L"index.html"
+#define DEFAULT_HTTP_PROTO L"http"
//
// String to delete the HTTP progress message to be able to update it :
@@ -85,20 +85,20 @@ typedef enum {
L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
-#define HTTP_KB L"\b\b\b\b\b\b\b\b\b\b"
+#define HTTP_KB L"\b\b\b\b\b\b\b\b\b\b"
//
// Frame for the progression slider.
//
-#define HTTP_PROGR_FRAME L"[ ]"
+#define HTTP_PROGR_FRAME L"[ ]"
//
// Improve readability by using these macros.
//
-#define PRINT_HII(token,...) \
+#define PRINT_HII(token, ...) \
ShellPrintHiiEx (\
-1, -1, NULL, token, mHttpHiiHandle, __VA_ARGS__)
-#define PRINT_HII_APP(token,value) \
+#define PRINT_HII_APP(token, value) \
PRINT_HII (token, HTTP_APP_NAME, value)
//
@@ -109,19 +109,19 @@ typedef enum {
//
// Define EPOCH (1970-JANUARY-01) in the Julian Date representation.
//
-#define EPOCH_JULIAN_DATE 2440588
+#define EPOCH_JULIAN_DATE 2440588
//
// Seconds per unit.
//
-#define SEC_PER_MIN ((UINTN) 60)
-#define SEC_PER_HOUR ((UINTN) 3600)
-#define SEC_PER_DAY ((UINTN) 86400)
+#define SEC_PER_MIN ((UINTN) 60)
+#define SEC_PER_HOUR ((UINTN) 3600)
+#define SEC_PER_DAY ((UINTN) 86400)
//
// String descriptions for server errors.
//
-STATIC CONST CHAR16 *ErrStatusDesc[] =
+STATIC CONST CHAR16 *ErrStatusDesc[] =
{
L"400 Bad Request",
L"401 Unauthorized",
@@ -149,32 +149,32 @@ STATIC CONST CHAR16 *ErrStatusDesc[] =
L"505 HTTP version not supported"
};
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-i", TypeValue},
- {L"-k", TypeFlag},
- {L"-l", TypeValue},
- {L"-m", TypeFlag},
- {L"-s", TypeValue},
- {L"-t", TypeValue},
- {NULL , TypeMax}
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-i", TypeValue },
+ { L"-k", TypeFlag },
+ { L"-l", TypeValue },
+ { L"-m", TypeFlag },
+ { L"-s", TypeValue },
+ { L"-t", TypeValue },
+ { NULL, TypeMax }
};
//
// Local File Handle.
//
-STATIC SHELL_FILE_HANDLE mFileHandle = NULL;
+STATIC SHELL_FILE_HANDLE mFileHandle = NULL;
//
// Path of the local file, Unicode encoded.
//
-STATIC CONST CHAR16 *mLocalFilePath;
+STATIC CONST CHAR16 *mLocalFilePath;
-STATIC BOOLEAN gRequestCallbackComplete = FALSE;
-STATIC BOOLEAN gResponseCallbackComplete = FALSE;
+STATIC BOOLEAN gRequestCallbackComplete = FALSE;
+STATIC BOOLEAN gResponseCallbackComplete = FALSE;
-STATIC BOOLEAN gHttpError;
+STATIC BOOLEAN gHttpError;
-EFI_HII_HANDLE mHttpHiiHandle;
+EFI_HII_HANDLE mHttpHiiHandle;
//
// Functions declarations.
@@ -286,9 +286,9 @@ CloseProtocolAndDestroyServiceChild (
STATIC
EFI_STATUS
DownloadFile (
- IN HTTP_DOWNLOAD_CONTEXT *Context,
- IN EFI_HANDLE ControllerHandle,
- IN CHAR16 *NicName
+ IN HTTP_DOWNLOAD_CONTEXT *Context,
+ IN EFI_HANDLE ControllerHandle,
+ IN CHAR16 *NicName
);
/**
@@ -302,11 +302,11 @@ DownloadFile (
STATIC
EFI_STATUS
TrimSpaces (
- IN CHAR16 *String
+ IN CHAR16 *String
)
{
- CHAR16 *Str;
- UINTN Len;
+ CHAR16 *Str;
+ UINTN Len;
ASSERT (String != NULL);
@@ -328,7 +328,7 @@ TrimSpaces (
//
do {
Len = StrLen (Str);
- if (!Len || (Str[Len - 1] != L' ' && Str[Len - 1] != '\t')) {
+ if (!Len || ((Str[Len - 1] != L' ') && (Str[Len - 1] != '\t'))) {
break;
}
@@ -355,8 +355,8 @@ STATIC
VOID
EFIAPI
RequestCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gRequestCallbackComplete = TRUE;
@@ -371,8 +371,8 @@ STATIC
VOID
EFIAPI
ResponseCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gResponseCallbackComplete = TRUE;
@@ -396,19 +396,19 @@ EfiGetEpochDays (
IN EFI_TIME *Time
)
{
- UINTN a;
- UINTN y;
- UINTN m;
+ UINTN a;
+ UINTN y;
+ UINTN m;
//
// Absolute Julian Date representation of the supplied Time.
//
- UINTN JulianDate;
+ UINTN JulianDate;
//
// Number of days elapsed since EPOCH_JULIAN_DAY.
//
- UINTN EpochDays;
+ UINTN EpochDays;
- a = (14 - Time->Month) / 12 ;
+ a = (14 - Time->Month) / 12;
y = Time->Year + 4800 - a;
m = Time->Month + (12 * a) - 3;
@@ -437,8 +437,8 @@ EfiTimeToEpoch (
//
// Number of days elapsed since EPOCH_JULIAN_DAY.
//
- UINTN EpochDays;
- UINTN EpochSeconds;
+ UINTN EpochDays;
+ UINTN EpochSeconds;
EpochDays = EfiGetEpochDays (Time);
@@ -471,32 +471,32 @@ RunHttp (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *CheckPackage;
- UINTN ParamCount;
- UINTN HandleCount;
- UINTN NicNumber;
- UINTN InitialSize;
- UINTN ParamOffset;
- UINTN StartSize;
- CHAR16 *ProblemParam;
- CHAR16 NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];
- CHAR16 *Walker1;
- CHAR16 *VStr;
- CONST CHAR16 *UserNicName;
- CONST CHAR16 *ValueStr;
- CONST CHAR16 *RemoteFilePath;
- CONST CHAR16 *Walker;
- EFI_HTTPv4_ACCESS_POINT IPv4Node;
- EFI_HANDLE *Handles;
- EFI_HANDLE ControllerHandle;
- HTTP_DOWNLOAD_CONTEXT Context;
- BOOLEAN NicFound;
-
- ProblemParam = NULL;
- RemoteFilePath = NULL;
- NicFound = FALSE;
- Handles = NULL;
+ EFI_STATUS Status;
+ LIST_ENTRY *CheckPackage;
+ UINTN ParamCount;
+ UINTN HandleCount;
+ UINTN NicNumber;
+ UINTN InitialSize;
+ UINTN ParamOffset;
+ UINTN StartSize;
+ CHAR16 *ProblemParam;
+ CHAR16 NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];
+ CHAR16 *Walker1;
+ CHAR16 *VStr;
+ CONST CHAR16 *UserNicName;
+ CONST CHAR16 *ValueStr;
+ CONST CHAR16 *RemoteFilePath;
+ CONST CHAR16 *Walker;
+ EFI_HTTPv4_ACCESS_POINT IPv4Node;
+ EFI_HANDLE *Handles;
+ EFI_HANDLE ControllerHandle;
+ HTTP_DOWNLOAD_CONTEXT Context;
+ BOOLEAN NicFound;
+
+ ProblemParam = NULL;
+ RemoteFilePath = NULL;
+ NicFound = FALSE;
+ Handles = NULL;
//
// Initialize the Shell library (we must be in non-auto-init...).
@@ -522,8 +522,8 @@ RunHttp (
TRUE
);
if (EFI_ERROR (Status)) {
- if ((Status == EFI_VOLUME_CORRUPTED)
- && (ProblemParam != NULL))
+ if ( (Status == EFI_VOLUME_CORRUPTED)
+ && (ProblemParam != NULL))
{
PRINT_HII_APP (STRING_TOKEN (STR_GEN_PROBLEM), ProblemParam);
SHELL_FREE_NON_NULL (ProblemParam);
@@ -554,7 +554,7 @@ RunHttp (
ZeroMem (&IPv4Node, sizeof (IPv4Node));
IPv4Node.UseDefaultAddress = TRUE;
- Context.HttpConfigData.HttpVersion = HttpVersion11;
+ Context.HttpConfigData.HttpVersion = HttpVersion11;
Context.HttpConfigData.AccessPoint.IPv4Node = &IPv4Node;
//
@@ -592,7 +592,7 @@ RunHttp (
}
if (*Walker1 == L'/') {
- ParamOffset = 1;
+ ParamOffset = 1;
RemoteFilePath = Walker1;
}
@@ -629,7 +629,8 @@ RunHttp (
Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') ||
- (*Walker == L'/' ) ) {
+ (*Walker == L'/'))
+ {
break;
}
}
@@ -659,12 +660,12 @@ RunHttp (
UserNicName = ShellCommandLineGetValue (CheckPackage, L"-i");
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-l");
- if ((ValueStr != NULL)
- && (!StringToUint16 (
- ValueStr,
- &Context.HttpConfigData.AccessPoint.IPv4Node->LocalPort
- )
- ))
+ if ( (ValueStr != NULL)
+ && (!StringToUint16 (
+ ValueStr,
+ &Context.HttpConfigData.AccessPoint.IPv4Node->LocalPort
+ )
+ ))
{
goto Error;
}
@@ -674,7 +675,7 @@ RunHttp (
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-s");
if (ValueStr != NULL) {
Context.BufferSize = ShellStrToUintn (ValueStr);
- if (!Context.BufferSize || Context.BufferSize > MAX_BUF_SIZE) {
+ if (!Context.BufferSize || (Context.BufferSize > MAX_BUF_SIZE)) {
PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV), ValueStr);
goto Error;
}
@@ -756,10 +757,10 @@ RunHttp (
}
if (gHttpError) {
- //
- // This is not related to connection, so no need to repeat with
- // another interface.
- //
+ //
+ // This is not related to connection, so no need to repeat with
+ // another interface.
+ //
break;
}
}
@@ -841,7 +842,7 @@ GetNicName (
&gEfiManagedNetworkServiceBindingProtocolGuid,
&gEfiManagedNetworkProtocolGuid,
&MnpHandle,
- (VOID**)&Mnp
+ (VOID **)&Mnp
);
if (EFI_ERROR (Status)) {
goto Error;
@@ -907,12 +908,12 @@ CreateServiceChildAndOpenProtocol (
EFI_STATUS Status;
*ChildHandle = NULL;
- Status = NetLibCreateServiceChild (
- ControllerHandle,
- gImageHandle,
- ServiceBindingProtocolGuid,
- ChildHandle
- );
+ Status = NetLibCreateServiceChild (
+ ControllerHandle,
+ gImageHandle,
+ ServiceBindingProtocolGuid,
+ ChildHandle
+ );
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
*ChildHandle,
@@ -990,8 +991,8 @@ WaitForCompletion (
IN OUT BOOLEAN *CallBackComplete
)
{
- EFI_STATUS Status;
- EFI_EVENT WaitEvt;
+ EFI_STATUS Status;
+ EFI_EVENT WaitEvt;
Status = EFI_SUCCESS;
@@ -1005,25 +1006,25 @@ WaitForCompletion (
NULL,
&WaitEvt
);
- ASSERT_EFI_ERROR (Status);
+ ASSERT_EFI_ERROR (Status);
- if (!EFI_ERROR (Status)) {
- Status = gBS->SetTimer (
- WaitEvt,
- TimerRelative,
- EFI_TIMER_PERIOD_SECONDS (TIMER_MAX_TIMEOUT_S)
- );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->SetTimer (
+ WaitEvt,
+ TimerRelative,
+ EFI_TIMER_PERIOD_SECONDS (TIMER_MAX_TIMEOUT_S)
+ );
- ASSERT_EFI_ERROR (Status);
- }
+ ASSERT_EFI_ERROR (Status);
+ }
- while (! *CallBackComplete
- && (!EFI_ERROR (Status))
- && EFI_ERROR (gBS->CheckEvent (WaitEvt)))
+ while ( !*CallBackComplete
+ && (!EFI_ERROR (Status))
+ && EFI_ERROR (gBS->CheckEvent (WaitEvt)))
{
Status = Context->Http->Poll (Context->Http);
- if (!Context->ContentDownloaded
- && CallBackComplete == &gResponseCallbackComplete)
+ if ( !Context->ContentDownloaded
+ && (CallBackComplete == &gResponseCallbackComplete))
{
//
// An HTTP server may just send a response redirection header.
@@ -1032,12 +1033,12 @@ WaitForCompletion (
// Note that at this point Response may not has been populated,
// so it needs to be checked first.
//
- if (Context->ResponseToken.Message
- && Context->ResponseToken.Message->Data.Response
- && (NEED_REDIRECTION (
- Context->ResponseToken.Message->Data.Response->StatusCode
- )
- ))
+ if ( Context->ResponseToken.Message
+ && Context->ResponseToken.Message->Data.Response
+ && (NEED_REDIRECTION (
+ Context->ResponseToken.Message->Data.Response->StatusCode
+ )
+ ))
{
break;
}
@@ -1079,20 +1080,20 @@ SendRequest (
IN CHAR16 *DownloadUrl
)
{
- EFI_HTTP_REQUEST_DATA RequestData;
- EFI_HTTP_HEADER RequestHeader[HdrMax];
- EFI_HTTP_MESSAGE RequestMessage;
- EFI_STATUS Status;
- CHAR16 *Host;
- UINTN StringSize;
+ EFI_HTTP_REQUEST_DATA RequestData;
+ EFI_HTTP_HEADER RequestHeader[HdrMax];
+ EFI_HTTP_MESSAGE RequestMessage;
+ EFI_STATUS Status;
+ CHAR16 *Host;
+ UINTN StringSize;
ZeroMem (&RequestData, sizeof (RequestData));
ZeroMem (&RequestHeader, sizeof (RequestHeader));
ZeroMem (&RequestMessage, sizeof (RequestMessage));
ZeroMem (&Context->RequestToken, sizeof (Context->RequestToken));
- RequestHeader[HdrHost].FieldName = "Host";
- RequestHeader[HdrConn].FieldName = "Connection";
+ RequestHeader[HdrHost].FieldName = "Host";
+ RequestHeader[HdrConn].FieldName = "Connection";
RequestHeader[HdrAgent].FieldName = "User-Agent";
Host = (CHAR16 *)Context->ServerAddrAndProto;
@@ -1113,7 +1114,7 @@ SendRequest (
//
Host++;
- StringSize = StrLen (Host) + 1;
+ StringSize = StrLen (Host) + 1;
RequestHeader[HdrHost].FieldValue = AllocatePool (StringSize);
if (!RequestHeader[HdrHost].FieldValue) {
return EFI_OUT_OF_RESOURCES;
@@ -1125,17 +1126,17 @@ SendRequest (
StringSize
);
- RequestHeader[HdrConn].FieldValue = "close";
+ RequestHeader[HdrConn].FieldValue = "close";
RequestHeader[HdrAgent].FieldValue = USER_AGENT_HDR;
- RequestMessage.HeaderCount = HdrMax;
+ RequestMessage.HeaderCount = HdrMax;
RequestData.Method = HttpMethodGet;
- RequestData.Url = DownloadUrl;
+ RequestData.Url = DownloadUrl;
RequestMessage.Data.Request = &RequestData;
- RequestMessage.Headers = RequestHeader;
- RequestMessage.BodyLength = 0;
- RequestMessage.Body = NULL;
+ RequestMessage.Headers = RequestHeader;
+ RequestMessage.BodyLength = 0;
+ RequestMessage.Body = NULL;
Context->RequestToken.Event = NULL;
//
@@ -1150,10 +1151,10 @@ SendRequest (
);
ASSERT_EFI_ERROR (Status);
- Context->RequestToken.Status = EFI_SUCCESS;
+ Context->RequestToken.Status = EFI_SUCCESS;
Context->RequestToken.Message = &RequestMessage;
- gRequestCallbackComplete = FALSE;
- Status = Context->Http->Request (Context->Http, &Context->RequestToken);
+ gRequestCallbackComplete = FALSE;
+ Status = Context->Http->Request (Context->Http, &Context->RequestToken);
if (EFI_ERROR (Status)) {
goto Error;
}
@@ -1193,15 +1194,15 @@ SavePortion (
IN CHAR8 *Buffer
)
{
- CHAR16 Progress[HTTP_PROGRESS_MESSAGE_SIZE];
- UINTN NbOfKb;
- UINTN Index;
- UINTN LastStep;
- UINTN Step;
- EFI_STATUS Status;
+ CHAR16 Progress[HTTP_PROGRESS_MESSAGE_SIZE];
+ UINTN NbOfKb;
+ UINTN Index;
+ UINTN LastStep;
+ UINTN Step;
+ EFI_STATUS Status;
LastStep = 0;
- Step = 0;
+ Step = 0;
ShellSetFilePosition (mFileHandle, Context->LastReportedNbOfBytes);
Status = ShellWriteFile (mFileHandle, &DownloadLen, Buffer);
@@ -1219,14 +1220,14 @@ SavePortion (
}
Context->ContentDownloaded += DownloadLen;
- NbOfKb = Context->ContentDownloaded >> 10;
+ NbOfKb = Context->ContentDownloaded >> 10;
Progress[0] = L'\0';
if (Context->ContentLength) {
- LastStep = (Context->LastReportedNbOfBytes * HTTP_PROGRESS_SLIDER_STEPS) /
- Context->ContentLength;
- Step = (Context->ContentDownloaded * HTTP_PROGRESS_SLIDER_STEPS) /
- Context->ContentLength;
+ LastStep = (Context->LastReportedNbOfBytes * HTTP_PROGRESS_SLIDER_STEPS) /
+ Context->ContentLength;
+ Step = (Context->ContentDownloaded * HTTP_PROGRESS_SLIDER_STEPS) /
+ Context->ContentLength;
}
Context->LastReportedNbOfBytes = Context->ContentDownloaded;
@@ -1265,7 +1266,6 @@ SavePortion (
NbOfKb
);
-
ShellPrintEx (-1, -1, L"%s", Progress);
return EFI_SUCCESS;
@@ -1286,29 +1286,29 @@ SavePortion (
STATIC
EFI_STATUS
SetHostURI (
- IN CHAR8 *Location,
- IN HTTP_DOWNLOAD_CONTEXT *Context,
- IN CHAR16 *DownloadUrl
+ IN CHAR8 *Location,
+ IN HTTP_DOWNLOAD_CONTEXT *Context,
+ IN CHAR16 *DownloadUrl
)
{
- EFI_STATUS Status;
- UINTN StringSize;
- UINTN FirstStep;
- UINTN Idx;
- UINTN Step;
- CHAR8 *Walker;
- CHAR16 *Temp;
- CHAR8 *Tmp;
- CHAR16 *Url;
- BOOLEAN IsAbEmptyUrl;
-
- Tmp = NULL;
- Url = NULL;
+ EFI_STATUS Status;
+ UINTN StringSize;
+ UINTN FirstStep;
+ UINTN Idx;
+ UINTN Step;
+ CHAR8 *Walker;
+ CHAR16 *Temp;
+ CHAR8 *Tmp;
+ CHAR16 *Url;
+ BOOLEAN IsAbEmptyUrl;
+
+ Tmp = NULL;
+ Url = NULL;
IsAbEmptyUrl = FALSE;
- FirstStep = 0;
+ FirstStep = 0;
StringSize = (AsciiStrSize (Location) * sizeof (CHAR16));
- Url = AllocateZeroPool (StringSize);
+ Url = AllocateZeroPool (StringSize);
if (!Url) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1320,7 +1320,7 @@ SetHostURI (
);
if (EFI_ERROR (Status)) {
- goto Error;
+ goto Error;
}
//
@@ -1347,11 +1347,11 @@ SetHostURI (
}
if (AsciiStrStr (Location, "://") || IsAbEmptyUrl) {
- Idx = 0;
+ Idx = 0;
Walker = Location;
for (Step = FirstStep; Step < 2; Step++) {
- for (; *Walker != '/' && *Walker != '\0'; Walker++) {
+ for ( ; *Walker != '/' && *Walker != '\0'; Walker++) {
Idx++;
}
@@ -1359,7 +1359,7 @@ SetHostURI (
//
// Skip "//"
//
- Idx += 2;
+ Idx += 2;
Walker += 2;
}
}
@@ -1375,7 +1375,7 @@ SetHostURI (
//
// Location now points to Uri
//
- Location += Idx;
+ Location += Idx;
StringSize = (Idx + 1) * sizeof (CHAR16);
SHELL_FREE_NON_NULL (Context->ServerAddrAndProto);
@@ -1421,7 +1421,7 @@ SetHostURI (
SHELL_FREE_NON_NULL (Context->Uri);
- StringSize = AsciiStrSize (Location) * sizeof (CHAR16);
+ StringSize = AsciiStrSize (Location) * sizeof (CHAR16);
Context->Uri = AllocateZeroPool (StringSize);
if (!Context->Uri) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1460,15 +1460,15 @@ STATIC
EFI_STATUS
EFIAPI
ParseMsg (
- IN HTTP_BODY_PARSE_EVENT EventType,
- IN CHAR8 *Data,
- IN UINTN Length,
- IN VOID *Context
+ IN HTTP_BODY_PARSE_EVENT EventType,
+ IN CHAR8 *Data,
+ IN UINTN Length,
+ IN VOID *Context
)
{
- if ((Data == NULL)
- || (EventType == BodyParseEventOnComplete)
- || (Context == NULL))
+ if ( (Data == NULL)
+ || (EventType == BodyParseEventOnComplete)
+ || (Context == NULL))
{
return EFI_SUCCESS;
}
@@ -1476,7 +1476,6 @@ ParseMsg (
return SavePortion (Context, Length, Data);
}
-
/**
Get HTTP server response and collect the whole body as a file.
Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR).
@@ -1498,38 +1497,38 @@ ParseMsg (
STATIC
EFI_STATUS
GetResponse (
- IN HTTP_DOWNLOAD_CONTEXT *Context,
- IN CHAR16 *DownloadUrl
+ IN HTTP_DOWNLOAD_CONTEXT *Context,
+ IN CHAR16 *DownloadUrl
)
{
- EFI_HTTP_RESPONSE_DATA ResponseData;
- EFI_HTTP_MESSAGE ResponseMessage;
- EFI_HTTP_HEADER *Header;
- EFI_STATUS Status;
- VOID *MsgParser;
- EFI_TIME StartTime;
- EFI_TIME EndTime;
- CONST CHAR16 *Desc;
- UINTN ElapsedSeconds;
- BOOLEAN IsTrunked;
- BOOLEAN CanMeasureTime;
+ EFI_HTTP_RESPONSE_DATA ResponseData;
+ EFI_HTTP_MESSAGE ResponseMessage;
+ EFI_HTTP_HEADER *Header;
+ EFI_STATUS Status;
+ VOID *MsgParser;
+ EFI_TIME StartTime;
+ EFI_TIME EndTime;
+ CONST CHAR16 *Desc;
+ UINTN ElapsedSeconds;
+ BOOLEAN IsTrunked;
+ BOOLEAN CanMeasureTime;
ZeroMem (&ResponseData, sizeof (ResponseData));
ZeroMem (&ResponseMessage, sizeof (ResponseMessage));
ZeroMem (&Context->ResponseToken, sizeof (Context->ResponseToken));
IsTrunked = FALSE;
- ResponseMessage.Body = Context->Buffer;
- Context->ResponseToken.Status = EFI_SUCCESS;
+ ResponseMessage.Body = Context->Buffer;
+ Context->ResponseToken.Status = EFI_SUCCESS;
Context->ResponseToken.Message = &ResponseMessage;
- Context->ContentLength = 0;
- Context->Status = REQ_OK;
- Status = EFI_SUCCESS;
- MsgParser = NULL;
- ResponseData.StatusCode = HTTP_STATUS_UNSUPPORTED_STATUS;
- ResponseMessage.Data.Response = &ResponseData;
- Context->ResponseToken.Event = NULL;
- CanMeasureTime = FALSE;
+ Context->ContentLength = 0;
+ Context->Status = REQ_OK;
+ Status = EFI_SUCCESS;
+ MsgParser = NULL;
+ ResponseData.StatusCode = HTTP_STATUS_UNSUPPORTED_STATUS;
+ ResponseMessage.Data.Response = &ResponseData;
+ Context->ResponseToken.Event = NULL;
+ CanMeasureTime = FALSE;
if (Context->Flags & DL_FLAG_TIME) {
ZeroMem (&StartTime, sizeof (StartTime));
CanMeasureTime = !EFI_ERROR (gRT->GetTime (&StartTime, NULL));
@@ -1538,8 +1537,8 @@ GetResponse (
do {
SHELL_FREE_NON_NULL (ResponseMessage.Headers);
ResponseMessage.HeaderCount = 0;
- gResponseCallbackComplete = FALSE;
- ResponseMessage.BodyLength = Context->BufferSize;
+ gResponseCallbackComplete = FALSE;
+ ResponseMessage.BodyLength = Context->BufferSize;
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
@@ -1642,8 +1641,8 @@ GetResponse (
HttpGetEntityLength (MsgParser, &Context->ContentLength);
- if (ResponseData.StatusCode >= HTTP_STATUS_400_BAD_REQUEST
- && (ResponseData.StatusCode != HTTP_STATUS_308_PERMANENT_REDIRECT))
+ if ( (ResponseData.StatusCode >= HTTP_STATUS_400_BAD_REQUEST)
+ && (ResponseData.StatusCode != HTTP_STATUS_308_PERMANENT_REDIRECT))
{
//
// Server reported an error via Response code.
@@ -1665,7 +1664,7 @@ GetResponse (
// This gives an RFC HTTP error.
//
Context->Status = ShellStrToUintn (Desc);
- Status = ENCODE_ERROR (Context->Status);
+ Status = ENCODE_ERROR (Context->Status);
}
}
}
@@ -1680,13 +1679,13 @@ GetResponse (
ResponseMessage.Body
);
}
- } while (!HttpIsMessageComplete (MsgParser)
- && !EFI_ERROR (Status)
- && ResponseMessage.BodyLength);
+ } while ( !HttpIsMessageComplete (MsgParser)
+ && !EFI_ERROR (Status)
+ && ResponseMessage.BodyLength);
- if (Context->Status != REQ_NEED_REPEAT
- && Status == EFI_SUCCESS
- && CanMeasureTime)
+ if ( (Context->Status != REQ_NEED_REPEAT)
+ && (Status == EFI_SUCCESS)
+ && CanMeasureTime)
{
if (!EFI_ERROR (gRT->GetTime (&EndTime, NULL))) {
ElapsedSeconds = EfiTimeToEpoch (&EndTime) - EfiTimeToEpoch (&StartTime);
@@ -1726,22 +1725,22 @@ GetResponse (
STATIC
EFI_STATUS
DownloadFile (
- IN HTTP_DOWNLOAD_CONTEXT *Context,
- IN EFI_HANDLE ControllerHandle,
- IN CHAR16 *NicName
+ IN HTTP_DOWNLOAD_CONTEXT *Context,
+ IN EFI_HANDLE ControllerHandle,
+ IN CHAR16 *NicName
)
{
- EFI_STATUS Status;
- CHAR16 *DownloadUrl;
- UINTN UrlSize;
- EFI_HANDLE HttpChildHandle;
+ EFI_STATUS Status;
+ CHAR16 *DownloadUrl;
+ UINTN UrlSize;
+ EFI_HANDLE HttpChildHandle;
ASSERT (Context);
if (Context == NULL) {
return EFI_INVALID_PARAMETER;
}
- DownloadUrl = NULL;
+ DownloadUrl = NULL;
HttpChildHandle = NULL;
Context->Buffer = AllocatePool (Context->BufferSize);
@@ -1780,7 +1779,7 @@ DownloadFile (
&gEfiHttpServiceBindingProtocolGuid,
&gEfiHttpProtocolGuid,
&HttpChildHandle,
- (VOID**)&Context->Http
+ (VOID **)&Context->Http
);
if (EFI_ERROR (Status)) {
@@ -1794,7 +1793,7 @@ DownloadFile (
goto ON_EXIT;
}
- UrlSize = 0;
+ UrlSize = 0;
DownloadUrl = StrnCatGrow (
&DownloadUrl,
&UrlSize,
@@ -1814,7 +1813,8 @@ DownloadFile (
&DownloadUrl,
&UrlSize,
Context->Uri,
- StrLen (Context->Uri));
+ StrLen (Context->Uri)
+ );
PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING), DownloadUrl);
@@ -1828,7 +1828,6 @@ DownloadFile (
if (Status) {
goto ON_EXIT;
}
-
} while (Context->Status == REQ_NEED_REPEAT);
if (Context->Status) {
@@ -1864,12 +1863,12 @@ ON_EXIT:
**/
EFI_HII_HANDLE
InitializeHiiPackage (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_HII_HANDLE HiiHandle;
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+ EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle.
@@ -1891,11 +1890,11 @@ InitializeHiiPackage (
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
- gHiiDatabase,
- PackageList,
- NULL,
- &HiiHandle
- );
+ gHiiDatabase,
+ PackageList,
+ NULL,
+ &HiiHandle
+ );
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
diff --git a/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h b/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h
index fa8b6f5..f6c4b2c 100644
--- a/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h
+++ b/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h
@@ -32,7 +32,7 @@
#include <Protocol/HttpUtilities.h>
#include <Protocol/ServiceBinding.h>
-#define HTTP_APP_NAME L"http"
+#define HTTP_APP_NAME L"http"
#define REQ_OK 0
#define REQ_NEED_REPEAT 1
@@ -40,25 +40,25 @@
//
// Download Flags.
//
-#define DL_FLAG_TIME BIT0 // Show elapsed time.
-#define DL_FLAG_KEEP_BAD BIT1 // Keep files even if download failed.
+#define DL_FLAG_TIME BIT0 // Show elapsed time.
+#define DL_FLAG_KEEP_BAD BIT1 // Keep files even if download failed.
-extern EFI_HII_HANDLE mHttpHiiHandle;
+extern EFI_HII_HANDLE mHttpHiiHandle;
typedef struct {
- UINTN ContentDownloaded;
- UINTN ContentLength;
- UINTN LastReportedNbOfBytes;
- UINTN BufferSize;
- UINTN Status;
- UINTN Flags;
- UINT8 *Buffer;
- CHAR16 *ServerAddrAndProto;
- CHAR16 *Uri;
- EFI_HTTP_TOKEN ResponseToken;
- EFI_HTTP_TOKEN RequestToken;
- EFI_HTTP_PROTOCOL *Http;
- EFI_HTTP_CONFIG_DATA HttpConfigData;
+ UINTN ContentDownloaded;
+ UINTN ContentLength;
+ UINTN LastReportedNbOfBytes;
+ UINTN BufferSize;
+ UINTN Status;
+ UINTN Flags;
+ UINT8 *Buffer;
+ CHAR16 *ServerAddrAndProto;
+ CHAR16 *Uri;
+ EFI_HTTP_TOKEN ResponseToken;
+ EFI_HTTP_TOKEN RequestToken;
+ EFI_HTTP_PROTOCOL *Http;
+ EFI_HTTP_CONFIG_DATA HttpConfigData;
} HTTP_DOWNLOAD_CONTEXT;
/**
@@ -87,6 +87,7 @@ RunHttp (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
);
+
#endif // _HTTP_H_
diff --git a/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c b/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c
index a7d2c27..6622e05 100644
--- a/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c
+++ b/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c
@@ -20,7 +20,7 @@
* 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_HTTP);
+EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_HTTP);
/**
Entry point of Http standalone application.
@@ -35,12 +35,12 @@ EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_HTTP);
EFI_STATUS
EFIAPI
HttpAppInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
+ EFI_STATUS Status;
+ SHELL_STATUS ShellStatus;
mHttpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mHttpHiiHandle == NULL) {
diff --git a/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c b/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c
index 7f59cc7..45aeaac 100644
--- a/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c
+++ b/ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c
@@ -28,10 +28,10 @@
SHELL_STATUS
EFIAPI
HttpCommandHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
+ 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;
@@ -53,8 +53,8 @@ HttpCommandHandler (
CHAR16 *
EFIAPI
HttpCommandGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
+ IN CONST CHAR8 *Language
)
{
return HiiGetString (
@@ -64,7 +64,7 @@ HttpCommandGetHelp (
);
}
-EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
HTTP_APP_NAME,
HttpCommandHandler,
HttpCommandGetHelp
@@ -85,11 +85,11 @@ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
EFI_STATUS
EFIAPI
HttpCommandInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mHttpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mHttpHiiHandle == NULL) {
@@ -117,10 +117,10 @@ HttpCommandInitialize (
EFI_STATUS
EFIAPI
HttpUnload (
- IN EFI_HANDLE ImageHandle
-)
+ IN EFI_HANDLE ImageHandle
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface (
ImageHandle,
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
index 4e296c4..7e5c73b 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
@@ -10,8 +10,8 @@
#include "Tftp.h"
-#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
-EFI_HII_HANDLE mTftpHiiHandle;
+#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
+EFI_HII_HANDLE mTftpHiiHandle;
/*
Constant strings and definitions related to the message indicating the amount of
@@ -19,7 +19,7 @@ EFI_HII_HANDLE mTftpHiiHandle;
*/
// Frame for the progression slider
-STATIC CONST CHAR16 mTftpProgressFrame[] = L"[ ]";
+STATIC CONST CHAR16 mTftpProgressFrame[] = L"[ ]";
// Number of steps in the progression slider
#define TFTP_PROGRESS_SLIDER_STEPS ((sizeof (mTftpProgressFrame) / sizeof (CHAR16)) - 3)
@@ -33,13 +33,13 @@ STATIC CONST CHAR16 mTftpProgressFrame[] = L"[
// String to delete the TFTP progress message to be able to update it :
// (TFTP_PROGRESS_MESSAGE_SIZE-1) '\b'
-STATIC CONST CHAR16 mTftpProgressDelete[] = L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
+STATIC CONST CHAR16 mTftpProgressDelete[] = L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
// Local File Handle
-SHELL_FILE_HANDLE mFileHandle;
+SHELL_FILE_HANDLE mFileHandle;
// Path of the local file, Unicode encoded
-CONST CHAR16 *mLocalFilePath;
+CONST CHAR16 *mLocalFilePath;
/**
Check and convert the UINT16 option values of the 'tftp' command
@@ -206,49 +206,57 @@ CheckPacket (
IN EFI_MTFTP4_PACKET *Packet
);
-EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
+EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
TRUE, // Use default setting
- { { 0, 0, 0, 0 } }, // StationIp - Not relevant as UseDefaultSetting=TRUE
- { { 0, 0, 0, 0 } }, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
+ {
+ { 0, 0, 0, 0 }
+ }, // StationIp - Not relevant as UseDefaultSetting=TRUE
+ {
+ { 0, 0, 0, 0 }
+ }, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
0, // LocalPort - Automatically assigned port number.
- { { 0, 0, 0, 0 } }, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
- { { 0, 0, 0, 0 } }, // ServerIp - Not known yet
+ {
+ { 0, 0, 0, 0 }
+ }, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
+ {
+ { 0, 0, 0, 0 }
+ }, // ServerIp - Not known yet
69, // InitialServerPort - Standard TFTP server port
6, // TryCount - The number of times to transmit request packets and wait for a response.
4 // TimeoutValue - Retransmission timeout in seconds.
};
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-i", TypeValue},
- {L"-l", TypeValue},
- {L"-r", TypeValue},
- {L"-c", TypeValue},
- {L"-t", TypeValue},
- {L"-s", TypeValue},
- {L"-w", TypeValue},
- {NULL , TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-i", TypeValue },
+ { L"-l", TypeValue },
+ { L"-r", TypeValue },
+ { L"-c", TypeValue },
+ { L"-t", TypeValue },
+ { L"-s", TypeValue },
+ { L"-w", TypeValue },
+ { NULL, TypeMax }
+};
///
/// The default block size (512) of tftp is defined in the RFC1350.
///
-#define MTFTP_DEFAULT_BLKSIZE 512
+#define MTFTP_DEFAULT_BLKSIZE 512
///
/// The valid range of block size option is defined in the RFC2348.
///
-#define MTFTP_MIN_BLKSIZE 8
-#define MTFTP_MAX_BLKSIZE 65464
+#define MTFTP_MIN_BLKSIZE 8
+#define MTFTP_MAX_BLKSIZE 65464
///
/// The default windowsize (1) of tftp.
///
-#define MTFTP_DEFAULT_WINDOWSIZE 1
+#define MTFTP_DEFAULT_WINDOWSIZE 1
///
/// The valid range of window size option.
/// Note that: RFC 7440 does not mention max window size value, but for the
/// stability reason, the value is limited to 64.
///
-#define MTFTP_MIN_WINDOWSIZE 1
-#define MTFTP_MAX_WINDOWSIZE 64
+#define MTFTP_MIN_WINDOWSIZE 1
+#define MTFTP_MAX_WINDOWSIZE 64
/**
Function for 'tftp' command.
@@ -319,15 +327,22 @@ RunTftp (
Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) &&
- (ProblemParam != NULL) ) {
+ (ProblemParam != NULL))
+ {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), mTftpHiiHandle,
- L"tftp", ProblemParam
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM),
+ mTftpHiiHandle,
+ L"tftp",
+ ProblemParam
);
FreePool (ProblemParam);
} else {
ASSERT (FALSE);
}
+
goto Error;
}
@@ -337,15 +352,24 @@ RunTftp (
ParamCount = ShellCommandLineGetCount (CheckPackage);
if (ParamCount > 4) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
- mTftpHiiHandle, L"tftp"
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_TOO_MANY),
+ mTftpHiiHandle,
+ L"tftp"
);
goto Error;
}
+
if (ParamCount < 3) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
- mTftpHiiHandle, L"tftp"
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_TOO_FEW),
+ mTftpHiiHandle,
+ L"tftp"
);
goto Error;
}
@@ -356,23 +380,29 @@ RunTftp (
// Check the host IPv4 address
//
ValueStr = ShellCommandLineGetRawValue (CheckPackage, 1);
- Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
+ Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- mTftpHiiHandle, L"tftp", ValueStr
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PARAM_INV),
+ mTftpHiiHandle,
+ L"tftp",
+ ValueStr
+ );
goto Error;
}
RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2);
- ASSERT(RemoteFilePath != NULL);
- FilePathSize = StrLen (RemoteFilePath) + 1;
+ ASSERT (RemoteFilePath != NULL);
+ FilePathSize = StrLen (RemoteFilePath) + 1;
AsciiRemoteFilePath = AllocatePool (FilePathSize);
if (AsciiRemoteFilePath == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Error;
}
+
UnicodeStrToAsciiStrS (RemoteFilePath, AsciiRemoteFilePath, FilePathSize);
if (ParamCount == 4) {
@@ -381,10 +411,12 @@ RunTftp (
Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') ||
- (*Walker == L'/' ) ) {
+ (*Walker == L'/'))
+ {
break;
}
}
+
mLocalFilePath = Walker + 1;
}
@@ -423,11 +455,17 @@ RunTftp (
if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TimeoutValue)) {
goto Error;
}
+
if (Mtftp4ConfigData.TimeoutValue == 0) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- mTftpHiiHandle, L"tftp", ValueStr
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PARAM_INV),
+ mTftpHiiHandle,
+ L"tftp",
+ ValueStr
+ );
goto Error;
}
}
@@ -437,11 +475,17 @@ RunTftp (
if (!StringToUint16 (ValueStr, &BlockSize)) {
goto Error;
}
- if (BlockSize < MTFTP_MIN_BLKSIZE || BlockSize > MTFTP_MAX_BLKSIZE) {
+
+ if ((BlockSize < MTFTP_MIN_BLKSIZE) || (BlockSize > MTFTP_MAX_BLKSIZE)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- mTftpHiiHandle, L"tftp", ValueStr
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PARAM_INV),
+ mTftpHiiHandle,
+ L"tftp",
+ ValueStr
+ );
goto Error;
}
}
@@ -451,11 +495,17 @@ RunTftp (
if (!StringToUint16 (ValueStr, &WindowSize)) {
goto Error;
}
- if (WindowSize < MTFTP_MIN_WINDOWSIZE || WindowSize > MTFTP_MAX_WINDOWSIZE) {
+
+ if ((WindowSize < MTFTP_MIN_WINDOWSIZE) || (WindowSize > MTFTP_MAX_WINDOWSIZE)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- mTftpHiiHandle, L"tftp", ValueStr
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PARAM_INV),
+ mTftpHiiHandle,
+ L"tftp",
+ ValueStr
+ );
goto Error;
}
}
@@ -464,32 +514,41 @@ RunTftp (
// Locate all MTFTP4 Service Binding protocols
//
ShellStatus = SHELL_NOT_FOUND;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiManagedNetworkServiceBindingProtocolGuid,
- NULL,
- &HandleCount,
- &Handles
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiManagedNetworkServiceBindingProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
if (EFI_ERROR (Status) || (HandleCount == 0)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
mTftpHiiHandle
- );
+ );
goto Error;
}
for (NicNumber = 0;
(NicNumber < HandleCount) && (ShellStatus != SHELL_SUCCESS);
- NicNumber++) {
+ NicNumber++)
+ {
ControllerHandle = Handles[NicNumber];
Status = GetNicName (ControllerHandle, NicNumber, NicName);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
- mTftpHiiHandle, NicNumber, Status
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
+ mTftpHiiHandle,
+ NicNumber,
+ Status
+ );
continue;
}
@@ -497,6 +556,7 @@ RunTftp (
if (StrCmp (NicName, UserNicName) != 0) {
continue;
}
+
NicFound = TRUE;
}
@@ -505,46 +565,68 @@ RunTftp (
&gEfiMtftp4ServiceBindingProtocolGuid,
&gEfiMtftp4ProtocolGuid,
&Mtftp4ChildHandle,
- (VOID**)&Mtftp4
+ (VOID **)&Mtftp4
);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
- mTftpHiiHandle, NicName, Status
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
+ mTftpHiiHandle,
+ NicName,
+ Status
+ );
continue;
}
Status = Mtftp4->Configure (Mtftp4, &Mtftp4ConfigData);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
- mTftpHiiHandle, NicName, Status
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
+ mTftpHiiHandle,
+ NicName,
+ Status
+ );
goto NextHandle;
}
Status = GetFileSize (Mtftp4, AsciiRemoteFilePath, &FileSize);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
- mTftpHiiHandle, RemoteFilePath, NicName, Status
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
+ mTftpHiiHandle,
+ RemoteFilePath,
+ NicName,
+ Status
+ );
goto NextHandle;
}
Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, BlockSize, WindowSize);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
- mTftpHiiHandle, RemoteFilePath, NicName, Status
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
+ mTftpHiiHandle,
+ RemoteFilePath,
+ NicName,
+ Status
+ );
goto NextHandle;
}
ShellStatus = SHELL_SUCCESS;
- NextHandle:
+NextHandle:
CloseProtocolAndDestroyServiceChild (
ControllerHandle,
@@ -556,22 +638,27 @@ RunTftp (
if ((UserNicName != NULL) && (!NicFound)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
- mTftpHiiHandle, UserNicName
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
+ mTftpHiiHandle,
+ UserNicName
+ );
}
- Error:
+Error:
ShellCommandLineFreeVarList (CheckPackage);
if (AsciiRemoteFilePath != NULL) {
FreePool (AsciiRemoteFilePath);
}
+
if (Handles != NULL) {
FreePool (Handles);
}
- if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR(Status))) {
+ if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR (Status))) {
ShellStatus = Status & ~MAX_BIT;
}
@@ -599,9 +686,14 @@ StringToUint16 (
Val = ShellStrToUintn (ValueStr);
if (Val > MAX_UINT16) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- mTftpHiiHandle, L"tftp", ValueStr
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PARAM_INV),
+ mTftpHiiHandle,
+ L"tftp",
+ ValueStr
+ );
return FALSE;
}
@@ -645,7 +737,7 @@ GetNicName (
&gEfiManagedNetworkServiceBindingProtocolGuid,
&gEfiManagedNetworkProtocolGuid,
&MnpHandle,
- (VOID**)&Mnp
+ (VOID **)&Mnp
);
if (EFI_ERROR (Status)) {
goto Error;
@@ -661,7 +753,7 @@ GetNicName (
IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH,
SnpMode.IfType == NET_IFTYPE_ETHERNET ?
L"eth%d" :
- L"unk%d" ,
+ L"unk%d",
NicNumber
);
@@ -713,12 +805,12 @@ CreateServiceChildAndOpenProtocol (
EFI_STATUS Status;
*ChildHandle = NULL;
- Status = NetLibCreateServiceChild (
- ControllerHandle,
- gImageHandle,
- ServiceBindingProtocolGuid,
- ChildHandle
- );
+ Status = NetLibCreateServiceChild (
+ ControllerHandle,
+ gImageHandle,
+ ServiceBindingProtocolGuid,
+ ChildHandle
+ );
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
*ChildHandle,
@@ -810,21 +902,21 @@ GetFileSize (
UINT32 OptCnt;
UINT8 OptBuf[128];
- ReqOpt[0].OptionStr = (UINT8*)"tsize";
- OptBuf[0] = '0';
- OptBuf[1] = 0;
- ReqOpt[0].ValueStr = OptBuf;
+ ReqOpt[0].OptionStr = (UINT8 *)"tsize";
+ OptBuf[0] = '0';
+ OptBuf[1] = 0;
+ ReqOpt[0].ValueStr = OptBuf;
Status = Mtftp4->GetInfo (
- Mtftp4,
- NULL,
- (UINT8*)FilePath,
- NULL,
- 1,
- ReqOpt,
- &PktLen,
- &Packet
- );
+ Mtftp4,
+ NULL,
+ (UINT8 *)FilePath,
+ NULL,
+ 1,
+ ReqOpt,
+ &PktLen,
+ &Packet
+ );
if (EFI_ERROR (Status)) {
goto Error;
@@ -834,7 +926,7 @@ GetFileSize (
Mtftp4,
PktLen,
Packet,
- (UINT32 *) &OptCnt,
+ (UINT32 *)&OptCnt,
&TableOfOptions
);
if (EFI_ERROR (Status)) {
@@ -847,16 +939,18 @@ GetFileSize (
*FileSize = AsciiStrDecimalToUintn ((CHAR8 *)Option->ValueStr);
break;
}
+
OptCnt--;
Option++;
}
+
FreePool (TableOfOptions);
if (OptCnt == 0) {
Status = EFI_UNSUPPORTED;
}
-Error :
+Error:
return Status;
}
@@ -889,11 +983,11 @@ DownloadFile (
IN UINT16 WindowSize
)
{
- EFI_STATUS Status;
- DOWNLOAD_CONTEXT *TftpContext;
- EFI_MTFTP4_TOKEN Mtftp4Token;
- UINT8 BlksizeBuf[10];
- UINT8 WindowsizeBuf[10];
+ EFI_STATUS Status;
+ DOWNLOAD_CONTEXT *TftpContext;
+ EFI_MTFTP4_TOKEN Mtftp4Token;
+ UINT8 BlksizeBuf[10];
+ UINT8 WindowsizeBuf[10];
ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN));
@@ -902,13 +996,14 @@ DownloadFile (
Status = EFI_OUT_OF_RESOURCES;
goto Error;
}
- TftpContext->FileSize = FileSize;
+
+ TftpContext->FileSize = FileSize;
TftpContext->DownloadedNbOfBytes = 0;
TftpContext->LastReportedNbOfBytes = 0;
- Mtftp4Token.Filename = (UINT8*)AsciiFilePath;
+ Mtftp4Token.Filename = (UINT8 *)AsciiFilePath;
Mtftp4Token.CheckPacket = CheckPacket;
- Mtftp4Token.Context = (VOID*)TftpContext;
+ Mtftp4Token.Context = (VOID *)TftpContext;
Mtftp4Token.OptionCount = 0;
Mtftp4Token.OptionList = AllocatePool (sizeof (EFI_MTFTP4_OPTION) * 2);
if (Mtftp4Token.OptionList == NULL) {
@@ -917,22 +1012,26 @@ DownloadFile (
}
if (BlockSize != MTFTP_DEFAULT_BLKSIZE) {
- Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *) "blksize";
- AsciiSPrint ((CHAR8 *) BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockSize);
- Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = BlksizeBuf;
- Mtftp4Token.OptionCount ++;
+ Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *)"blksize";
+ AsciiSPrint ((CHAR8 *)BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockSize);
+ Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = BlksizeBuf;
+ Mtftp4Token.OptionCount++;
}
if (WindowSize != MTFTP_DEFAULT_WINDOWSIZE) {
- Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *) "windowsize";
- AsciiSPrint ((CHAR8 *) WindowsizeBuf, sizeof (WindowsizeBuf), "%d", WindowSize);
- Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = WindowsizeBuf;
- Mtftp4Token.OptionCount ++;
+ Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *)"windowsize";
+ AsciiSPrint ((CHAR8 *)WindowsizeBuf, sizeof (WindowsizeBuf), "%d", WindowSize);
+ Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = WindowsizeBuf;
+ Mtftp4Token.OptionCount++;
}
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING),
- mTftpHiiHandle, FilePath
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_DOWNLOADING),
+ mTftpHiiHandle,
+ FilePath
);
//
@@ -943,24 +1042,32 @@ DownloadFile (
}
Status = ShellOpenFileByName (
- mLocalFilePath,
- &mFileHandle,
- EFI_FILE_MODE_CREATE |
- EFI_FILE_MODE_WRITE |
- EFI_FILE_MODE_READ,
- 0
- );
+ mLocalFilePath,
+ &mFileHandle,
+ EFI_FILE_MODE_CREATE |
+ EFI_FILE_MODE_WRITE |
+ EFI_FILE_MODE_READ,
+ 0
+ );
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
- mTftpHiiHandle, L"tftp", mLocalFilePath
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
+ mTftpHiiHandle,
+ L"tftp",
+ mLocalFilePath
+ );
goto Error;
}
Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_CRLF),
mTftpHiiHandle
);
@@ -969,7 +1076,7 @@ DownloadFile (
//
ShellCloseFile (&mFileHandle);
-Error :
+Error:
if (TftpContext != NULL) {
FreePool (TftpContext);
}
@@ -1016,7 +1123,7 @@ CheckPacket (
return EFI_SUCCESS;
}
- Context = (DOWNLOAD_CONTEXT*)Token->Context;
+ Context = (DOWNLOAD_CONTEXT *)Token->Context;
//
// The data in the packet are prepended with two UINT16 :
@@ -1025,19 +1132,28 @@ CheckPacket (
//
DownloadLen = (UINTN)PacketLen - sizeof (Packet->OpCode) - sizeof (Packet->Data.Block);
- ShellSetFilePosition(mFileHandle, Context->DownloadedNbOfBytes);
+ ShellSetFilePosition (mFileHandle, Context->DownloadedNbOfBytes);
Status = ShellWriteFile (mFileHandle, &DownloadLen, Packet->Data.Data);
if (EFI_ERROR (Status)) {
if (Context->DownloadedNbOfBytes > 0) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_CRLF),
mTftpHiiHandle
- );
+ );
}
+
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_WRITE),
- mTftpHiiHandle, mLocalFilePath, Status
- );
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_TFTP_ERR_WRITE),
+ mTftpHiiHandle,
+ mLocalFilePath,
+ Status
+ );
return Status;
}
@@ -1046,11 +1162,11 @@ CheckPacket (
}
Context->DownloadedNbOfBytes += DownloadLen;
- NbOfKb = Context->DownloadedNbOfBytes / 1024;
+ NbOfKb = Context->DownloadedNbOfBytes / 1024;
Progress[0] = L'\0';
- LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
- Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
+ LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
+ Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
if (Step <= LastStep) {
return EFI_SUCCESS;
@@ -1059,12 +1175,14 @@ CheckPacket (
ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete);
Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
+
for (Index = 1; Index < Step; Index++) {
Progress[Index] = L'=';
}
+
Progress[Step] = L'>';
UnicodeSPrint (
@@ -1089,12 +1207,12 @@ CheckPacket (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
- EFI_HANDLE ImageHandle
+ EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_HII_HANDLE HiiHandle;
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+ EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
@@ -1125,5 +1243,6 @@ InitializeHiiPackage (
if (EFI_ERROR (Status)) {
return NULL;
}
+
return HiiHandle;
}
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
index c46a0d5..89cb79c 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
@@ -30,12 +30,12 @@
#include <Library/PrintLib.h>
#include <Library/UefiHiiServicesLib.h>
-extern EFI_HII_HANDLE mTftpHiiHandle;
+extern EFI_HII_HANDLE mTftpHiiHandle;
typedef struct {
- UINTN FileSize;
- UINTN DownloadedNbOfBytes;
- UINTN LastReportedNbOfBytes;
+ UINTN FileSize;
+ UINTN DownloadedNbOfBytes;
+ UINTN LastReportedNbOfBytes;
} DOWNLOAD_CONTEXT;
/**
@@ -64,6 +64,7 @@ RunTftp (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
- EFI_HANDLE ImageHandle
+ EFI_HANDLE ImageHandle
);
+
#endif // _TFTP_H_
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c
index 0972454..5af7784 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c
@@ -17,7 +17,7 @@
// 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_TFTP);
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);
/**
Entry point of Tftp standalone application.
@@ -32,11 +32,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (S
EFI_STATUS
EFIAPI
TftpAppInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mTftpHiiHandle == NULL) {
return EFI_ABORTED;
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c
index 8e5df7b..23c86a7 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c
@@ -26,10 +26,10 @@
SHELL_STATUS
EFIAPI
TftpCommandHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
+ 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;
@@ -50,14 +50,14 @@ TftpCommandHandler (
CHAR16 *
EFIAPI
TftpCommandGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
+ IN CONST CHAR8 *Language
)
{
return HiiGetString (mTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP), Language);
}
-EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
L"tftp",
TftpCommandHandler,
TftpCommandGetHelp
@@ -78,11 +78,12 @@ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
EFI_STATUS
EFIAPI
TftpCommandInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mTftpHiiHandle == NULL) {
return EFI_ABORTED;
@@ -109,10 +110,11 @@ TftpCommandInitialize (
EFI_STATUS
EFIAPI
TftpUnload (
- IN EFI_HANDLE ImageHandle
-)
+ IN EFI_HANDLE ImageHandle
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
Status = gBS->UninstallProtocolInterface (
ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
@@ -121,6 +123,7 @@ TftpUnload (
if (EFI_ERROR (Status)) {
return Status;
}
+
HiiRemovePackages (mTftpHiiHandle);
return EFI_SUCCESS;
}