mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
hw/pxb: Use a type for realizing expanders
This opens up the possibility for more types of expanders (other than PCI and PCIe). We'll need this to create a CXL expander. Signed-off-by: Ben Widawsky <ben.widawsky@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220429144110.25167-12-Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
056172691b
commit
25a2e524e3
|
@ -24,6 +24,8 @@
|
||||||
#include "hw/boards.h"
|
#include "hw/boards.h"
|
||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
|
|
||||||
|
enum BusType { PCI, PCIE };
|
||||||
|
|
||||||
#define TYPE_PXB_BUS "pxb-bus"
|
#define TYPE_PXB_BUS "pxb-bus"
|
||||||
typedef struct PXBBus PXBBus;
|
typedef struct PXBBus PXBBus;
|
||||||
DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS,
|
DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS,
|
||||||
|
@ -221,7 +223,8 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
|
static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
PXBDev *pxb = convert_to_pxb(dev);
|
PXBDev *pxb = convert_to_pxb(dev);
|
||||||
DeviceState *ds, *bds = NULL;
|
DeviceState *ds, *bds = NULL;
|
||||||
|
@ -246,7 +249,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
ds = qdev_new(TYPE_PXB_HOST);
|
ds = qdev_new(TYPE_PXB_HOST);
|
||||||
if (pcie) {
|
if (type == PCIE) {
|
||||||
bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS);
|
bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS);
|
||||||
} else {
|
} else {
|
||||||
bus = pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS);
|
bus = pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS);
|
||||||
|
@ -295,7 +298,7 @@ static void pxb_dev_realize(PCIDevice *dev, Error **errp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxb_dev_realize_common(dev, false, errp);
|
pxb_dev_realize_common(dev, PCI, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pxb_dev_exitfn(PCIDevice *pci_dev)
|
static void pxb_dev_exitfn(PCIDevice *pci_dev)
|
||||||
|
@ -348,7 +351,7 @@ static void pxb_pcie_dev_realize(PCIDevice *dev, Error **errp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxb_dev_realize_common(dev, true, errp);
|
pxb_dev_realize_common(dev, PCIE, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
|
static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
|
||||||
|
|
Loading…
Reference in a new issue