Fix double debug message output on serial port
SBL allows debug message to be redirected to output console besides the serial port. However, serial port itself could be part of the output console device as well. In this case the debug message will be printed twice. This patch added check to this condition and skip the redundant print. It fixed #349. Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
parent
5ec7be2c5d
commit
56867c3bc6
|
@ -43,3 +43,4 @@
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask ## CONSUMES
|
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask ## CONSUMES
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel ## CONSUMES
|
gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel ## CONSUMES
|
||||||
gPlatformCommonLibTokenSpaceGuid.PcdDebugOutputDeviceMask ## CONSUMES
|
gPlatformCommonLibTokenSpaceGuid.PcdDebugOutputDeviceMask ## CONSUMES
|
||||||
|
gPlatformCommonLibTokenSpaceGuid.PcdConsoleOutDeviceMask ## CONSUMES
|
||||||
|
|
|
@ -47,6 +47,9 @@ DebugPrint (
|
||||||
{
|
{
|
||||||
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
|
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
|
||||||
VA_LIST Marker;
|
VA_LIST Marker;
|
||||||
|
UINTN Length;
|
||||||
|
BOOLEAN OutputToSerial;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Format is NULL, then ASSERT().
|
// If Format is NULL, then ASSERT().
|
||||||
|
@ -60,6 +63,8 @@ DebugPrint (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Length = AsciiStrLen (Buffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert the DEBUG() message to an ASCII String
|
// Convert the DEBUG() message to an ASCII String
|
||||||
//
|
//
|
||||||
|
@ -71,13 +76,22 @@ DebugPrint (
|
||||||
// Send the print string to debug output handler
|
// Send the print string to debug output handler
|
||||||
//
|
//
|
||||||
if (PcdGet32 (PcdDebugOutputDeviceMask) & DEBUG_OUTPUT_DEVICE_LOG_BUFFER) {
|
if (PcdGet32 (PcdDebugOutputDeviceMask) & DEBUG_OUTPUT_DEVICE_LOG_BUFFER) {
|
||||||
DebugLogBufferWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
|
DebugLogBufferWrite ((UINT8 *)Buffer, Length);
|
||||||
}
|
|
||||||
if (PcdGet32 (PcdDebugOutputDeviceMask) & DEBUG_OUTPUT_DEVICE_SERIAL_PORT) {
|
|
||||||
SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutputToSerial = (PcdGet32 (PcdDebugOutputDeviceMask) & DEBUG_OUTPUT_DEVICE_SERIAL_PORT) ? TRUE : FALSE;
|
||||||
if (PcdGet32 (PcdDebugOutputDeviceMask) & DEBUG_OUTPUT_DEVICE_CONSOLE) {
|
if (PcdGet32 (PcdDebugOutputDeviceMask) & DEBUG_OUTPUT_DEVICE_CONSOLE) {
|
||||||
ConsoleWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
|
ConsoleWrite ((UINT8 *)Buffer, Length);
|
||||||
|
|
||||||
|
// If serial port is part of console output devices, skip the output below.
|
||||||
|
// since it has been outputed in ConsoleWrite().
|
||||||
|
if ( (PcdGet32 (PcdConsoleOutDeviceMask) & ConsoleOutSerialPort) != 0) {
|
||||||
|
OutputToSerial = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OutputToSerial) {
|
||||||
|
SerialPortWrite ((UINT8 *)Buffer, Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue