aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.c
diff options
context:
space:
mode:
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 eaa30f4..db6f696 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;
+}