mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-07 11:28:46 +00:00
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>
This commit is contained in:
parent
c2039bd0ff
commit
8c52c8f320
@ -3209,9 +3209,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
|
|||||||
pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
|
pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
|
||||||
PCI_BASE_ADDRESS_SPACE_MEMORY, cirrus_pci_mmio_map);
|
PCI_BASE_ADDRESS_SPACE_MEMORY, cirrus_pci_mmio_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ROM BIOS */
|
|
||||||
pci_add_option_rom((PCIDevice *)d, VGABIOS_CIRRUS_FILENAME);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3226,6 +3223,7 @@ static PCIDeviceInfo cirrus_vga_info = {
|
|||||||
.qdev.size = sizeof(PCICirrusVGAState),
|
.qdev.size = sizeof(PCICirrusVGAState),
|
||||||
.qdev.vmsd = &vmstate_pci_cirrus_vga,
|
.qdev.vmsd = &vmstate_pci_cirrus_vga,
|
||||||
.init = pci_cirrus_vga_initfn,
|
.init = pci_cirrus_vga_initfn,
|
||||||
|
.romfile = VGABIOS_CIRRUS_FILENAME,
|
||||||
.config_write = pci_cirrus_write_config,
|
.config_write = pci_cirrus_write_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1121,14 +1121,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
|
|||||||
d->dev.qdev.info->name, d->dev.qdev.id, d);
|
d->dev.qdev.info->name, d->dev.qdev.id, d);
|
||||||
|
|
||||||
qemu_format_nic_info_str(&d->nic->nc, macaddr);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1146,6 +1138,7 @@ static PCIDeviceInfo e1000_info = {
|
|||||||
.qdev.vmsd = &vmstate_e1000,
|
.qdev.vmsd = &vmstate_e1000,
|
||||||
.init = pci_e1000_init,
|
.init = pci_e1000_init,
|
||||||
.exit = pci_e1000_uninit,
|
.exit = pci_e1000_uninit,
|
||||||
|
.romfile = "pxe-e1000.bin",
|
||||||
.qdev.props = (Property[]) {
|
.qdev.props = (Property[]) {
|
||||||
DEFINE_NIC_PROPERTIES(E1000State, conf),
|
DEFINE_NIC_PROPERTIES(E1000State, conf),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
24
hw/pci.c
24
hw/pci.c
@ -63,12 +63,14 @@ static struct BusInfo pci_bus_info = {
|
|||||||
.print_dev = pcibus_dev_print,
|
.print_dev = pcibus_dev_print,
|
||||||
.props = (Property[]) {
|
.props = (Property[]) {
|
||||||
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
|
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
|
||||||
|
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
|
||||||
DEFINE_PROP_END_OF_LIST()
|
DEFINE_PROP_END_OF_LIST()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pci_update_mappings(PCIDevice *d);
|
static void pci_update_mappings(PCIDevice *d);
|
||||||
static void pci_set_irq(void *opaque, int irq_num, int level);
|
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;
|
target_phys_addr_t pci_mem_base;
|
||||||
static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
|
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);
|
rc = info->init(pci_dev);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
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)
|
if (qdev->hotplugged)
|
||||||
bus->hotplug(pci_dev, 1);
|
bus->hotplug(pci_dev, 1);
|
||||||
return 0;
|
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 */
|
/* 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;
|
int size;
|
||||||
char *path;
|
char *path;
|
||||||
void *ptr;
|
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) {
|
if (path == NULL) {
|
||||||
path = qemu_strdup(name);
|
path = qemu_strdup(pdev->romfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
size = get_image_size(path);
|
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)) {
|
if (size & (size - 1)) {
|
||||||
size = 1 << qemu_fls(size);
|
size = 1 << qemu_fls(size);
|
||||||
}
|
}
|
||||||
|
6
hw/pci.h
6
hw/pci.h
@ -244,6 +244,7 @@ struct PCIDevice {
|
|||||||
int32_t version_id;
|
int32_t version_id;
|
||||||
|
|
||||||
/* Location of option rom */
|
/* Location of option rom */
|
||||||
|
char *romfile;
|
||||||
ram_addr_t rom_offset;
|
ram_addr_t rom_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,8 +257,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
|||||||
pcibus_t size, int type,
|
pcibus_t size, int type,
|
||||||
PCIMapIORegionFunc *map_func);
|
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);
|
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);
|
void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
|
||||||
@ -385,6 +384,9 @@ typedef struct {
|
|||||||
|
|
||||||
/* pcie stuff */
|
/* pcie stuff */
|
||||||
int is_express; /* is this device pci express? */
|
int is_express; /* is this device pci express? */
|
||||||
|
|
||||||
|
/* rom bar */
|
||||||
|
const char *romfile;
|
||||||
} PCIDeviceInfo;
|
} PCIDeviceInfo;
|
||||||
|
|
||||||
void pci_qdev_register(PCIDeviceInfo *info);
|
void pci_qdev_register(PCIDeviceInfo *info);
|
||||||
|
@ -3353,14 +3353,6 @@ static int pci_rtl8139_init(PCIDevice *dev)
|
|||||||
qemu_mod_timer(s->timer,
|
qemu_mod_timer(s->timer,
|
||||||
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
|
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
|
||||||
#endif /* RTL8139_ONBOARD_TIMER */
|
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3371,6 +3363,7 @@ static PCIDeviceInfo rtl8139_info = {
|
|||||||
.qdev.vmsd = &vmstate_rtl8139,
|
.qdev.vmsd = &vmstate_rtl8139,
|
||||||
.init = pci_rtl8139_init,
|
.init = pci_rtl8139_init,
|
||||||
.exit = pci_rtl8139_uninit,
|
.exit = pci_rtl8139_uninit,
|
||||||
|
.romfile = "pxe-rtl8139.bin",
|
||||||
.qdev.props = (Property[]) {
|
.qdev.props = (Property[]) {
|
||||||
DEFINE_NIC_PROPERTIES(RTL8139State, conf),
|
DEFINE_NIC_PROPERTIES(RTL8139State, conf),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
@ -518,14 +518,6 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
|
|||||||
|
|
||||||
/* make the actual value visible */
|
/* make the actual value visible */
|
||||||
proxy->nvectors = vdev->nvectors;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,6 +561,7 @@ static PCIDeviceInfo virtio_info[] = {
|
|||||||
.qdev.size = sizeof(VirtIOPCIProxy),
|
.qdev.size = sizeof(VirtIOPCIProxy),
|
||||||
.init = virtio_net_init_pci,
|
.init = virtio_net_init_pci,
|
||||||
.exit = virtio_net_exit_pci,
|
.exit = virtio_net_exit_pci,
|
||||||
|
.romfile = "pxe-virtio.bin",
|
||||||
.qdev.props = (Property[]) {
|
.qdev.props = (Property[]) {
|
||||||
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
|
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
|
||||||
DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
|
DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
|
||||||
|
Loading…
Reference in New Issue
Block a user