aboutsummaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-12-18 12:01:08 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-18 11:26:34 -0600
commit8c52c8f320b27684ec3b1a649925b75af376b1f7 (patch)
tree3319fe6f7e835d0a718000ae04be89f380d72406 /hw/pci.c
parentc2039bd0ffce8807e0eaac55254fde790825fa92 (diff)
pci romfiles: add property, add default to PCIDeviceInfo
This patch adds a romfile property to the pci bus. It allows to specify a romfile to load into the rom bar of the pci device. The default value comes from a new field in PCIDeviceInfo. The property allows to change the file and also to disable the rom loading using an empty string. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.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 b037fd8902..9cc5a6a3ef 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -63,12 +63,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;
@@ -1362,6 +1364,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;
@@ -1445,18 +1453,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);
}