use C99 initializers for all audio/*
[armpft.git] / hw / isa-bus.c
blob8c14b1d943dadc2e5aff91fb64ce829c27e3cca5
1 /*
2 * isa bus support for qdev.
4 * Copyright (c) 2009 Gerd Hoffmann <kraxel@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #include "hw.h"
20 #include "sysemu.h"
21 #include "isa.h"
23 struct ISABus {
24 BusState qbus;
26 static ISABus *isabus;
28 static struct BusInfo isa_bus_info = {
29 .name = "ISA",
30 .size = sizeof(ISABus),
31 .props = (Property[]) {
33 .name = "iobase",
34 .info = &qdev_prop_hex32,
35 .offset = offsetof(ISADevice, iobase[0]),
36 .defval = (uint32_t[]) { -1 },
37 },{
38 .name = "iobase2",
39 .info = &qdev_prop_hex32,
40 .offset = offsetof(ISADevice, iobase[1]),
41 .defval = (uint32_t[]) { -1 },
43 {/* end of list */}
47 ISABus *isa_bus_new(DeviceState *dev)
49 if (isabus) {
50 fprintf(stderr, "Can't create a second ISA bus\n");
51 return NULL;
54 isabus = FROM_QBUS(ISABus, qbus_create(&isa_bus_info, dev, NULL));
55 return isabus;
58 void isa_connect_irq(ISADevice *dev, int n, qemu_irq irq)
60 assert(n >= 0 && n < dev->nirqs);
61 if (dev->irqs[n])
62 *dev->irqs[n] = irq;
65 void isa_init_irq(ISADevice *dev, qemu_irq *p)
67 assert(dev->nirqs < ARRAY_SIZE(dev->irqs));
68 dev->irqs[dev->nirqs] = p;
69 dev->nirqs++;
72 static void isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
74 ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);
75 ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base);
77 info->init(dev);
80 void isa_qdev_register(ISADeviceInfo *info)
82 info->qdev.init = isa_qdev_init;
83 info->qdev.bus_info = &isa_bus_info;
84 qdev_register(&info->qdev);
87 ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2)
89 DeviceState *dev;
90 ISADevice *isa;
92 if (!isabus) {
93 fprintf(stderr, "Tried to create isa device %s with no isa bus present.\n", name);
94 return NULL;
96 dev = qdev_create(&isabus->qbus, name);
97 isa = DO_UPCAST(ISADevice, qdev, dev);
98 isa->iobase[0] = iobase;
99 isa->iobase[1] = iobase2;
100 qdev_init(dev);
101 return isa;