[SeaBIOS] [PATCH] Support more than one vga card

Glauber Costa glommer at redhat.com
Tue May 3 18:49:57 CEST 2011


It is theorectically possible for a system to have more than
one pci vga card. In particular, I am interested in the use of SGAbios
as a pci device, alongside of a normal vga bios in QEMU.

This patch makes seabios continue searching the pci range looking for
vga cards, even if it finds one. The first card to be found is assigned
to VGAbdf, being the main one. The others, just have their initializatiom
roms called and are listed in the pci bus.

Signed-off-by: Glauber Costa <glommer at redhat.com>
---
 src/optionroms.c |   11 ++++++++---
 src/pci.c        |    6 ++++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/optionroms.c b/src/optionroms.c
index 37a4e6c..2d0a258 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -462,13 +462,18 @@ vga_setup(void)
         // Option roms are already deployed on the system.
         init_optionrom((void*)BUILD_ROM_START, 0, 1);
     } else {
+        int bdf;
         // Clear option rom memory
         memset((void*)RomEnd, 0, _max_rom() - RomEnd);
 
         // Find and deploy PCI VGA rom.
-        int bdf = VGAbdf = pci_find_vga();
-        if (bdf >= 0)
-            init_pcirom(bdf, 1, NULL);
+        do {
+                bdf = pci_find_vga();
+                if (!VGAbdf)
+                    VGAbdf = bdf;
+                if (bdf >= 0)
+                    init_pcirom(bdf, 1, NULL);
+         } while ((bdf >= 0))
 
         // Find and deploy CBFS vga-style roms not associated with a device.
         run_file_roms("vgaroms/", 1, NULL);
diff --git a/src/pci.c b/src/pci.c
index 944a393..6f124cf 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -107,7 +107,9 @@ pci_next(int bdf, int *pmax)
 int
 pci_find_vga(void)
 {
-    int bdf = 0x0000, max = 0x0100;
+    static int bdf;
+    int max = 0x0100;
+
     for (;;) {
         if (bdf >= max) {
             if (CONFIG_PCI_ROOT1 && bdf <= (CONFIG_PCI_ROOT1 << 8))
@@ -132,7 +134,7 @@ pci_find_vga(void)
             u16 cmd = pci_config_readw(bdf, PCI_COMMAND);
             if (cmd & PCI_COMMAND_IO && cmd & PCI_COMMAND_MEMORY)
                 // Found active vga card
-                return bdf;
+                return bdf++;
         }
 
         // Check if device is a bridge.
-- 
1.7.4.2




More information about the SeaBIOS mailing list