vgabios: handle vmware vga in bochsvga.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 29 Jan 2012 16:53:59 +0000 (11:53 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 2 Feb 2012 01:42:06 +0000 (20:42 -0500)
The vmware vga emulated by qemu has a I/O region in pci bar 0.
The framebuffer is in pci bar 1.  Handle that by checking the
type of bar 0 in case it is a I/O bar use bar 1 instead.

Also make bochsbios report lfb size in debug output.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
vgasrc/bochsvga.c

index 5770e106a565f627b48e02898cf505da0c02e6a8..e40a1fd507eefa92a5a234d20dcd094711f93539 100644 (file)
@@ -139,16 +139,25 @@ bochsvga_init(void)
 
     u32 lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
     int bdf = GET_GLOBAL(VgaBDF);
-    if (CONFIG_VGA_PCI && bdf >= 0)
-        lfb_addr = (pci_config_readl(bdf, PCI_BASE_ADDRESS_0)
-                    & PCI_BASE_ADDRESS_MEM_MASK);
+    if (CONFIG_VGA_PCI && bdf >= 0) {
+        int barid = 0;
+        u32 bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_0);
+        if ((bar & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) {
+            barid = 1;
+            bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_1);
+        }
+        lfb_addr = bar & PCI_BASE_ADDRESS_MEM_MASK;
+        dprintf(1, "VBE DISPI: bdf %02x:%02x.%x, bar %d\n", pci_bdf_to_bus(bdf)
+                , pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf), barid);
+    }
 
     SET_VGA(VBE_framebuffer, lfb_addr);
     u16 totalmem = dispi_read(VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
     SET_VGA(VBE_total_memory, totalmem * 64 * 1024);
     SET_VGA(VBE_capabilities, VBE_CAPABILITY_8BIT_DAC);
 
-    dprintf(1, "VBE DISPI detected. lfb_addr=%x\n", lfb_addr);
+    dprintf(1, "VBE DISPI: lfb_addr=%x, size %d MB\n",
+            lfb_addr, totalmem / 16);
 
     return 0;
 }