[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 02/18] hw/isa: Factor isa_bus_get_irq() out of isa_get_irq()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 02/18] hw/isa: Factor isa_bus_get_irq() out of isa_get_irq() |
Date: |
Wed, 15 Feb 2023 17:16:25 +0100 |
isa_get_irq() was added in commit 3a38d437ca
("Add isa_reserve_irq()" Fri Aug 14 11:36:15 2009) as:
a temporary interface to be used to allocate ISA IRQs for
devices which have not yet been converted to qdev, and for
special cases which are not suited for qdev conversions,
such as the 'ferr'.
We still use it 14 years later, using the global 'isabus'
singleton. In order to get rid of such *temporary* interface,
extract isa_bus_get_irq() which can take any ISABus* object.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/isa/isa-bus.c | 14 ++++++++++----
include/hw/isa/isa.h | 8 ++++++++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index 39111f74cc..96bfee9aa7 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -72,6 +72,13 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs)
bus->irqs = irqs;
}
+qemu_irq isa_bus_get_irq(ISABus *bus, unsigned irqnum)
+{
+ assert(irqnum < ISA_NUM_IRQS);
+ assert(bus && bus->irqs);
+ return bus->irqs[irqnum];
+}
+
/*
* isa_get_irq() returns the corresponding qemu_irq entry for the i8259.
*
@@ -81,14 +88,13 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs)
qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq)
{
assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) == isabus);
- assert(isairq < ISA_NUM_IRQS);
- return isabus->irqs[isairq];
+ return isa_bus_get_irq(isabus, isairq);
}
void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq)
{
- qemu_irq irq = isa_get_irq(isadev, isairq);
- qdev_connect_gpio_out(DEVICE(isadev), gpioirq, irq);
+ qemu_irq input_irq = isa_get_irq(isadev, isairq);
+ qdev_connect_gpio_out(DEVICE(isadev), gpioirq, input_irq);
}
void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16)
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 029d6e90bf..42d36b21a3 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -80,6 +80,14 @@ void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16);
IsaDma *isa_bus_get_dma(ISABus *bus, int nchan);
MemoryRegion *isa_address_space(ISADevice *dev);
MemoryRegion *isa_address_space_io(ISADevice *dev);
+/**
+ * isa_bus_get_irq: Return input IRQ on ISA bus.
+ * @bus: the #ISABus to plug ISA devices on.
+ * @irqnum: the ISA IRQ number.
+ *
+ * Return IRQ @irqnum from the PIC associated on ISA @bus.
+ */
+qemu_irq isa_bus_get_irq(ISABus *bus, unsigned irqnum);
ISADevice *isa_new(const char *name);
ISADevice *isa_try_new(const char *name);
bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
--
2.38.1
- [PATCH v2 00/18] hw/ide: Untangle ISA/PCI abuses of ide_init_ioport(), Philippe Mathieu-Daudé, 2023/02/15
- [PATCH v2 01/18] hw/isa: Rename isa_get_dma() -> isa_bus_get_dma(), Philippe Mathieu-Daudé, 2023/02/15
- [PATCH v2 02/18] hw/isa: Factor isa_bus_get_irq() out of isa_get_irq(),
Philippe Mathieu-Daudé <=
- [PATCH v2 03/18] hw: Replace isa_get_irq() by isa_bus_get_irq() when ISABus is available, Philippe Mathieu-Daudé, 2023/02/15
- [PATCH v2 04/18] hw/ide/piix: Expose output IRQ as properties for late object population, Philippe Mathieu-Daudé, 2023/02/15
- [PATCH v2 05/18] hw/i386/pc_piix: Wire PIIX3 IDE ouput IRQs to ISA bus IRQs 14/15, Philippe Mathieu-Daudé, 2023/02/15
- [PATCH v2 06/18] hw/isa/piix4: Wire PIIX4 IDE ouput IRQs to ISA bus IRQs 14/15, Philippe Mathieu-Daudé, 2023/02/15
- [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Philippe Mathieu-Daudé, 2023/02/15