qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 036/197] qom: make pcidevice part of the hierarch


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH v3 036/197] qom: make pcidevice part of the hierarchy
Date: Mon, 12 Dec 2011 14:18:32 -0600

---
 hw/pci.c  |   18 ++++++++++++++++--
 hw/pci.h  |   12 ++++++++++++
 hw/qdev.c |    5 +++++
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 9992ea2..04fd95f 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -89,7 +89,6 @@ static const VMStateDescription vmstate_pcibus = {
         VMSTATE_END_OF_LIST()
     }
 };
-
 static int pci_bar(PCIDevice *d, int reg)
 {
     uint8_t type;
@@ -1550,7 +1549,7 @@ void pci_qdev_register(PCIDeviceInfo *info)
     info->qdev.unplug = pci_unplug_device;
     info->qdev.exit = pci_unregister_device;
     info->qdev.bus_info = &pci_bus_info;
-    qdev_register(&info->qdev);
+    qdev_register_subclass(&info->qdev, TYPE_PCI_DEVICE);
 }
 
 void pci_qdev_register_many(PCIDeviceInfo *info)
@@ -2038,3 +2037,18 @@ MemoryRegion *pci_address_space_io(PCIDevice *dev)
 {
     return dev->bus->address_space_io;
 }
+
+static TypeInfo pci_device_type_info = {
+    .name = TYPE_PCI_DEVICE,
+    .parent = TYPE_DEVICE,
+    .instance_size = sizeof(PCIDevice),
+    .abstract = true,
+    .class_size = sizeof(PCIDeviceClass),
+};
+
+static void pci_register_devices(void)
+{
+    type_register_static(&pci_device_type_info);
+}
+
+device_init(pci_register_devices);
diff --git a/hw/pci.h b/hw/pci.h
index 625e717..00c9897 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -127,6 +127,18 @@ enum {
     QEMU_PCI_CAP_SERR = (1 << QEMU_PCI_CAP_SERR_BITNR),
 };
 
+#define TYPE_PCI_DEVICE "pci-device"
+#define PCI_DEVICE(obj) \
+     OBJECT_CHECK(PCIDevice, (obj), TYPE_PCI_DEVICE)
+#define PCI_DEVICE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(PCIDeviceClass, (klass), TYPE_PCI_DEVICE)
+#define PCI_DEVICE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(PCIDeviceClass, (obj), TYPE_PCI_DEVICE)
+
+typedef struct PCIDeviceClass {
+    DeviceClass parent_class;
+} PCIDeviceClass;
+
 struct PCIDevice {
     DeviceState qdev;
     /* PCI config space */
diff --git a/hw/qdev.c b/hw/qdev.c
index e0c4a40..09f8b4c 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -111,6 +111,11 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const 
char *name)
     return NULL;
 }
 
+/* FIXME: need to figure out somethign to do with bus.
+ *
+ * The general problem is that we don't want to take a bus argument on
+ * create.  there's simply no way to pass it to instance init.
+ */
 static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
 {
     DeviceState *dev;
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]