[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 22/32] hw/isa/piix4: Use Proxy PIC device
From: |
Bernhard Beschow |
Subject: |
[PATCH 22/32] hw/isa/piix4: Use Proxy PIC device |
Date: |
Sun, 4 Dec 2022 20:05:43 +0100 |
Aligns the code with PIIX3 such that PIIXState can be used in PIIX4,
too.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-Id: <20221022150508.26830-33-shentey@gmail.com>
---
hw/isa/Kconfig | 2 +-
hw/isa/piix4.c | 30 +++++++++++-------------------
hw/mips/Kconfig | 1 +
hw/mips/malta.c | 11 +++++++++--
4 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 8bf6462798..4dfa3310d9 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -48,10 +48,10 @@ config PIIX4
select ACPI_PIIX4
select I8254
select I8257
- select I8259
select IDE_PIIX
select ISA_BUS
select MC146818RTC
+ select PROXY_PIC
select USB_UHCI
config VT82C686
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index dbefcb3ff4..0c34e3717c 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -30,7 +30,7 @@
#include "hw/pci/pci.h"
#include "hw/ide/piix.h"
#include "hw/isa/isa.h"
-#include "hw/intc/i8259.h"
+#include "hw/core/proxy-pic.h"
#include "hw/dma/i8257.h"
#include "hw/timer/i8254.h"
#include "hw/rtc/mc146818rtc.h"
@@ -44,9 +44,8 @@
struct PIIX4State {
PCIDevice dev;
- qemu_irq cpu_intr;
- qemu_irq *isa;
+ ProxyPICState pic;
RTCState rtc;
PCIIDEState ide;
UHCIState uhci;
@@ -82,7 +81,7 @@ static void piix4_set_irq(void *opaque, int irq_num, int
level)
pic_level |= pci_bus_get_irq_level(bus, i);
}
}
- qemu_set_irq(s->isa[pic_irq], pic_level);
+ qemu_set_irq(s->pic.in_irqs[pic_irq], pic_level);
}
}
@@ -174,12 +173,6 @@ static const VMStateDescription vmstate_piix4 = {
}
};
-static void piix4_request_i8259_irq(void *opaque, int irq, int level)
-{
- PIIX4State *s = opaque;
- qemu_set_irq(s->cpu_intr, level);
-}
-
static void piix4_rcr_write(void *opaque, hwaddr addr, uint64_t val,
unsigned int len)
{
@@ -215,7 +208,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
PIIX4State *s = PIIX4_PCI_DEVICE(dev);
PCIBus *pci_bus = pci_get_bus(dev);
ISABus *isa_bus;
- qemu_irq *i8259_out_irq;
isa_bus = isa_bus_new(DEVICE(dev), pci_address_space(dev),
pci_address_space_io(dev), errp);
@@ -223,20 +215,18 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
return;
}
- qdev_init_gpio_out_named(DEVICE(dev), &s->cpu_intr,
- "intr", 1);
-
memory_region_init_io(&s->rcr_mem, OBJECT(dev), &piix4_rcr_ops, s,
"reset-control", 1);
memory_region_add_subregion_overlap(pci_address_space_io(dev),
PIIX_RCR_IOPORT, &s->rcr_mem, 1);
/* initialize i8259 pic */
- i8259_out_irq = qemu_allocate_irqs(piix4_request_i8259_irq, s, 1);
- s->isa = i8259_init(isa_bus, *i8259_out_irq);
+ if (!qdev_realize(DEVICE(&s->pic), NULL, errp)) {
+ return;
+ }
/* initialize ISA irqs */
- isa_bus_irqs(isa_bus, s->isa);
+ isa_bus_irqs(isa_bus, s->pic.in_irqs);
/* initialize pit */
i8254_pit_init(isa_bus, 0x40, 0, NULL);
@@ -249,7 +239,7 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) {
return;
}
- s->rtc.irq = isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq);
+ s->rtc.irq = qdev_get_gpio_in(DEVICE(&s->pic), s->rtc.isairq);
/* IDE */
qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1);
@@ -276,7 +266,8 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
return;
}
- qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
+ qdev_connect_gpio_out(DEVICE(&s->pm), 0,
+ qdev_get_gpio_in(DEVICE(&s->pic), 9));
}
pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
@@ -286,6 +277,7 @@ static void piix4_init(Object *obj)
{
PIIX4State *s = PIIX4_PCI_DEVICE(obj);
+ object_initialize_child(obj, "pic", &s->pic, TYPE_PROXY_PIC);
object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE);
}
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
index 4e7042f03d..d156de812c 100644
--- a/hw/mips/Kconfig
+++ b/hw/mips/Kconfig
@@ -1,5 +1,6 @@
config MALTA
bool
+ select I8259
select ISA_SUPERIO
select PIIX4
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 4d0251ee12..36bdc184f6 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -29,6 +29,7 @@
#include "qemu/guest-random.h"
#include "hw/clock.h"
#include "hw/southbridge/piix.h"
+#include "hw/intc/i8259.h"
#include "hw/isa/superio.h"
#include "hw/char/serial.h"
#include "net/net.h"
@@ -1254,10 +1255,11 @@ void mips_malta_init(MachineState *machine)
PCIBus *pci_bus;
ISABus *isa_bus;
qemu_irq cbus_irq, i8259_irq;
+ qemu_irq *i8259;
I2CBus *smbus;
DriveInfo *dinfo;
int fl_idx = 0;
- int be;
+ int be, i;
MaltaState *s;
PCIDevice *piix4;
DeviceState *dev;
@@ -1432,7 +1434,12 @@ void mips_malta_init(MachineState *machine)
pci_ide_create_devs(PCI_DEVICE(dev));
/* Interrupt controller */
- qdev_connect_gpio_out_named(DEVICE(piix4), "intr", 0, i8259_irq);
+ dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pic"));
+ i8259 = i8259_init(isa_bus, i8259_irq);
+ for (i = 0; i < ISA_NUM_IRQS; i++) {
+ qdev_connect_gpio_out(dev, i, i8259[i]);
+ }
+ g_free(i8259);
/* generate SPD EEPROM data */
dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pm"));
--
2.38.1
- [PATCH 11/32] hw/core: Introduce proxy-pic, (continued)
- [PATCH 11/32] hw/core: Introduce proxy-pic, Bernhard Beschow, 2022/12/04
- [PATCH 13/32] hw/isa/piix3: Create IDE controller in host device, Bernhard Beschow, 2022/12/04
- [PATCH 14/32] hw/isa/piix3: Wire up ACPI interrupt internally, Bernhard Beschow, 2022/12/04
- [PATCH 15/32] hw/isa/piix3: Resolve redundant PIIX_NUM_PIC_IRQS, Bernhard Beschow, 2022/12/04
- [PATCH 16/32] hw/isa/piix3: Rename pci_piix3_props for sharing with PIIX4, Bernhard Beschow, 2022/12/04
- [PATCH 17/32] hw/isa/piix3: Rename piix3_reset() for sharing with PIIX4, Bernhard Beschow, 2022/12/04
- [PATCH 18/32] hw/isa/piix3: Prefix pci_slot_get_pirq() with "piix3_", Bernhard Beschow, 2022/12/04
- [PATCH 12/32] hw/isa/piix3: Create Proxy PIC in host device, Bernhard Beschow, 2022/12/04
- [PATCH 20/32] hw/isa/piix4: Make PIIX4's ACPI and USB functions optional, Bernhard Beschow, 2022/12/04
- [PATCH 21/32] hw/isa/piix4: Remove unused code, Bernhard Beschow, 2022/12/04
- [PATCH 22/32] hw/isa/piix4: Use Proxy PIC device,
Bernhard Beschow <=
- [PATCH 19/32] hw/isa/piix3: Rename typedef PIIX3State to PIIXState, Bernhard Beschow, 2022/12/04
- [PATCH 23/32] hw/isa/piix4: Reuse struct PIIXState from PIIX3, Bernhard Beschow, 2022/12/04
- [PATCH 24/32] hw/isa/piix4: Rename reset control operations to match PIIX3, Bernhard Beschow, 2022/12/04
- [PATCH 25/32] hw/isa/piix4: Prefix pci_slot_get_pirq() with "piix4_", Bernhard Beschow, 2022/12/04
- [PATCH 27/32] hw/isa/piix: Harmonize names of reset control memory regions, Bernhard Beschow, 2022/12/04
- [PATCH 28/32] hw/isa/piix: Reuse PIIX3 base class' realize method in PIIX4, Bernhard Beschow, 2022/12/04
- [PATCH 26/32] hw/isa/piix3: Merge hw/isa/piix4.c, Bernhard Beschow, 2022/12/04
- [PATCH 30/32] hw/isa/piix: Consolidate IRQ triggering, Bernhard Beschow, 2022/12/04
- [PATCH 29/32] hw/isa/piix: Rename functions to be shared for interrupt triggering, Bernhard Beschow, 2022/12/04
- [PATCH 31/32] hw/isa/piix: Share PIIX3 base class with PIIX4, Bernhard Beschow, 2022/12/04