[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 034/197] qdev: add isa-device as a subclass of de
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH v3 034/197] qdev: add isa-device as a subclass of device |
Date: |
Mon, 12 Dec 2011 14:18:30 -0600 |
Signed-off-by: Anthony Liguori <address@hidden>
---
hw/isa-bus.c | 11 ++++++++++-
hw/isa.h | 12 ++++++++++++
hw/pci.c | 2 +-
hw/qdev.c | 9 +++++++--
hw/qdev.h | 1 +
5 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 7c2c261..0beb1bf 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -126,7 +126,7 @@ void isa_qdev_register(ISADeviceInfo *info)
{
info->qdev.init = isa_qdev_init;
info->qdev.bus_info = &isa_bus_info;
- qdev_register(&info->qdev);
+ qdev_register_subclass(&info->qdev, TYPE_ISA_DEVICE);
}
ISADevice *isa_create(const char *name)
@@ -189,9 +189,18 @@ static SysBusDeviceInfo isabus_bridge_info = {
.qdev.no_user = 1,
};
+static TypeInfo isa_device_type_info = {
+ .name = TYPE_ISA_DEVICE,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(ISADevice),
+ .abstract = true,
+ .class_size = sizeof(ISADeviceClass),
+};
+
static void isabus_register_devices(void)
{
sysbus_register_withprop(&isabus_bridge_info);
+ type_register_static(&isa_device_type_info);
}
static char *isabus_get_fw_dev_path(DeviceState *dev)
diff --git a/hw/isa.h b/hw/isa.h
index 5eb9c78..af7e3dc 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -13,6 +13,18 @@ typedef struct ISABus ISABus;
typedef struct ISADevice ISADevice;
typedef struct ISADeviceInfo ISADeviceInfo;
+#define TYPE_ISA_DEVICE "isa-device"
+#define ISA_DEVICE(obj) \
+ OBJECT_CHECK(ISADeviceState, (obj), ISA_TYPE_DEVICE)
+#define ISA_DEVICE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ISADeviceClass, (klass), ISA_TYPE_DEVICE)
+#define ISA_DEVICE_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ISADeviceClass, (obj), ISA_TYPE_DEVICE)
+
+typedef struct ISADeviceClass {
+ DeviceClass parent_class;
+} ISADeviceClass;
+
struct ISADevice {
DeviceState qdev;
uint32_t isairq[2];
diff --git a/hw/pci.c b/hw/pci.c
index 16d676d..9992ea2 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -161,7 +161,7 @@ void pci_device_reset(PCIDevice *dev)
int r;
/* TODO: call the below unconditionally once all pci devices
* are qdevified */
- if (OBJECT(dev)->type != 0) {
+ if (OBJECT(dev)->class != NULL) {
qdev_reset_all(DEVICE(dev));
}
diff --git a/hw/qdev.c b/hw/qdev.c
index fed9848..e0c4a40 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -61,7 +61,7 @@ DeviceInfo *qdev_get_info(DeviceState *dev)
return DEVICE_GET_CLASS(dev)->info;
}
-void qdev_register(DeviceInfo *info)
+void qdev_register_subclass(DeviceInfo *info, const char *parent)
{
TypeInfo type_info = {};
@@ -69,7 +69,7 @@ void qdev_register(DeviceInfo *info)
assert(!info->next);
type_info.name = info->name;
- type_info.parent = TYPE_DEVICE;
+ type_info.parent = parent;
type_info.instance_size = info->size;
type_info.class_init = qdev_subclass_init;
type_info.class_data = info;
@@ -80,6 +80,11 @@ void qdev_register(DeviceInfo *info)
device_info_list = info;
}
+void qdev_register(DeviceInfo *info)
+{
+ qdev_register_subclass(info, TYPE_DEVICE);
+}
+
static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
{
DeviceInfo *info;
diff --git a/hw/qdev.h b/hw/qdev.h
index cd2eaf2..aab8f42 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -235,6 +235,7 @@ struct DeviceInfo {
extern DeviceInfo *device_info_list;
void qdev_register(DeviceInfo *info);
+void qdev_register_subclass(DeviceInfo *info, const char *parent);
/* Register device properties. */
/* GPIO inputs also double as IRQ sinks. */
--
1.7.4.1
- [Qemu-devel] [PATCH v3 016/197] qom: optimize qdev_get_canonical_path using a parent link, (continued)
- [Qemu-devel] [PATCH v3 016/197] qom: optimize qdev_get_canonical_path using a parent link, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 017/197] qmp: make qmp.py easier to use, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 018/197] qom: add test tools (v2), Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 020/197] qom: add vga node to the pc composition tree, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 021/197] qom: add string property type, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 022/197] qdev: add a qdev_get_type() function and expose as a 'type' property, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 023/197] pc: fill out most of the composition tree, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 024/197] i440fx: split out piix3 device, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 025/197] i440fx: rename piix_pci -> i440fx, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 033/197] a little better approach to this, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 034/197] qdev: add isa-device as a subclass of device,
Anthony Liguori <=
- [Qemu-devel] [PATCH v3 035/197] isa: more isa stuff, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 036/197] qom: make pcidevice part of the hierarchy, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 039/197] virtio-serial-port, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 040/197] get rid of more DO_UPCAST, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 042/197] isa: move methods from isadeviceinfo to isadeviceclass, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 045/197] usb: get rid of info pointer, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 047/197] usb: use a factory instead of doing silly things for legacy, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 046/197] usb: promote all of the methods for USBDevice to class methods, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 049/197] usb-hid: simply class initialization a bit, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 051/197] drop info link in SCSIDeviceInfo, Anthony Liguori, 2011/12/12