#include <Library/PcdLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/DebugPrintErrorLevelLib.h>\r
+#include "DebugLibDetect.h"\r
\r
//\r
// Define the maximum debug and assert message length that this library supports\r
ASSERT (Format != NULL);\r
\r
//\r
- // Check driver debug mask value and global mask\r
+ // Check if the global mask disables this message or the device is inactive\r
//\r
- if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {\r
+ if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0 ||\r
+ !PlatformDebugLibIoPortFound ()) {\r
return;\r
}\r
\r
FileName, (UINT64)LineNumber, Description);\r
\r
//\r
- // Send the print string to the debug I/O port\r
+ // Send the print string to the debug I/O port, if present\r
//\r
- IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);\r
+ if (PlatformDebugLibIoPortFound ()) {\r
+ IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);\r
+ }\r
\r
//\r
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
{\r
return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);\r
}\r
+\r
+/**\r
+ Return the result of detecting the debug I/O port device.\r
+\r
+ @retval TRUE if the debug I/O port device was detected.\r
+ @retval FALSE otherwise\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PlatformDebugLibIoPortDetect (\r
+ VOID\r
+ )\r
+{\r
+ return IoRead8 (PcdGet16 (PcdDebugIoPort)) == BOCHS_DEBUG_PORT_MAGIC;\r
+}\r