summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2022-04-08 10:23:32 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-04-25 21:01:13 +0000
commit86de090b9950aaa0d8392745088fb0b150f17f3a (patch)
treeb67e74effda1cb8d4d8724dfeca07c12638f0a73
parent5f6ecaa398ba902f724be504663a0156c9e24570 (diff)
downloadedk2-86de090b9950aaa0d8392745088fb0b150f17f3a.tar.gz
edk2-86de090b9950aaa0d8392745088fb0b150f17f3a.tar.bz2
edk2-86de090b9950aaa0d8392745088fb0b150f17f3a.zip
OvmfPkg/VirtioGpuDxe: move code to GopInitialize
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 <kraxel@redhat.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r--OvmfPkg/VirtioGpuDxe/Gop.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 337a7e19bf..05daefcbfb 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;
@@ -260,20 +291,6 @@ GopSetMode (
//
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.
//
NewResourceId = 1;