]> xenbits.xensource.com Git - seabios.git/commitdiff
pciinit: Enable default VGA device
authorAlex Williamson <alex.williamson@redhat.com>
Wed, 20 Mar 2013 16:58:47 +0000 (10:58 -0600)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 23 Mar 2013 00:46:59 +0000 (20:46 -0400)
As QEMU gains PCI bridge and PCIe root port support, we won't always
find the VGA device on the root bus.  We therefore need to add support
to find and enable a VGA device and the path to it through the VGA
Enable support in the PCI bridge control register.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
src/optionroms.c
src/pciinit.c
src/util.h

index caa215106bff27b2108d71ed8bfbbc276c877c03..ac92613b142777bc9568f2b4e5c6285c22bc501a 100644 (file)
@@ -213,7 +213,7 @@ run_file_roms(const char *prefix, int isvga, u64 *sources)
  ****************************************************************/
 
 // Verify device is a vga device with legacy address decoding enabled.
-static int
+int
 is_pci_vga(struct pci_device *pci)
 {
     if (pci->class != PCI_CLASS_DISPLAY_VGA)
index ce0a4ccbc6e41417b9b1f6603624daebd998efd5..bb9355fc3b24f16e18e1e01d1fe7402b7b132fec 100644 (file)
@@ -316,6 +316,44 @@ static void pci_bios_init_devices(void)
     }
 }
 
+static void pci_enable_default_vga(void)
+{
+    struct pci_device *pci;
+
+    foreachpci(pci) {
+        if (is_pci_vga(pci)) {
+            dprintf(1, "PCI: Using %02x:%02x.%x for primary VGA\n",
+                    pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf),
+                    pci_bdf_to_fn(pci->bdf));
+            return;
+        }
+    }
+
+    pci = pci_find_class(PCI_CLASS_DISPLAY_VGA);
+    if (!pci) {
+        dprintf(1, "PCI: No VGA devices found\n");
+        return;
+    }
+
+    dprintf(1, "PCI: Enabling %02x:%02x.%x for primary VGA\n",
+            pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf),
+            pci_bdf_to_fn(pci->bdf));
+
+    pci_config_maskw(pci->bdf, PCI_COMMAND, 0,
+                     PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
+
+    while (pci->parent) {
+        pci = pci->parent;
+
+        dprintf(1, "PCI: Setting VGA enable on bridge %02x:%02x.%x\n",
+                pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf),
+                pci_bdf_to_fn(pci->bdf));
+
+        pci_config_maskw(pci->bdf, PCI_BRIDGE_CONTROL, 0, PCI_BRIDGE_CTL_VGA);
+        pci_config_maskw(pci->bdf, PCI_COMMAND, 0,
+                         PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
+    }
+}
 
 /****************************************************************
  * Platform device initialization
@@ -804,4 +842,6 @@ pci_setup(void)
     pci_bios_init_devices();
 
     free(busses);
+
+    pci_enable_default_vga();
 }
index af029fc03590fd7925be77daaab97a9047b50e93..99aff786053b9549f97344c40446a329db6607ef 100644 (file)
@@ -344,6 +344,7 @@ void vgahook_setup(struct pci_device *pci);
 
 // optionroms.c
 void call_bcv(u16 seg, u16 ip);
+int is_pci_vga(struct pci_device *pci);
 void optionrom_setup(void);
 void vgarom_setup(void);
 void s3_resume_vga(void);