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.web10.2677.1646977424777104321 for ; Thu, 10 Mar 2022 21:43:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KR/FyjTl; 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=1646977423; 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: in-reply-to:in-reply-to:references:references; bh=NqwqMiefeu5bMreK/4nHg0AfXiSQHM3Ed5zDNGHUCGA=; b=KR/FyjTlVLgTMjTdBKBJL3DxyerDYiNFmAFU8NGcT3tqBEQiLP9fRHa7vnUAZ8BNyQ9C0G CbDIsACE5Idg2rWlBkcw1S4v5HjEfVQtqPmp06nGRfRKbRX4BguivGar5YB1pKsGVn6FZq 8jzJmiqRad6J8vFp8kQB7slngTkvn6A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-grFtSdkuNuCu8PrcGV7iwA-1; Fri, 11 Mar 2022 00:43:41 -0500 X-MC-Unique: grFtSdkuNuCu8PrcGV7iwA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD4A9180FD72 for ; Fri, 11 Mar 2022 05:43:40 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.196.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB47D5DF4B; Fri, 11 Mar 2022 05:43:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B9F8D180063C; Fri, 11 Mar 2022 06:43:15 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Gerd Hoffmann Subject: [PATCH v2 5/6] OvmfPkg/VirtioGpuDxe: move code to GopInitialize Date: Fri, 11 Mar 2022 06:43:14 +0100 Message-Id: <20220311054315.876774-6-kraxel@redhat.com> In-Reply-To: <20220311054315.876774-1-kraxel@redhat.com> References: <20220311054315.876774-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Add new function to initialize the GOP, move over setup code. Handle initialization first, specifically before calling GopQueryMode(), so GopQueryMode is never called before GopInitialize() did complete. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtioGpuDxe/Gop.c | 47 ++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 337a7e19bffa..05daefcbfbc8 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -192,6 +192,32 @@ STATIC CONST GOP_RESOLUTION mGopResolutions[] = { #define VGPU_GOP_FROM_GOP(GopPointer) \ CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG) +STATIC +VOID +EFIAPI +GopInitialize ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This + ) +{ + VGPU_GOP *VgpuGop; + + VgpuGop = VGPU_GOP_FROM_GOP (This); + + // + // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other + // (nonzero) constant fields. + // + // No direct framebuffer access is supported, only Blt() is. + // + VgpuGop->Gop.Mode = &VgpuGop->GopMode; + + VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions)); + VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo; + VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo; + + VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly; +} + // // EFI_GRAPHICS_OUTPUT_PROTOCOL member functions. // @@ -207,7 +233,7 @@ GopQueryMode ( { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; - if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) { + if (ModeNumber >= This->Mode->MaxMode) { return EFI_INVALID_PARAMETER; } @@ -247,6 +273,11 @@ GopSetMode ( EFI_STATUS Status; EFI_STATUS Status2; + if (!This->Mode) { + // SetMode() call in InitVgpuGop() triggers this. + GopInitialize (This); + } + Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo); if (Status != EFI_SUCCESS) { return Status; @@ -259,20 +290,6 @@ GopSetMode ( // calls. // if (VgpuGop->ResourceId == 0) { - // - // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other - // (nonzero) constant fields. - // - // No direct framebuffer access is supported, only Blt() is. - // - VgpuGop->Gop.Mode = &VgpuGop->GopMode; - - VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions)); - VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo; - VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo; - - VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly; - // // This is the first time we create a host side resource. // -- 2.35.1