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.129.124]) by mx.groups.io with SMTP id smtpd.web08.4307.1662527826176108916 for ; Tue, 06 Sep 2022 22:17:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N8d6eoLE; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662527825; 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=0Mrz3TC+TY8Q0gi5UTsOYk5NYhhH/ulMqw4/Iojz03w=; b=N8d6eoLEf7ryTjBv8YBQYelZ+W/ER/GAR7j4NWjA3eAKLix5TwtVAwkLq40luiL6cATOsX jB5iRphIcdJrnb5wfYDftsw6YzPcNGgqxaS+96sYkT/KfYzVKLy0iEkl8I0xe8WVRrOIcX 98sMoIyZY7DZrQdBrCLGqYKQNJqQ57I= 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-349-Wpud7zluM2WzoZzfm70BLA-1; Wed, 07 Sep 2022 01:17:01 -0400 X-MC-Unique: Wpud7zluM2WzoZzfm70BLA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C6C58037B7; Wed, 7 Sep 2022 05:17:01 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.195.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57539C15BBA; Wed, 7 Sep 2022 05:17:00 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F03BC180039B; Wed, 7 Sep 2022 07:16:58 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Pawel Polawski , Jiewen Yao , Ard Biesheuvel , Oliver Steffen Subject: [PATCH v2 1/1] OvmfPkg/QemuVideoDxe: fix bochs mode init Date: Wed, 7 Sep 2022 07:16:58 +0200 Message-Id: <20220907051658.2884354-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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 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 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..a15e54d38fd2 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 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