summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2024-01-29 13:29:29 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-01-29 20:53:55 +0000
commit98c7cb3be73d0f15151133abe91bc880a4400794 (patch)
treef194320029b4dfc02379ca331dd1b64a88da6fad
parenta6013625a3d7d949571fdc2cc4fc5905f37a0023 (diff)
downloadedk2-98c7cb3be73d0f15151133abe91bc880a4400794.tar.gz
edk2-98c7cb3be73d0f15151133abe91bc880a4400794.tar.bz2
edk2-98c7cb3be73d0f15151133abe91bc880a4400794.zip
OvmfPkg/ResetVector: send post codes to qemu debug console
Neat when doing ResetVector coding. Incompatible with TDX and SEV, therefore not enabled by default. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Acked-by: Erdem Aktas <erdemaktas@google.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20240129122929.349726-1-kraxel@redhat.com> [lersek@redhat.com: replace "SEV" with "SEV-ES/SEV-SNP" in comment]
-rw-r--r--OvmfPkg/ResetVector/QemuDebugCon.asm36
-rw-r--r--OvmfPkg/ResetVector/ResetVector.nasmb4
2 files changed, 40 insertions, 0 deletions
diff --git a/OvmfPkg/ResetVector/QemuDebugCon.asm b/OvmfPkg/ResetVector/QemuDebugCon.asm
new file mode 100644
index 0000000000..8729fc2ffc
--- /dev/null
+++ b/OvmfPkg/ResetVector/QemuDebugCon.asm
@@ -0,0 +1,36 @@
+;------------------------------------------------------------------------------
+; @file
+; qemu debug console support macros (based on serial port macros)
+;
+; Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2024, Red Hat, Inc.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;------------------------------------------------------------------------------
+
+%macro debugShowCharacter 1
+ mov dx, 0x402
+ mov al, %1
+ out dx, al
+%endmacro
+
+%macro debugShowHexDigit 1
+ %if (%1 < 0xa)
+ debugShowCharacter BYTE ('0' + (%1))
+ %else
+ debugShowCharacter BYTE ('a' + ((%1) - 0xa))
+ %endif
+%endmacro
+
+%macro debugShowPostCode 1
+ debugShowHexDigit (((%1) >> 4) & 0xf)
+ debugShowHexDigit ((%1) & 0xf)
+ debugShowCharacter `\r`
+ debugShowCharacter `\n`
+%endmacro
+
+BITS 16
+
+%macro debugInitialize 0
+ ; not required
+%endmacro
diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/ResetVector.nasmb
index 5832aaa8ab..366a70fb99 100644
--- a/OvmfPkg/ResetVector/ResetVector.nasmb
+++ b/OvmfPkg/ResetVector/ResetVector.nasmb
@@ -40,6 +40,10 @@
%include "Port80Debug.asm"
%elifdef DEBUG_SERIAL
%include "SerialDebug.asm"
+%elif 0
+; Set ^ this to 1 to enable postcodes on the qemu debug console.
+; Disabled by default because it is incompatible with SEV-ES/SEV-SNP and TDX.
+ %include "QemuDebugCon.asm"
%else
%include "DebugDisabled.asm"
%endif