[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 04/18] hw/ide/piix: Expose output IRQ as properties for late o
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 04/18] hw/ide/piix: Expose output IRQ as properties for late object population |
Date: |
Wed, 15 Feb 2023 17:16:27 +0100 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ide/piix.c | 14 ++++++++++++--
include/hw/ide/pci.h | 1 +
include/hw/ide/piix.h | 4 ++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 41d60921e3..9d876dd4a7 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -121,6 +121,13 @@ static void piix_ide_reset(DeviceState *dev)
pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */
}
+static void piix_ide_initfn(Object *obj)
+{
+ PCIIDEState *dev = PCI_IDE(obj);
+
+ qdev_init_gpio_out_named(DEVICE(obj), dev->irq, "ide-irq", 2);
+}
+
static bool pci_piix_init_bus(PCIIDEState *d, unsigned i, Error **errp)
{
static const struct {
@@ -133,6 +140,7 @@ static bool pci_piix_init_bus(PCIIDEState *d, unsigned i,
Error **errp)
};
int ret;
+ qemu_irq irq_out = d->irq[i] ? : isa_get_irq(NULL, port_info[i].isairq);
ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
ret = ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase,
port_info[i].iobase2);
@@ -141,7 +149,7 @@ static bool pci_piix_init_bus(PCIIDEState *d, unsigned i,
Error **errp)
object_get_typename(OBJECT(d)), i);
return false;
}
- ide_bus_init_output_irq(&d->bus[i], isa_get_irq(NULL,
port_info[i].isairq));
+ ide_bus_init_output_irq(&d->bus[i], irq_out);
bmdma_init(&d->bus[i], &d->bmdma[i], d);
d->bmdma[i].bus = &d->bus[i];
@@ -162,7 +170,7 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error
**errp)
vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
- for (unsigned i = 0; i < 2; i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(d->irq); i++) {
if (!pci_piix_init_bus(d, i, errp)) {
return;
}
@@ -199,6 +207,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void
*data)
static const TypeInfo piix3_ide_info = {
.name = TYPE_PIIX3_IDE,
.parent = TYPE_PCI_IDE,
+ .instance_init = piix_ide_initfn,
.class_init = piix3_ide_class_init,
};
@@ -221,6 +230,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void
*data)
static const TypeInfo piix4_ide_info = {
.name = TYPE_PIIX4_IDE,
.parent = TYPE_PCI_IDE,
+ .instance_init = piix_ide_initfn,
.class_init = piix4_ide_class_init,
};
diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h
index 7b5e3f6e1c..548e539add 100644
--- a/include/hw/ide/pci.h
+++ b/include/hw/ide/pci.h
@@ -49,6 +49,7 @@ struct PCIIDEState {
IDEBus bus[2];
BMDMAState bmdma[2];
+ qemu_irq irq[2];
uint32_t secondary; /* used only for cmd646 */
MemoryRegion bmdma_bar;
MemoryRegion cmd_bar[2];
diff --git a/include/hw/ide/piix.h b/include/hw/ide/piix.h
index ef3ef3d62d..533d24d408 100644
--- a/include/hw/ide/piix.h
+++ b/include/hw/ide/piix.h
@@ -1,6 +1,10 @@
#ifndef HW_IDE_PIIX_H
#define HW_IDE_PIIX_H
+/*
+ * QEMU interface:
+ * + named GPIO outputs "ide-irq": asserted by each IDE channel
+ */
#define TYPE_PIIX3_IDE "piix3-ide"
#define TYPE_PIIX4_IDE "piix4-ide"
--
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é, 2023/02/15
- [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é <=
- [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
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Bernhard Beschow, 2023/02/16
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Philippe Mathieu-Daudé, 2023/02/16
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Bernhard Beschow, 2023/02/16
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Philippe Mathieu-Daudé, 2023/02/19
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Bernhard Beschow, 2023/02/20
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, BALATON Zoltan, 2023/02/20
- Re: [PATCH v2 07/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization, Daniel P . Berrangé, 2023/02/21