Patchwork [03/11] isa: add isa_register_ioport()

login
register
mail settings
Submitter Richard Henderson
Date Aug. 10, 2011, 10:28 p.m.
Message ID <1313015300-23920-4-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/109472/
State New
Headers show

Comments

Richard Henderson - Aug. 10, 2011, 10:28 p.m.
To replace isa_init_ioport and isa_init_ioport_range
as the ISA devices are converted to the memory api.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 hw/isa-bus.c |   10 ++++++++++
 hw/isa.h     |    5 ++++-
 2 files changed, 14 insertions(+), 1 deletions(-)
Avi Kivity - Aug. 11, 2011, 6:18 a.m.
On 08/11/2011 01:28 AM, Richard Henderson wrote:
> To replace isa_init_ioport and isa_init_ioport_range
> as the ISA devices are converted to the memory api.
>
>
> +void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start)
> +{
> +    memory_region_add_subregion(isabus->address_space_io, start, io);
> +    if (dev != NULL) {
> +        assert(dev->nio<  ARRAY_SIZE(dev->io));
> +        dev->io[dev->nio++] = io;
> +        isa_init_ioport_range(dev, start, io->size);
> +    }
> +}

memory_region_size(io);

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index d067505..b49e6c6 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -108,6 +108,16 @@  void isa_init_ioport(ISADevice *dev, uint16_t ioport)
     isa_init_ioport_range(dev, ioport, 1);
 }
 
+void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start)
+{
+    memory_region_add_subregion(isabus->address_space_io, start, io);
+    if (dev != NULL) {
+        assert(dev->nio < ARRAY_SIZE(dev->io));
+        dev->io[dev->nio++] = io;
+        isa_init_ioport_range(dev, start, io->size);
+    }
+}
+
 static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
 {
     ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);
diff --git a/hw/isa.h b/hw/isa.h
index 390e2d4..432d17a 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -13,10 +13,12 @@  typedef struct ISADeviceInfo ISADeviceInfo;
 
 struct ISADevice {
     DeviceState qdev;
+    MemoryRegion *io[32];
     uint32_t isairq[2];
-    int nirqs;
     uint16_t ioports[32];
+    int nirqs;
     int nioports;
+    int nio;
 };
 
 typedef int (*isa_qdev_initfn)(ISADevice *dev);
@@ -29,6 +31,7 @@  ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
 void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_get_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
+void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
 void isa_init_ioport(ISADevice *dev, uint16_t ioport);
 void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
 void isa_qdev_register(ISADeviceInfo *info);