From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/4] pci: add romfile property
Date: Wed, 16 Dec 2009 15:15:49 +0100 [thread overview]
Message-ID: <1260972950-31543-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1260972950-31543-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/cirrus_vga.c | 4 +++-
hw/e1000.c | 8 ++------
hw/pci.c | 19 ++++++++++++++++---
hw/pci.h | 3 +--
hw/rtl8139.c | 8 ++------
hw/virtio-pci.c | 8 ++------
6 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index b08d2ae..b2886c4 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3211,7 +3211,9 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
}
/* ROM BIOS */
- pci_add_option_rom((PCIDevice *)d, VGABIOS_CIRRUS_FILENAME);
+ if (dev->rom_filename == NULL) {
+ dev->rom_filename = qemu_strdup(VGABIOS_CIRRUS_FILENAME);
+ }
return 0;
}
diff --git a/hw/e1000.c b/hw/e1000.c
index f795601..021f666 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1122,12 +1122,8 @@ static int pci_e1000_init(PCIDevice *pci_dev)
qemu_format_nic_info_str(&d->nic->nc, macaddr);
- if (!pci_dev->qdev.hotplugged) {
- static int loaded = 0;
- if (!loaded) {
- pci_add_option_rom(&d->dev, "pxe-e1000.bin");
- loaded = 1;
- }
+ if (pci_dev->rom_filename == NULL) {
+ pci_dev->rom_filename = qemu_strdup("pxe-e1000.bin");
}
return 0;
}
diff --git a/hw/pci.c b/hw/pci.c
index dbdfdbf..3ff7d0c 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, rom_filename),
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;
@@ -1387,6 +1389,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
rc = info->init(pci_dev);
if (rc != 0)
return rc;
+ pci_add_option_rom(pci_dev);
if (qdev->hotplugged)
bus->hotplug(pci_dev, 1);
return 0;
@@ -1470,18 +1473,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->rom_filename)
+ return 0;
+ if (strlen(pdev->rom_filename) == 0)
+ return 0;
+
+ path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->rom_filename);
if (path == NULL) {
- path = qemu_strdup(name);
+ path = qemu_strdup(pdev->rom_filename);
}
size = get_image_size(path);
+ if (size < 0) {
+ qemu_error("%s: failed to find romfile \"%s\"\n", __FUNCTION__,
+ pdev->rom_filename);
+ return -1;
+ }
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
diff --git a/hw/pci.h b/hw/pci.h
index 89b3f55..c27e800 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -245,6 +245,7 @@ struct PCIDevice {
int32_t version_id;
/* Location of option rom */
+ char *rom_filename;
ram_addr_t rom_offset;
};
@@ -257,8 +258,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
pcibus_t size, int type,
PCIMapIORegionFunc *map_func);
-int pci_add_option_rom(PCIDevice *pdev, const char *name);
-
int pci_add_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 2cee97b..d096711 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3354,12 +3354,8 @@ static int pci_rtl8139_init(PCIDevice *dev)
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
#endif /* RTL8139_ONBOARD_TIMER */
- if (!dev->qdev.hotplugged) {
- static int loaded = 0;
- if (!loaded) {
- pci_add_option_rom(&s->dev, "pxe-rtl8139.bin");
- loaded = 1;
- }
+ if (dev->rom_filename == NULL) {
+ dev->rom_filename = qemu_strdup("pxe-rtl8139.bin");
}
return 0;
}
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 85f14a2..e38fe70 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -519,12 +519,8 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
/* make the actual value visible */
proxy->nvectors = vdev->nvectors;
- if (!pci_dev->qdev.hotplugged) {
- static int loaded = 0;
- if (!loaded) {
- pci_add_option_rom(pci_dev, "pxe-virtio.bin");
- loaded = 1;
- }
+ if (pci_dev->rom_filename == NULL) {
+ pci_dev->rom_filename = qemu_strdup("pxe-virtio.bin");
}
return 0;
}
--
1.6.5.2
next prev parent reply other threads:[~2009-12-16 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-16 14:15 [Qemu-devel] [PATCH 0/4] rom loading patches Gerd Hoffmann
2009-12-16 14:15 ` [Qemu-devel] [PATCH 1/4] patched seabios binary Gerd Hoffmann
2009-12-16 14:15 ` [Qemu-devel] [PATCH 2/4] Support PCI based option rom loading Gerd Hoffmann
2009-12-16 14:15 ` Gerd Hoffmann [this message]
2009-12-16 14:15 ` [Qemu-devel] [PATCH 4/4] pci: specify default romfile in PCIDeviceInfo Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1260972950-31543-4-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).