From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web08.4899.1662474463904173330 for ; Tue, 06 Sep 2022 07:27:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vj+BUAEw; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662474462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hxIRUzU2xVLuxB5hbi9t1ZpUpMkZZXmm8lHTuFGeERs=; b=Vj+BUAEwnHBajAhyGLf5ahXBnQTnq1ZqTJvySeZOO5rbjZAFMZJd9eeHxHhQN+I3rTk9+f kQEl8psu5i9qPjGxlhAQxJbh0lR3AwZM4EP5vA+M6wmTgZ6+1CUgInu51DKQDdeK9qEnDw WPlywNOl8w9dKUvp8i9oWH8G4YSSxXk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-NKLRipqbPG6C5_oPdYvg5w-1; Tue, 06 Sep 2022 10:27:40 -0400 X-MC-Unique: NKLRipqbPG6C5_oPdYvg5w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8AE385A58A; Tue, 6 Sep 2022 14:27:39 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.195.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DD431121314; Tue, 6 Sep 2022 14:27:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 052EA18003A1; Tue, 6 Sep 2022 16:27:36 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Jiewen Yao , Gerd Hoffmann , Ard Biesheuvel , Oliver Steffen , Jordan Justen Subject: [PATCH 1/1] OvmfPkg/QemuVideoDxe: fix bochs mode init Date: Tue, 6 Sep 2022 16:27:36 +0200 Message-Id: <20220906142736.2762874-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Add VgaInb() helper function to read vga registers. With that in place fix the unblanking. We need to put the ATT_ADDRESS_REGISTER flip flip 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 flip happens to be in the state we need. Signed-off-by: Gerd Hoffmann --- OvmfPkg/QemuVideoDxe/Driver.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c index b91909a14e59..bfa92ae96022 100644 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ b/OvmfPkg/QemuVideoDxe/Driver.c @@ -984,6 +984,31 @@ VgaOutb ( } } +UINT8 +VgaInb ( + QEMU_VIDEO_PRIVATE_DATA *Private, + UINTN Reg + ) +{ + EFI_STATUS Status; + UINT8 Data = 0; + + if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { + 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 +1023,11 @@ InitializeBochsGraphicsMode ( ModeData->ColorDepth )); - /* unblank */ + /* set color mode */ + VgaOutb (Private, MISC_OUTPUT_REGISTER, 0x01); + + /* reset flop flop + unblank */ + VgaInb (Private, INPUT_STATUS_1_REGISTER); VgaOutb (Private, ATT_ADDRESS_REGISTER, 0x20); BochsWrite (Private, VBE_DISPI_INDEX_ENABLE, 0); -- 2.37.3