From: Corey Minyard <cminy...@mvista.com> This lets devices that don't care about their interrupt number, like IPMI, just grab any unused interrupt.
Signed-off-by: Corey Minyard <cminy...@mvista.com> --- hw/isa-bus.c | 13 +++++++++++++ hw/isa.h | 2 ++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 5a43f03..f561f21 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -71,6 +71,7 @@ qemu_irq isa_get_irq(ISADevice *dev, int isairq) if (isairq < 0 || isairq > 15) { hw_error("isa irq %d invalid", isairq); } + isabus->irq_inuse[isairq] = 1; return isabus->irqs[isairq]; } @@ -82,6 +83,18 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) dev->nirqs++; } +int isa_find_free_irq(ISABus *bus) +{ + unsigned int i; + + /* 0 and 1 are called for, 2 is the chain interrupt */ + for (i = 3; i < ISA_NUM_IRQS; i++) { + if (!bus->irq_inuse[i]) + return i; + } + return 0; +} + static inline void isa_init_ioport(ISADevice *dev, uint16_t ioport) { if (dev && (dev->ioport_id == 0 || ioport < dev->ioport_id)) { diff --git a/hw/isa.h b/hw/isa.h index f7bc4b5..9447296 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -28,6 +28,7 @@ struct ISABus { BusState qbus; MemoryRegion *address_space_io; qemu_irq *irqs; + int irq_inuse[ISA_NUM_IRQS]; }; struct ISADevice { @@ -41,6 +42,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io); void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); qemu_irq isa_get_irq(ISADevice *dev, int isairq); void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); +int isa_find_free_irq(ISABus *bus); MemoryRegion *isa_address_space(ISADevice *dev); ISADevice *isa_create(ISABus *bus, const char *name); ISADevice *isa_try_create(ISABus *bus, const char *name); -- 1.7.4.1