aboutsummaryrefslogtreecommitdiff
path: root/hw/isa-bus.c
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-12-08 13:34:56 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-12-11 21:27:46 +0000
commitdee41d58ef7b874fd8a07e9e0ae4ef6e7fe624fc (patch)
treebf50e58bad6dda3e9e334ebd57373b7bdc3b8d17 /hw/isa-bus.c
parent21150814d9f0d40b77f8ec54e716505b85b87e6b (diff)
downloadqemu-dee41d58ef7b874fd8a07e9e0ae4ef6e7fe624fc.zip
qemu-dee41d58ef7b874fd8a07e9e0ae4ef6e7fe624fc.tar.gz
qemu-dee41d58ef7b874fd8a07e9e0ae4ef6e7fe624fc.tar.bz2
Keep track of ISA ports ISA device is using in qdev.
Store all io ports used by device in ISADevice structure. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/isa-bus.c')
-rw-r--r--hw/isa-bus.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index f9c7ec0..5486efa 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -89,6 +89,31 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
dev->nirqs++;
}
+static void isa_init_ioport_one(ISADevice *dev, uint16_t ioport)
+{
+ assert(dev->nioports < ARRAY_SIZE(dev->ioports));
+ dev->ioports[dev->nioports++] = ioport;
+}
+
+static int isa_cmp_ports(const void *p1, const void *p2)
+{
+ return *(uint16_t*)p1 - *(uint16_t*)p2;
+}
+
+void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length)
+{
+ int i;
+ for (i = start; i < start + length; i++) {
+ isa_init_ioport_one(dev, i);
+ }
+ qsort(dev->ioports, dev->nioports, sizeof(dev->ioports[0]), isa_cmp_ports);
+}
+
+void isa_init_ioport(ISADevice *dev, uint16_t ioport)
+{
+ isa_init_ioport_range(dev, ioport, 1);
+}
+
static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);