mirror of
https://github.com/qemu/qemu.git
synced 2024-11-25 20:03:37 +08:00
pci: add creation functions that may fail
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
0bcdeda7e4
commit
7cc050b165
20
hw/pci.c
20
hw/pci.c
@ -1708,6 +1708,21 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
|
||||
return DO_UPCAST(PCIDevice, qdev, dev);
|
||||
}
|
||||
|
||||
PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
|
||||
bool multifunction,
|
||||
const char *name)
|
||||
{
|
||||
DeviceState *dev;
|
||||
|
||||
dev = qdev_try_create(&bus->qbus, name);
|
||||
if (!dev) {
|
||||
return NULL;
|
||||
}
|
||||
qdev_prop_set_uint32(dev, "addr", devfn);
|
||||
qdev_prop_set_bit(dev, "multifunction", multifunction);
|
||||
return DO_UPCAST(PCIDevice, qdev, dev);
|
||||
}
|
||||
|
||||
PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
|
||||
bool multifunction,
|
||||
const char *name)
|
||||
@ -1727,6 +1742,11 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
|
||||
return pci_create_simple_multifunction(bus, devfn, false, name);
|
||||
}
|
||||
|
||||
PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name)
|
||||
{
|
||||
return pci_try_create_multifunction(bus, devfn, false, name);
|
||||
}
|
||||
|
||||
static int pci_find_space(PCIDevice *pdev, uint8_t size)
|
||||
{
|
||||
int config_size = pci_config_size(pdev);
|
||||
|
4
hw/pci.h
4
hw/pci.h
@ -453,8 +453,12 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
|
||||
PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
|
||||
bool multifunction,
|
||||
const char *name);
|
||||
PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
|
||||
bool multifunction,
|
||||
const char *name);
|
||||
PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
|
||||
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
|
||||
PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name);
|
||||
|
||||
static inline int pci_is_express(const PCIDevice *d)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user