diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2011-02-05 14:34:56 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2011-02-12 09:45:03 +0000 |
commit | 4912371fc39120fb7eb1a6b3f270fab30d05a7b6 (patch) | |
tree | e4afd92efce18ebbbae098459dde8288117312a4 /hw/sysbus.c | |
parent | 86d864140bc597dce0fedf8547f4d615a920c444 (diff) | |
download | qemu-4912371fc39120fb7eb1a6b3f270fab30d05a7b6.zip qemu-4912371fc39120fb7eb1a6b3f270fab30d05a7b6.tar.gz qemu-4912371fc39120fb7eb1a6b3f270fab30d05a7b6.tar.bz2 |
sysbus: add creation function that may fail
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/sysbus.c')
-rw-r--r-- | hw/sysbus.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/hw/sysbus.c b/hw/sysbus.c index 1928b51..acad72a 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -173,6 +173,37 @@ DeviceState *sysbus_create_varargs(const char *name, return dev; } +DeviceState *sysbus_try_create_varargs(const char *name, + target_phys_addr_t addr, ...) +{ + DeviceState *dev; + SysBusDevice *s; + va_list va; + qemu_irq irq; + int n; + + dev = qdev_try_create(NULL, name); + if (!dev) { + return NULL; + } + s = sysbus_from_qdev(dev); + qdev_init_nofail(dev); + if (addr != (target_phys_addr_t)-1) { + sysbus_mmio_map(s, 0, addr); + } + va_start(va, addr); + n = 0; + while (1) { + irq = va_arg(va, qemu_irq); + if (!irq) { + break; + } + sysbus_connect_irq(s, n, irq); + n++; + } + return dev; +} + static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent) { SysBusDevice *s = sysbus_from_qdev(dev); |