aboutsummaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-12-20 12:38:47 +0200
committerAvi Kivity <avi@redhat.com>2009-12-20 12:38:47 +0200
commit616d8208b2f75e44ad4a876e517f0829a548f745 (patch)
tree0add92b62676f3d78f3337fc1217f6c58c28ad6f /hw/pci.c
parentMerge commit '72bb3c7571226af13cfe9eec020a56add3d30a70' into stable-0.12-merge (diff)
parentpci romfiles: add property, add default to PCIDeviceInfo (diff)
downloadqemu-kvm-616d8208b2f75e44ad4a876e517f0829a548f745.tar.gz
qemu-kvm-616d8208b2f75e44ad4a876e517f0829a548f745.tar.bz2
qemu-kvm-616d8208b2f75e44ad4a876e517f0829a548f745.zip
Merge commit '898829d5c731516c96f9e3cc3cdcbe36cd494fd4' into stable-0.12-merge
* commit '898829d5c731516c96f9e3cc3cdcbe36cd494fd4': pci romfiles: add property, add default to PCIDeviceInfo Conflicts: hw/pci.h Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 399256cab..637289b9b 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -66,12 +66,14 @@ 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, romfile),
DEFINE_PROP_END_OF_LIST()
}
};
static void pci_update_mappings(PCIDevice *d);
static void pci_set_irq(void *opaque, int irq_num, int level);
+static int pci_add_option_rom(PCIDevice *pdev);
target_phys_addr_t pci_mem_base;
static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
@@ -1479,6 +1481,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;
@@ -1593,18 +1601,28 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p
}
/* Add an option rom for the device */
-int pci_add_option_rom(PCIDevice *pdev, const char *name)
+static int pci_add_option_rom(PCIDevice *pdev)
{
int size;
char *path;
void *ptr;
- path = qemu_find_file(QEMU_FILE_TYPE_BIOS, name);
+ if (!pdev->romfile)
+ return 0;
+ if (strlen(pdev->romfile) == 0)
+ return 0;
+
+ path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
- path = qemu_strdup(name);
+ path = qemu_strdup(pdev->romfile);
}
size = get_image_size(path);
+ if (size < 0) {
+ qemu_error("%s: failed to find romfile \"%s\"\n", __FUNCTION__,
+ pdev->romfile);
+ return -1;
+ }
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}