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.web10.5570.1662542111038633626 for ; Wed, 07 Sep 2022 02:15:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RKtjCoxZ; 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=1662542110; 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=Ea5LiGTw4ZiOe5BxeukPp0ZSexweok8qLFQ+RC+QYZc=; b=RKtjCoxZL7mrwKPPfFE//Gewk0F1fN4187F8/BcXjvEhPFgr2DrDAct/UaD7Tuc7opGZZy +QrMQMmr/NVfV5HNjtL6KjNHh79yMDrZdOqJoU1b868TgxaYUKRsEjq9/MWdnw5kTFZKSW PfmE/1qXhGa2UIMW4jyXsnMU5iCQPIs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-336-igoPmPfHPf-zJbrZhl00gQ-1; Wed, 07 Sep 2022 05:15:07 -0400 X-MC-Unique: igoPmPfHPf-zJbrZhl00gQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5B0929AA3AF; Wed, 7 Sep 2022 09:15:06 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.195.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30AAD492C3B; Wed, 7 Sep 2022 09:15:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 68934180039B; Wed, 7 Sep 2022 11:15:04 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Pawel Polawski , Jiewen Yao , Ard Biesheuvel , Jordan Justen , Gerd Hoffmann Subject: [PATCH v3 1/1] OvmfPkg/QemuVideoDxe: fix bochs mode init Date: Wed, 7 Sep 2022 11:15:04 +0200 Message-Id: <20220907091504.3152616-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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 flop happens to be in the state we need. Signed-off-by: Gerd Hoffmann --- OvmfPkg/QemuVideoDxe/Driver.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c index b91909a14e59..1f9ba046ef04 100644 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ b/OvmfPkg/QemuVideoDxe/Driver.c @@ -984,6 +984,33 @@ VgaOutb ( } } +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 +1025,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