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.3473.1649406231715558797 for ; Fri, 08 Apr 2022 01:23:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gYbZVaRJ; 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=1649406231; 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=gYbZVaRJC5xSxVGbNhv7h4bR2CX1XIcabM3sjPBImyMdAAm4LpCaWCcQM/FPuNo1mF0i1u x5T2eqCrVi0zaauOCrBH8ZOABy3nekJR4FwH+HSxJjzvcL1RhTHSNgyCo3YUlXulgkIBAp JZ0NlchIOBKZ4tSp+4qBKa3wZT/e1Hc= 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-210-Kkyi_TVLM6OThITnuj8sWw-1; Fri, 08 Apr 2022 04:23:50 -0400 X-MC-Unique: Kkyi_TVLM6OThITnuj8sWw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC51318E0042; Fri, 8 Apr 2022 08:23:49 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39D782166BA3; Fri, 8 Apr 2022 08:23:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D5838180098A; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [PATCH v3 5/6] OvmfPkg/VirtioGpuDxe: move code to GopInitialize Date: Fri, 8 Apr 2022 10:23:32 +0200 Message-Id: <20220408082333.3023758-6-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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"; x-default=true 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