summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library
diff options
context:
space:
mode:
authorOliver Smith-Denny <osde@microsoft.com>2026-10-01 22:38:03 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-10-23 06:44:49 +0300
commitbbbb761e370379aed5d548cd5c044377fee4daaa (patch)
tree56d02029be2c2ede0bfb743a9ebf5572d22e6f14 /MdeModulePkg/Library
parent2b2c8374f91a9622b0d49ce7d90ce2bab10c9c6e (diff)
downloadedk2-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/Library')
-rw-r--r--MdeModulePkg/Library/HobPrintLib/HobPrintLib.c42
-rw-r--r--MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c16
-rw-r--r--MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibCommon.c63
-rw-r--r--MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c58
4 files changed, 14 insertions, 165 deletions
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;