From bf9171b66aaa88ae977428e0122b831510cb83a5 Mon Sep 17 00:00:00 2001
From: belliash <belliash@codingworkshop.eu.org>
Date: Tue, 27 Sep 2022 18:39:26 +0200
Subject: [PATCH] Check for OVMF and prevent doubled messages on serial console

---
 xtldr/efiutil.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/xtldr/efiutil.c b/xtldr/efiutil.c
index 770f58eb..3f06c720 100644
--- a/xtldr/efiutil.c
+++ b/xtldr/efiutil.c
@@ -227,11 +227,15 @@ BlEfiPrint(IN PUINT16 Format,
     /* Format and print the string to the stdout */
     BlStringPrint(BlConsolePutChar, Format, Arguments);
 
-    /* Check if EFI serial port is fully initialized */
-    if(EfiSerialPort.Flags & COMPORT_FLAG_INIT)
+    /* Print to serial console only if not running under OVMF */
+    if(RtlWideStringCompare(EfiSystemTable->FirmwareVendor, L"EDK II", 6) != 0)
     {
-        /* Format and print the string to the serial console */
-        BlStringPrint(BlComPortPutChar, Format, Arguments);
+        /* Check if EFI serial port is fully initialized */
+        if(EfiSerialPort.Flags & COMPORT_FLAG_INIT)
+        {
+            /* Format and print the string to the serial console */
+            BlStringPrint(BlComPortPutChar, Format, Arguments);
+        }
     }
 
     /* Clean up the va_list */