[SeaBIOS] [PATCH] vga: rework bar detection, add virtio-vga

Gerd Hoffmann kraxel at redhat.com
Tue Jan 28 15:17:15 CET 2014


Replace the heuristic which checks the bar 0 attributes to
figure whenever bar 0 or bar 1 has the linear framebuffer
with a vendor id check.

Add support for virtio-vga which uses bar 2 for the linear
framebuffer.

Cc: Dave Airlie <airlied at redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
 vgasrc/bochsvga.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c
index 6da9d5d..b802be1 100644
--- a/vgasrc/bochsvga.c
+++ b/vgasrc/bochsvga.c
@@ -402,12 +402,20 @@ bochsvga_setup(void)
     u32 lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
     int bdf = GET_GLOBAL(VgaBDF);
     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) {
+        u16 vendor = pci_config_readw(bdf, PCI_VENDOR_ID);
+        int barid;
+        switch (vendor) {
+        case 0x15ad: /* qemu vmware vga */
             barid = 1;
-            bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_1);
+            break;
+        case 0x1af4: /* virtio-vga */
+            barid = 2;
+            break;
+        default: /* stdvga, qxl */
+            barid = 0;
+            break;
         }
+        u32 bar = pci_config_readl(bdf, PCI_BASE_ADDRESS_0 + barid * 4);
         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);
-- 
1.8.3.1




More information about the SeaBIOS mailing list