isa: add isa_register_ioport()

To replace isa_init_ioport and isa_init_ioport_range
as the ISA devices are converted to the memory api.

[avi: use memory_region_size()]

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Richard Henderson 2011-08-10 15:28:12 -07:00 committed by Avi Kivity
parent c2d0d01202
commit 78e2059352
2 changed files with 14 additions and 1 deletions

View file

@ -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, memory_region_size(io));
}
}
static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);

View file

@ -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);