In the next patch we'll add many new BOCHS modes, some of which require
large frame buffers.

The size of the QXL VGA compatibility framebuffer can be changed with the

  -global qxl-vga.vgamem_mb=$NUM_MB

QEMU option.

If $NUM_MB would exceed 32, then the following two QEMU options are
necessary instead:

  -global qxl-vga.vgamem_mb=$NUM_MB         \
  -global qxl-vga.ram_size_mb=$((NUM_MB*2))

because the compatibility framebuffer can't cover more than half of PCI
BAR #0. The latter defaults to 64MB in size, and is controlled by
"ram_size_mb".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---

Notes:
    v2:
    - calculate size of available framebuffer with a paravirt call [Gerd]
    - update commit message to reflect QEMU command line options that change
      the size of the vga compat framebuffer [Gerd]

 OvmfPkg/QemuVideoDxe/Initialize.c | 46 ++++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c 
b/OvmfPkg/QemuVideoDxe/Initialize.c
index d3d2e2e..80e9b3a 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -222,11 +222,20 @@ QemuVideoBochsModeSetup (
   QEMU_VIDEO_PRIVATE_DATA  *Private
   )
 {
+  UINT32                                 AvailableFbSize;
   UINT32                                 Index;
   QEMU_VIDEO_MODE_DATA                   *ModeData;
   QEMU_VIDEO_BOCHS_MODES                 *VideoMode;
 
   //
+  // fetch available framebuffer size
+  //
+  AvailableFbSize  = BochsRead (Private, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
+  AvailableFbSize *= SIZE_64KB;
+  DEBUG ((EFI_D_VERBOSE, "%a: AvailableFbSize=0x%x\n", __FUNCTION__,
+    AvailableFbSize));
+
+  //
   // Setup Video Modes
   //
   Private->ModeData = AllocatePool (
@@ -238,22 +247,29 @@ QemuVideoBochsModeSetup (
   ModeData = Private->ModeData;
   VideoMode = &QemuVideoBochsModes[0];
   for (Index = 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index ++) {
-    ModeData->InternalModeIndex = Index;
-    ModeData->HorizontalResolution          = VideoMode->Width;
-    ModeData->VerticalResolution            = VideoMode->Height;
-    ModeData->ColorDepth                    = VideoMode->ColorDepth;
-    ModeData->RefreshRate                   = 60;
-    DEBUG ((EFI_D_INFO,
-      "Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
-      (INT32) (ModeData - Private->ModeData),
-      ModeData->InternalModeIndex,
-      ModeData->HorizontalResolution,
-      ModeData->VerticalResolution,
-      ModeData->ColorDepth,
-      ModeData->RefreshRate
-      ));
+    UINTN RequiredFbSize;
 
-    ModeData ++ ;
+    ASSERT (VideoMode->ColorDepth % 8 == 0);
+    RequiredFbSize = (UINTN) VideoMode->Width * VideoMode->Height *
+                     (VideoMode->ColorDepth / 8);
+    if (RequiredFbSize <= AvailableFbSize) {
+      ModeData->InternalModeIndex    = Index;
+      ModeData->HorizontalResolution = VideoMode->Width;
+      ModeData->VerticalResolution   = VideoMode->Height;
+      ModeData->ColorDepth           = VideoMode->ColorDepth;
+      ModeData->RefreshRate          = 60;
+      DEBUG ((EFI_D_INFO,
+        "Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
+        (INT32) (ModeData - Private->ModeData),
+        ModeData->InternalModeIndex,
+        ModeData->HorizontalResolution,
+        ModeData->VerticalResolution,
+        ModeData->ColorDepth,
+        ModeData->RefreshRate
+        ));
+
+      ModeData ++ ;
+    }
     VideoMode ++;
   }
   Private->MaxMode = ModeData - Private->ModeData;
-- 
1.8.3.1



------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to