From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCQg-0006h8-Jp for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:24:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaCQf-0001GM-Aj for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:24:54 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:55845 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCQf-0001GI-0s for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:24:53 -0500 From: Anthony Liguori Date: Mon, 12 Dec 2011 14:18:32 -0600 Message-Id: <1323721273-32404-37-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> References: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH v3 036/197] qom: make pcidevice part of the hierarchy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , Markus Armbruster , Luiz Capitulino --- 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