diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:06 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:06 +0100 |
commit | 4d6ae6741e4fb3bf809466a5afaa7f5183dc6ffd (patch) | |
tree | f1f0a5f9cddf8e3286be652d76517eea91030834 /hw/qdev.c | |
parent | aae9460e244c7abe70b72ff374b3aa102bb09691 (diff) |
qdev child bus support
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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; +} |