]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
pci: allow loading roms via fw_cfg.
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 8 Jan 2010 14:25:41 +0000 (15:25 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 12 Jan 2010 20:48:27 +0000 (14:48 -0600)
This patch adds a pci bus property 'rombar' which specifies whenever
the pci rom should be loaded via pci rom bar (default) or via fw_cfg.
The later can be used for compatibility with older qemu versions where
no pci rom bar is present.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 88169ddf82853ca892ce7bee279579c8a0ac03e5)

hw/pci.c
hw/pci.h

index 9cc5a6a3efd20b1518ded5f8a87d88bc202ad1dd..8f30f73b7e096cf97f83627e43d78f559db19f26 100644 (file)
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -64,6 +64,7 @@ static struct BusInfo pci_bus_info = {
     .props      = (Property[]) {
         DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
         DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
+        DEFINE_PROP_UINT32("rombar",  PCIDevice, rom_bar, 1),
         DEFINE_PROP_END_OF_LIST()
     }
 };
@@ -1464,6 +1465,20 @@ static int pci_add_option_rom(PCIDevice *pdev)
     if (strlen(pdev->romfile) == 0)
         return 0;
 
+    if (!pdev->rom_bar) {
+        /*
+         * Load rom via fw_cfg instead of creating a rom bar,
+         * for 0.11 compatibility.
+         */
+        int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+        if (class == 0x0300) {
+            rom_add_vga(pdev->romfile);
+        } else {
+            rom_add_option(pdev->romfile);
+        }
+        return 0;
+    }
+
     path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
     if (path == NULL) {
         path = qemu_strdup(pdev->romfile);
index e52e63238091d78c56c3962b8752822e355dc408..dba66ef666e5b9ffdb0e7733962bbc99c7c0f8db 100644 (file)
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -246,6 +246,7 @@ struct PCIDevice {
     /* Location of option rom */
     char *romfile;
     ram_addr_t rom_offset;
+    uint32_t rom_bar;
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,