diff --git a/0022-OvmfPkg-QemuVideoDxe-fix-bochs-mode-init.patch b/0022-OvmfPkg-QemuVideoDxe-fix-bochs-mode-init.patch new file mode 100644 index 0000000..09fc6c5 --- /dev/null +++ b/0022-OvmfPkg-QemuVideoDxe-fix-bochs-mode-init.patch @@ -0,0 +1,77 @@ +From 6f20526da6631302cac8a79fd2392bddd2514948 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Wed, 7 Sep 2022 11:15:04 +0200 +Subject: [PATCH 22/22] OvmfPkg/QemuVideoDxe: fix bochs mode init + +Add VgaInb() helper function to read vga registers. With that in place +fix the unblanking. We need to put the ATT_ADDRESS_REGISTER flip flop +into a known state, which is done by reading the +INPUT_STATUS_1_REGISTER. Reading the INPUT_STATUS_1_REGISTER only works +when the device is in color mode, so make sure that bit (0x01) is set in +MISC_OUTPUT_REGISTER. + +Currently the mode setting works more by luck because +ATT_ADDRESS_REGISTER flip flop happens to be in the state we need. + +Signed-off-by: Gerd Hoffmann +Reviewed-by: Ard Biesheuvel +(cherry picked from commit 512042eba87ff97a4820a55cf3b1a89a8afd1cc7) +--- + OvmfPkg/QemuVideoDxe/Driver.c | 34 +++++++++++++++++++++++++++++++++- + 1 file changed, 33 insertions(+), 1 deletion(-) + +diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c +index b91909a14e59..c28171d13719 100644 +--- a/OvmfPkg/QemuVideoDxe/Driver.c ++++ b/OvmfPkg/QemuVideoDxe/Driver.c +@@ -984,6 +984,34 @@ VgaOutb ( + } + } + ++STATIC ++UINT8 ++VgaInb ( ++ QEMU_VIDEO_PRIVATE_DATA *Private, ++ UINTN Reg ++ ) ++{ ++ EFI_STATUS Status; ++ UINT8 Data; ++ ++ if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { ++ Data = 0; ++ Status = Private->PciIo->Mem.Read ( ++ Private->PciIo, ++ EfiPciIoWidthUint8, ++ PCI_BAR_IDX2, ++ 0x400 - 0x3c0 + Reg, ++ 1, ++ &Data ++ ); ++ ASSERT_EFI_ERROR (Status); ++ } else { ++ Data = inb (Private, Reg); ++ } ++ ++ return Data; ++} ++ + VOID + InitializeBochsGraphicsMode ( + QEMU_VIDEO_PRIVATE_DATA *Private, +@@ -998,7 +1026,11 @@ InitializeBochsGraphicsMode ( + ModeData->ColorDepth + )); + +- /* unblank */ ++ /* set color mode */ ++ VgaOutb (Private, MISC_OUTPUT_REGISTER, 0x01); ++ ++ /* reset flip flop + unblank */ ++ VgaInb (Private, INPUT_STATUS_1_REGISTER); + VgaOutb (Private, ATT_ADDRESS_REGISTER, 0x20); + + BochsWrite (Private, VBE_DISPI_INDEX_ENABLE, 0); +-- +2.37.3 + diff --git a/edk2.spec b/edk2.spec index 09516c6..9a9398b 100644 --- a/edk2.spec +++ b/edk2.spec @@ -88,6 +88,7 @@ Patch0018: 0018-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch Patch0019: 0019-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch Patch0020: 0020-Tweak-the-tools_def-to-support-cross-compiling.patch Patch0021: 0021-tools_def-add-fno-omit-frame-pointer-to-GCC48_-IA32-.patch +Patch0022: 0022-OvmfPkg-QemuVideoDxe-fix-bochs-mode-init.patch # python3-devel and libuuid-devel are required for building tools. # python3-devel is also needed for varstore template generation and