diff options
| author | Oliver Smith-Denny <osde@microsoft.com> | 2026-10-01 22:38:03 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2026-10-23 06:44:49 +0300 |
| commit | bbbb761e370379aed5d548cd5c044377fee4daaa (patch) | |
| tree | 56d02029be2c2ede0bfb743a9ebf5572d22e6f14 /MdeModulePkg | |
| parent | 2b2c8374f91a9622b0d49ce7d90ce2bab10c9c6e (diff) | |
| download | edk2-bbbb761e370379aed5d548cd5c044377fee4daaa.tar.xz | |
MdeModulePkg: Use DUMP_HEX Macro
Several places in MdeModulePkg were implementing their
own versions of hex dumping logic; use the DebugLib.h
macro instead.
Prints change slightly, they are now standardized with
uppercase hex, prefixes on every row instead of in the
header only, and VarCheckHiiLib no longer indents rows
with *ASCII*.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
Diffstat (limited to 'MdeModulePkg')
8 files changed, 20 insertions, 287 deletions
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c index 79888bf3a5..23e49f922f 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c @@ -188,33 +188,7 @@ EhcDumpQh ( EhcDumpQtd (Qtd, NULL);
if (DumpBuf && (Qtd->DataLen != 0)) {
- EhcDumpBuf (Qtd->Data, Qtd->DataLen);
+ DUMP_HEX (DEBUG_VERBOSE, 0, Qtd->Data, Qtd->DataLen, "");
}
}
}
-
-/**
- Dump the buffer in the form of hex.
-
- @param Buf The buffer to dump.
- @param Len The length of buffer.
-
-**/
-VOID
-EhcDumpBuf (
- IN UINT8 *Buf,
- IN UINTN Len
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < Len; Index++) {
- if (Index % 16 == 0) {
- DEBUG ((DEBUG_VERBOSE, "\n"));
- }
-
- DEBUG ((DEBUG_VERBOSE, "%02x ", Buf[Index]));
- }
-
- DEBUG ((DEBUG_VERBOSE, "\n"));
-}
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h index dfba501d36..1a0c318b39 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h @@ -36,16 +36,3 @@ EhcDumpQh ( IN CHAR8 *Msg,
IN BOOLEAN DumpBuf
);
-
-/**
- Dump the buffer in the form of hex.
-
- @param Buf The buffer to dump.
- @param Len The length of buffer.
-
-**/
-VOID
-EhcDumpBuf (
- IN UINT8 *Buf,
- IN UINTN Len
- );
diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c index f202e7d679..dd85621260 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c +++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c @@ -113,25 +113,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED SMI_HANDLER_PROFILE_PROTOCOL mSmiHandlerProfile = };
/**
- This function dump raw data.
-
- @param Data raw data
- @param Size raw data size
-**/
-VOID
-InternalDumpData (
- IN UINT8 *Data,
- IN UINTN Size
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < Size; Index++) {
- DEBUG ((DEBUG_INFO, "%02x ", (UINTN)Data[Index]));
- }
-}
-
-/**
Get GUID name for an image.
@param[in] LoadedImage LoadedImage protocol.
@@ -403,9 +384,7 @@ DumpSmiChildContext ( FreePool (Str);
}
} else {
- DEBUG ((DEBUG_INFO, " Context - "));
- InternalDumpData (Context, ContextSize);
- DEBUG ((DEBUG_INFO, "\n"));
+ DUMP_HEX (DEBUG_INFO, 0, Context, ContextSize, " Context - ");
}
}
diff --git a/MdeModulePkg/Library/HobPrintLib/HobPrintLib.c b/MdeModulePkg/Library/HobPrintLib/HobPrintLib.c index 8ff32e5601..fbea333b92 100644 --- a/MdeModulePkg/Library/HobPrintLib/HobPrintLib.c +++ b/MdeModulePkg/Library/HobPrintLib/HobPrintLib.c @@ -54,40 +54,6 @@ CHAR8 *mResource_Type_List[] = { };
/**
- Print the Hex value of a given range.
-
- @param[in] ErrorLevel Error Level to print the Hex value.
- @param[in] DataStart A pointer to the start of data to be printed.
- @param[in] DataSize The length of the data to be printed.
-
- @retval EFI_SUCCESS If it completed successfully.
-**/
-EFI_STATUS
-PrintHex (
- IN UINT32 ErrorLevel,
- IN UINT8 *DataStart,
- IN UINT16 DataSize
- )
-{
- UINTN Index1;
- UINTN Index2;
- UINT8 *StartAddr;
-
- StartAddr = DataStart;
- for (Index1 = 0; Index1 * ROW_LIMITER < DataSize; Index1++) {
- DEBUG ((ErrorLevel, " 0x%04p:", (DataStart - StartAddr)));
- for (Index2 = 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + Index2 < DataSize); Index2++) {
- DEBUG ((ErrorLevel, " %02x", *DataStart));
- DataStart++;
- }
-
- DEBUG ((ErrorLevel, "\n"));
- }
-
- return EFI_SUCCESS;
-}
-
-/**
Print the Hex value of the Invalid HOB.
@param[in] HobStart A pointer to the Invalid HOB.
@@ -102,7 +68,7 @@ PrintInvalidHob ( )
{
DEBUG ((DEBUG_ERROR, " Invalid HOB. Full hex dump in below:\n"));
- PrintHex (DEBUG_ERROR, HobStart, HobLength);
+ DUMP_HEX (DEBUG_ERROR, 0, HobStart, HobLength, "");
return RETURN_INVALID_PARAMETER;
}
@@ -264,7 +230,7 @@ PrintGuidHob ( DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));
DEBUG ((DEBUG_INFO, " DataLength = 0x%x\n", DataLength));
- PrintHex (DEBUG_VERBOSE, GET_GUID_HOB_DATA (Hob.Raw), DataLength);
+ DUMP_HEX (DEBUG_VERBOSE, 0, GET_GUID_HOB_DATA (Hob.Raw), DataLength, "");
return EFI_SUCCESS;
}
@@ -333,7 +299,7 @@ PrintMemoryPoolHob ( AllocationSize = HobLength - sizeof (EFI_HOB_GENERIC_HEADER);
DEBUG ((DEBUG_INFO, " AllocationSize = 0x%lx\n", AllocationSize));
- PrintHex (DEBUG_VERBOSE, Hob.Raw + sizeof (EFI_HOB_GENERIC_HEADER), AllocationSize);
+ DUMP_HEX (DEBUG_VERBOSE, 0, Hob.Raw + sizeof (EFI_HOB_GENERIC_HEADER), AllocationSize, "");
return EFI_SUCCESS;
}
@@ -489,7 +455,7 @@ PrintHobList ( }
} else {
DEBUG ((DEBUG_INFO, " Unknown Hob type, full hex dump in below:\n"));
- PrintHex (DEBUG_INFO, Hob.Raw, Hob.Header->HobLength);
+ DUMP_HEX (DEBUG_INFO, 0, Hob.Raw, Hob.Header->HobLength, "");
}
}
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c index 279daefac1..2ddb6a2d1f 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c @@ -1220,7 +1220,6 @@ BootScriptExecuteInformation ( )
{
- UINT32 Index;
EFI_BOOT_SCRIPT_INFORMATION Information;
UINT8 *InformationData;
@@ -1229,12 +1228,7 @@ BootScriptExecuteInformation ( InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
DEBUG ((DEBUG_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN)InformationData));
- DEBUG ((DEBUG_INFO, "BootScriptInformation: "));
- for (Index = 0; Index < Information.InformationLength; Index++) {
- DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index]));
- }
-
- DEBUG ((DEBUG_INFO, "\n"));
+ DUMP_HEX (DEBUG_INFO, 0, InformationData, Information.InformationLength, "BootScriptInformation: ");
}
/**
@@ -1249,7 +1243,6 @@ BootScriptExecuteLabel ( )
{
- UINT32 Index;
EFI_BOOT_SCRIPT_INFORMATION Information;
UINT8 *InformationData;
@@ -1258,12 +1251,7 @@ BootScriptExecuteLabel ( InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
DEBUG ((DEBUG_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN)InformationData));
- DEBUG ((DEBUG_INFO, "BootScriptLabel: "));
- for (Index = 0; Index < Information.InformationLength; Index++) {
- DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index]));
- }
-
- DEBUG ((DEBUG_INFO, "\n"));
+ DUMP_HEX (DEBUG_INFO, 0, InformationData, Information.InformationLength, "BootScriptLabel: ");
}
/**
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibCommon.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibCommon.c index 00a37df017..35961a2641 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibCommon.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibCommon.c @@ -8,58 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "VarCheckHii.h"
#include "VarCheckHiiLibCommon.h"
-EFI_HANDLE mEfiVariableCheckHiiHandle = NULL;
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-
-/**
- Dump some hexadecimal data.
- @param[in] Indent How many spaces to indent the output.
- @param[in] Offset The offset of the dump.
- @param[in] DataSize The size in bytes of UserData.
- @param[in] UserData The data to dump.
-**/
-VOID
-VarCheckHiiInternalDumpHex (
- IN UINTN Indent,
- IN UINTN Offset,
- IN UINTN DataSize,
- IN VOID *UserData
- )
-{
- UINT8 *Data;
-
- CHAR8 Val[50];
-
- CHAR8 Str[20];
-
- UINT8 TempByte;
- UINTN Size;
- UINTN Index;
-
- Data = UserData;
- while (DataSize != 0) {
- Size = 16;
- if (Size > DataSize) {
- Size = DataSize;
- }
-
- for (Index = 0; Index < Size; Index += 1) {
- TempByte = Data[Index];
- Val[Index * 3 + 0] = mVarCheckHiiHex[TempByte >> 4];
- Val[Index * 3 + 1] = mVarCheckHiiHex[TempByte & 0xF];
- Val[Index * 3 + 2] = (CHAR8)((Index == 7) ? '-' : ' ');
- Str[Index] = (CHAR8)((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
- }
-
- Val[Index * 3] = 0;
- Str[Index] = 0;
- DEBUG ((DEBUG_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
-
- Data += Size;
- Offset += Size;
- DataSize -= Size;
- }
-}
+EFI_HANDLE mEfiVariableCheckHiiHandle = NULL;
/**
Var Check Hii Question.
@@ -148,7 +97,7 @@ VarCheckHiiQuestion ( //
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
- VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ DUMP_HEX (DEBUG_INFO, 0, HiiQuestion, HiiQuestion->Length, " ");
);
return FALSE;
}
@@ -159,7 +108,7 @@ VarCheckHiiQuestion ( if ((OneData != 0) && (OneData != 1)) {
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
- VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ DUMP_HEX (DEBUG_INFO, 0, HiiQuestion, HiiQuestion->Length, " ");
);
return FALSE;
}
@@ -191,7 +140,7 @@ VarCheckHiiQuestion ( if ((OneData < Minimum) || (OneData > Maximum)) {
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
- VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ DUMP_HEX (DEBUG_INFO, 0, HiiQuestion, HiiQuestion->Length, " ");
);
return FALSE;
}
@@ -235,10 +184,10 @@ VarCheckHiiQuestion ( //
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: OrderedList mismatch\n"));
DEBUG_CODE (
- VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *)Data + HiiQuestion->VarOffset);
+ DUMP_HEX (DEBUG_INFO, 0, (UINT8 *)Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth * MaxContainers, " ");
);
DEBUG_CODE (
- VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ DUMP_HEX (DEBUG_INFO, 0, HiiQuestion, HiiQuestion->Length, " ");
);
return FALSE;
}
diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c index 90cef6e85d..d0cda797ef 100644 --- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c @@ -17,60 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // #define DUMP_VAR_CHECK_PCD
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckPcdHex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-
-/**
- Dump some hexadecimal data.
-
- @param[in] Indent How many spaces to indent the output.
- @param[in] Offset The offset of the dump.
- @param[in] DataSize The size in bytes of UserData.
- @param[in] UserData The data to dump.
-
-**/
-VOID
-VarCheckPcdInternalDumpHex (
- IN UINTN Indent,
- IN UINTN Offset,
- IN UINTN DataSize,
- IN VOID *UserData
- )
-{
- UINT8 *Data;
-
- CHAR8 Val[50];
-
- CHAR8 Str[20];
-
- UINT8 TempByte;
- UINTN Size;
- UINTN Index;
-
- Data = UserData;
- while (DataSize != 0) {
- Size = 16;
- if (Size > DataSize) {
- Size = DataSize;
- }
-
- for (Index = 0; Index < Size; Index += 1) {
- TempByte = Data[Index];
- Val[Index * 3 + 0] = mVarCheckPcdHex[TempByte >> 4];
- Val[Index * 3 + 1] = mVarCheckPcdHex[TempByte & 0xF];
- Val[Index * 3 + 2] = (CHAR8)((Index == 7) ? '-' : ' ');
- Str[Index] = (CHAR8)((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
- }
-
- Val[Index * 3] = 0;
- Str[Index] = 0;
- DEBUG ((DEBUG_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
-
- Data += Size;
- Offset += Size;
- DataSize -= Size;
- }
-}
-
/**
Var Check Pcd ValidData.
@@ -120,7 +66,7 @@ VarCheckPcdValidData ( //
DEBUG ((DEBUG_INFO, "VarCheckPcdValidData fail: ValidList mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
- VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *)PcdValidData);
+ DUMP_HEX (DEBUG_INFO, 0, PcdValidData, PcdValidData->Length, " ");
);
return FALSE;
}
@@ -144,7 +90,7 @@ VarCheckPcdValidData ( DEBUG ((DEBUG_INFO, "VarCheckPcdValidData fail: ValidRange mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
- VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *)PcdValidData);
+ DUMP_HEX (DEBUG_INFO, 0, PcdValidData, PcdValidData->Length, " ");
);
return FALSE;
break;
diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c index 5388fe4c28..3c7341e080 100644 --- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c +++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c @@ -124,62 +124,6 @@ typedef struct { /**
- This function dump raw data.
-
- @param Data raw data
- @param Size raw data size
-
-**/
-VOID
-InternalDumpData (
- IN UINT8 *Data,
- IN UINTN Size
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < Size; Index++) {
- DEBUG ((DEBUG_VERBOSE, "%02x", (UINTN)Data[Index]));
- }
-}
-
-/**
-
- This function dump raw data with colume format.
-
- @param Data raw data
- @param Size raw data size
-
-**/
-VOID
-InternalDumpHex (
- IN UINT8 *Data,
- IN UINTN Size
- )
-{
- UINTN Index;
- UINTN Count;
- UINTN Left;
-
- #define COLUME_SIZE (16 * 2)
-
- Count = Size / COLUME_SIZE;
- Left = Size % COLUME_SIZE;
- for (Index = 0; Index < Count; Index++) {
- DEBUG ((DEBUG_VERBOSE, "%04x: ", Index * COLUME_SIZE));
- InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE);
- DEBUG ((DEBUG_VERBOSE, "\n"));
- }
-
- if (Left != 0) {
- DEBUG ((DEBUG_VERBOSE, "%04x: ", Index * COLUME_SIZE));
- InternalDumpData (Data + Index * COLUME_SIZE, Left);
- DEBUG ((DEBUG_VERBOSE, "\n"));
- }
-}
-
-/**
-
This function get filter structure by SMBIOS type.
@param Type SMBIOS type
@@ -285,7 +229,7 @@ FilterSmbiosEntry ( DEBUG ((DEBUG_INFO, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type));
DEBUG_CODE (
- InternalDumpHex (TableEntry, TableEntrySize);
+ DUMP_HEX (DEBUG_VERBOSE, 0, TableEntry, TableEntrySize, "");
);
//
@@ -328,7 +272,7 @@ FilterSmbiosEntry ( DEBUG ((DEBUG_INFO, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type));
DEBUG_CODE (
- InternalDumpHex (TableEntry, TableEntrySize);
+ DUMP_HEX (DEBUG_VERBOSE, 0, TableEntry, TableEntrySize, "");
);
}
@@ -583,7 +527,7 @@ MeasureSmbiosTable ( DEBUG ((DEBUG_INFO, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress));
DEBUG ((DEBUG_INFO, "The Smbios Table size: 0x%x\n", TableLength));
DEBUG_CODE (
- InternalDumpHex ((UINT8 *)(UINTN)SmbiosTableAddress, TableLength);
+ DUMP_HEX (DEBUG_VERBOSE, 0, (UINT8 *)(UINTN)SmbiosTableAddress, TableLength, "");
);
TableAddress = AllocateCopyPool ((UINTN)TableLength, (VOID *)(UINTN)SmbiosTableAddress);
@@ -596,7 +540,7 @@ MeasureSmbiosTable ( DEBUG ((DEBUG_INFO, "The final Smbios Table starts at: 0x%x\n", TableAddress));
DEBUG ((DEBUG_INFO, "The final Smbios Table size: 0x%x\n", TableLength));
DEBUG_CODE (
- InternalDumpHex (TableAddress, TableLength);
+ DUMP_HEX (DEBUG_VERBOSE, 0, TableAddress, TableLength, "");
);
HandoffTables.NumberOfTables = 1;
|
