aboutsummaryrefslogtreecommitdiff
path: root/hw/sysbus.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-23 00:05:19 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-23 00:13:41 +0100
commit02e2da45c4601909d5105838323d5c529ec7010b (patch)
treee9b1099baa55c3f8084110feb28f57ede8d2de3a /hw/sysbus.c
parent4856fcff8af1ba349baaf063af00f5e5d87a99f4 (diff)
Add common BusState
Implement and use a common device bus state. The main side-effect is that creating a bus and attaching it to a parent device are no longer separate operations. For legacy code we allow a NULL parent, but that should go away eventually. Also tweak creation code to veriry theat a device in on the right bus. Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/sysbus.c')
-rw-r--r--hw/sysbus.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/hw/sysbus.c b/hw/sysbus.c
index e6cb7dd78b..13d81f541f 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -21,6 +21,11 @@
#include "sysbus.h"
#include "sysemu.h"
+typedef struct {
+ DeviceInfo qdev;
+ sysbus_initfn init;
+} SysBusDeviceInfo;
+
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
{
assert(n >= 0 && n < dev->num_irq);
@@ -97,17 +102,24 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
dev->mmio[n].cb = cb;
}
-static void sysbus_device_init(DeviceState *dev, void *opaque)
+static void sysbus_device_init(DeviceState *dev, DeviceInfo *base)
{
- sysbus_initfn init = (sysbus_initfn)opaque;
+ SysBusDeviceInfo *info = container_of(base, SysBusDeviceInfo, qdev);
- init(sysbus_from_qdev(dev));
+ info->init(sysbus_from_qdev(dev));
}
void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init)
{
+ SysBusDeviceInfo *info;
+
+ info = qemu_mallocz(sizeof(*info));
+ info->init = init;
+ info->qdev.init = sysbus_device_init;
+ info->qdev.bus_type = BUS_TYPE_SYSTEM;
+
assert(size >= sizeof(SysBusDevice));
- qdev_register(name, size, sysbus_device_init, init);
+ qdev_register(name, size, &info->qdev);
}
DeviceState *sysbus_create_varargs(const char *name,