]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c
OvmfPkg/PlatformDebugLibIoPort: factor out debug port detection
[mirror_edk2.git] / OvmfPkg / Library / PlatformDebugLibIoPort / DebugIoPortQemu.c
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c
new file mode 100644 (file)
index 0000000..bf91198
--- /dev/null
@@ -0,0 +1,34 @@
+/** @file\r
+  Detection code for QEMU debug port.\r
+\r
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012, Red Hat, Inc.<BR>\r
+  Copyright (c) 2020, Citrix Systems, Inc.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/IoLib.h>\r
+#include <Library/PcdLib.h>\r
+#include "DebugLibDetect.h"\r
+\r
+//\r
+// The constant value that is read from the debug I/O port\r
+//\r
+#define BOCHS_DEBUG_PORT_MAGIC    0xE9\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