summary refs log tree commit diff stats
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:06 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:06 +0100
commit4d6ae6741e4fb3bf809466a5afaa7f5183dc6ffd (patch)
treef1f0a5f9cddf8e3286be652d76517eea91030834 /hw/qdev.c
parentaae9460e244c7abe70b72ff374b3aa102bb09691 (diff)
downloadfocaccia-qemu-4d6ae6741e4fb3bf809466a5afaa7f5183dc6ffd.tar.gz
focaccia-qemu-4d6ae6741e4fb3bf809466a5afaa7f5183dc6ffd.zip
qdev child bus support
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index eaa30f430b..db6f696d2d 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -46,6 +46,12 @@ struct DeviceType {
     DeviceType *next;
 };
 
+struct ChildBusList {
+    const char *name;
+    void *ptr;
+    ChildBusList *next;
+};
+
 static DeviceType *device_type_list;
 
 /* Register a new device type.  */
@@ -235,3 +241,27 @@ BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type)
     }
     return drives_table[index].bdrv;
 }
+
+void *qdev_get_child_bus(DeviceState *dev, const char *name)
+{
+    ChildBusList *bus;
+
+    for (bus = dev->child_bus; bus; bus = bus->next) {
+        if (strcmp(name, bus->name) == 0) {
+            return bus->ptr;
+        }
+    }
+    return NULL;
+}
+
+void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus)
+{
+    ChildBusList *p;
+
+    assert(!qdev_get_child_bus(dev, name));
+    p = qemu_mallocz(sizeof(*p));
+    p->name = qemu_strdup(name);
+    p->ptr = bus;
+    p->next = dev->child_bus;
+    dev->child_bus = p;
+}