Skip to content

Commit 512042e

Browse files
kraxelmergify[bot]
authored andcommitted
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 <kraxel@redhat.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 314799a commit 512042e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

OvmfPkg/QemuVideoDxe/Driver.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,34 @@ VgaOutb (
984984
}
985985
}
986986

987+
STATIC
988+
UINT8
989+
VgaInb (
990+
QEMU_VIDEO_PRIVATE_DATA *Private,
991+
UINTN Reg
992+
)
993+
{
994+
EFI_STATUS Status;
995+
UINT8 Data;
996+
997+
if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) {
998+
Data = 0;
999+
Status = Private->PciIo->Mem.Read (
1000+
Private->PciIo,
1001+
EfiPciIoWidthUint8,
1002+
PCI_BAR_IDX2,
1003+
0x400 - 0x3c0 + Reg,
1004+
1,
1005+
&Data
1006+
);
1007+
ASSERT_EFI_ERROR (Status);
1008+
} else {
1009+
Data = inb (Private, Reg);
1010+
}
1011+
1012+
return Data;
1013+
}
1014+
9871015
VOID
9881016
InitializeBochsGraphicsMode (
9891017
QEMU_VIDEO_PRIVATE_DATA *Private,
@@ -998,7 +1026,11 @@ InitializeBochsGraphicsMode (
9981026
ModeData->ColorDepth
9991027
));
10001028

1001-
/* unblank */
1029+
/* set color mode */
1030+
VgaOutb (Private, MISC_OUTPUT_REGISTER, 0x01);
1031+
1032+
/* reset flip flop + unblank */
1033+
VgaInb (Private, INPUT_STATUS_1_REGISTER);
10021034
VgaOutb (Private, ATT_ADDRESS_REGISTER, 0x20);
10031035

10041036
BochsWrite (Private, VBE_DISPI_INDEX_ENABLE, 0);

0 commit comments

Comments
 (0)