diff mbox

[4/4] pci: specify default romfile in PCIDeviceInfo.

Message ID 1260972950-31543-5-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Dec. 16, 2009, 2:15 p.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/cirrus_vga.c |    6 +-----
 hw/e1000.c      |    5 +----
 hw/pci.c        |   17 +++++++++++------
 hw/pci.h        |    5 ++++-
 hw/rtl8139.c    |    5 +----
 hw/virtio-pci.c |    5 +----
 6 files changed, 19 insertions(+), 24 deletions(-)
diff mbox

Patch

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index b2886c4..6fe433d 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3209,11 +3209,6 @@  static int pci_cirrus_vga_initfn(PCIDevice *dev)
          pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
                           PCI_BASE_ADDRESS_SPACE_MEMORY, cirrus_pci_mmio_map);
      }
-
-     /* ROM BIOS */
-     if (dev->rom_filename == NULL) {
-         dev->rom_filename = qemu_strdup(VGABIOS_CIRRUS_FILENAME);
-     }
      return 0;
 }
 
@@ -3228,6 +3223,7 @@  static PCIDeviceInfo cirrus_vga_info = {
     .qdev.size    = sizeof(PCICirrusVGAState),
     .qdev.vmsd    = &vmstate_pci_cirrus_vga,
     .init         = pci_cirrus_vga_initfn,
+    .romfile      = VGABIOS_CIRRUS_FILENAME,
     .config_write = pci_cirrus_write_config,
 };
 
diff --git a/hw/e1000.c b/hw/e1000.c
index 021f666..33c4bc6 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1121,10 +1121,6 @@  static int pci_e1000_init(PCIDevice *pci_dev)
                           d->dev.qdev.info->name, d->dev.qdev.id, d);
 
     qemu_format_nic_info_str(&d->nic->nc, macaddr);
-
-    if (pci_dev->rom_filename == NULL) {
-        pci_dev->rom_filename = qemu_strdup("pxe-e1000.bin");
-    }
     return 0;
 }
 
@@ -1142,6 +1138,7 @@  static PCIDeviceInfo e1000_info = {
     .qdev.vmsd  = &vmstate_e1000,
     .init       = pci_e1000_init,
     .exit       = pci_e1000_uninit,
+    .romfile    = "pxe-e1000.bin",
     .qdev.props = (Property[]) {
         DEFINE_NIC_PROPERTIES(E1000State, conf),
         DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/pci.c b/hw/pci.c
index 3ff7d0c..d54f05e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -63,7 +63,7 @@  static struct BusInfo pci_bus_info = {
     .print_dev  = pcibus_dev_print,
     .props      = (Property[]) {
         DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
-        DEFINE_PROP_STRING("romfile", PCIDevice, rom_filename),
+        DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
         DEFINE_PROP_END_OF_LIST()
     }
 };
@@ -1389,7 +1389,12 @@  static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
     rc = info->init(pci_dev);
     if (rc != 0)
         return rc;
+
+    /* rom loading */
+    if (pci_dev->romfile == NULL && info->romfile != NULL)
+        pci_dev->romfile = qemu_strdup(info->romfile);
     pci_add_option_rom(pci_dev);
+
     if (qdev->hotplugged)
         bus->hotplug(pci_dev, 1);
     return 0;
@@ -1479,20 +1484,20 @@  static int pci_add_option_rom(PCIDevice *pdev)
     char *path;
     void *ptr;
 
-    if (!pdev->rom_filename)
+    if (!pdev->romfile)
         return 0;
-    if (strlen(pdev->rom_filename) == 0)
+    if (strlen(pdev->romfile) == 0)
         return 0;
 
-    path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->rom_filename);
+    path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
     if (path == NULL) {
-        path = qemu_strdup(pdev->rom_filename);
+        path = qemu_strdup(pdev->romfile);
     }
 
     size = get_image_size(path);
     if (size < 0) {
         qemu_error("%s: failed to find romfile \"%s\"\n", __FUNCTION__,
-                   pdev->rom_filename);
+                   pdev->romfile);
         return -1;
     }
     if (size & (size - 1)) {
diff --git a/hw/pci.h b/hw/pci.h
index c27e800..39da7df 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -245,7 +245,7 @@  struct PCIDevice {
     int32_t version_id;
 
     /* Location of option rom */
-    char *rom_filename;
+    char *romfile;
     ram_addr_t rom_offset;
 };
 
@@ -385,6 +385,9 @@  typedef struct {
 
     /* pcie stuff */
     int is_express;   /* is this device pci express? */
+
+    /* rom bar */
+    const char *romfile;
 } PCIDeviceInfo;
 
 void pci_qdev_register(PCIDeviceInfo *info);
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index d096711..fcdcd1d 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3353,10 +3353,6 @@  static int pci_rtl8139_init(PCIDevice *dev)
     qemu_mod_timer(s->timer,
         rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
 #endif /* RTL8139_ONBOARD_TIMER */
-
-    if (dev->rom_filename == NULL) {
-        dev->rom_filename = qemu_strdup("pxe-rtl8139.bin");
-    }
     return 0;
 }
 
@@ -3367,6 +3363,7 @@  static PCIDeviceInfo rtl8139_info = {
     .qdev.vmsd  = &vmstate_rtl8139,
     .init       = pci_rtl8139_init,
     .exit       = pci_rtl8139_uninit,
+    .romfile    = "pxe-rtl8139.bin",
     .qdev.props = (Property[]) {
         DEFINE_NIC_PROPERTIES(RTL8139State, conf),
         DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index e38fe70..62b46bd 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -518,10 +518,6 @@  static int virtio_net_init_pci(PCIDevice *pci_dev)
 
     /* make the actual value visible */
     proxy->nvectors = vdev->nvectors;
-
-    if (pci_dev->rom_filename == NULL) {
-        pci_dev->rom_filename = qemu_strdup("pxe-virtio.bin");
-    }
     return 0;
 }
 
@@ -565,6 +561,7 @@  static PCIDeviceInfo virtio_info[] = {
         .qdev.size  = sizeof(VirtIOPCIProxy),
         .init       = virtio_net_init_pci,
         .exit       = virtio_net_exit_pci,
+        .romfile    = "pxe-virtio.bin",
         .qdev.props = (Property[]) {
             DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
             DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),