OcDebugLogLib: Fix hex logging issues

This commit is contained in:
vit9696 2019-07-21 13:09:39 +03:00
parent 598a106c22
commit a7fc06ddce
2 changed files with 7 additions and 3 deletions

View File

@ -18,7 +18,7 @@
#include <Library/DebugLib.h>
#include <Protocol/OcLog.h>
#define OC_HEX_LOWER(x) "0123456789ABCDEF"[(UINT32) (x) >> 4U]
#define OC_HEX_LOWER(x) "0123456789ABCDEF"[((UINT32) (x) & 0x0FU)]
#define OC_HEX_UPPER(x) "0123456789ABCDEF"[((UINT32) (x) & 0xF0U) >> 4U]
/**

View File

@ -49,6 +49,7 @@ DebugPrintHexDump (
UINTN Index;
UINTN Index2;
UINTN Count;
UINTN SizeLeft;
UINTN MaxPerLine;
CHAR8 *HexLine;
CHAR8 *HexLineCurrent;
@ -61,17 +62,19 @@ DebugPrintHexDump (
return;
}
SizeLeft = Size;
for (Index = 0; Index < Count; ++Index) {
HexLineCurrent = HexLine;
for (Index2 = 0; Size > 0 && Index2 < MaxPerLine; ++Index) {
for (Index2 = 0; SizeLeft > 0 && Index2 < MaxPerLine; ++Index2) {
if (Index2 > 0) {
*HexLineCurrent++ = ' ';
}
*HexLineCurrent++ = OC_HEX_UPPER (*Bytes);
*HexLineCurrent++ = OC_HEX_LOWER (*Bytes);
--Size;
--SizeLeft;
++Bytes;
}
@ -80,6 +83,7 @@ DebugPrintHexDump (
DEBUG ((
ErrorLevel,
"%a (%u/%u %u) - %a\n",
Message,
(UINT32) Index + 1,
(UINT32) Count,
(UINT32) Size,