[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 13/30] hw/isa/piix3: Create Proxy PIC in host device
From: |
Bernhard Beschow |
Subject: |
[PATCH v4 13/30] hw/isa/piix3: Create Proxy PIC in host device |
Date: |
Wed, 21 Dec 2022 17:59:46 +0100 |
Use the newly introduced TYPE_PROXY_PIC which allows for wiring
up devices in the southbridge where the virtualization technology used
(KVM, TCG, Xen) is not yet known.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20221022150508.26830-16-shentey@gmail.com>
---
hw/i386/Kconfig | 1 +
hw/i386/pc_piix.c | 15 +++++++++------
hw/isa/Kconfig | 1 +
hw/isa/piix3.c | 10 +++++++++-
include/hw/southbridge/piix.h | 4 ++--
5 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index d22ac4a4b9..79f5925dbe 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -72,6 +72,7 @@ config I440FX
select PC_PCI
select PC_ACPI
select ACPI_SMBUS
+ select I8259
select PCI_I440FX
select PIIX3
select IDE_PIIX
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 10f2db6f2d..e33406a2e3 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -219,10 +219,11 @@ static void pc_init1(MachineState *machine,
gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
if (pcmc->pci_enabled) {
- PIIX3State *piix3;
+ DeviceState *dev;
PCIDevice *pci_dev;
const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
: TYPE_PIIX3_DEVICE;
+ int i;
pci_bus = i440fx_init(pci_type,
i440fx_host,
@@ -247,10 +248,12 @@ static void pc_init1(MachineState *machine,
&error_abort);
pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);
- piix3 = PIIX3_PCI_DEVICE(pci_dev);
- piix3->pic = x86ms->gsi;
- piix3_devfn = piix3->dev.devfn;
- isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
+ dev = DEVICE(object_resolve_path_component(OBJECT(pci_dev), "pic"));
+ for (i = 0; i < ISA_NUM_IRQS; i++) {
+ qdev_connect_gpio_out(dev, i, x86ms->gsi[i]);
+ }
+ piix3_devfn = pci_dev->devfn;
+ isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0"));
rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
"rtc"));
piix4_pm = object_resolve_path_component(OBJECT(pci_dev), "pm");
@@ -259,6 +262,7 @@ static void pc_init1(MachineState *machine,
piix4_pm = NULL;
isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
&error_abort);
+ isa_bus_irqs(isa_bus, x86ms->gsi);
rtc_state = isa_new(TYPE_MC146818_RTC);
qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000);
@@ -267,7 +271,6 @@ static void pc_init1(MachineState *machine,
i8257_dma_init(isa_bus, 0);
pcms->hpet_enabled = false;
}
- isa_bus_irqs(isa_bus, x86ms->gsi);
if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 6c154d88c7..b4ad1fb66e 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -37,6 +37,7 @@ config PIIX3
select I8257
select ISA_BUS
select MC146818RTC
+ select PROXY_PIC
select USB_UHCI
config PIIX4
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index ed7d58bc98..9e9155cbda 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -39,7 +39,7 @@
static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
{
- qemu_set_irq(piix3->pic[pic_irq],
+ qemu_set_irq(piix3->pic.in_irqs[pic_irq],
!!(piix3->pic_levels &
(((1ULL << PIIX_NUM_PIRQS) - 1) <<
(pic_irq * PIIX_NUM_PIRQS))));
@@ -297,6 +297,13 @@ static void pci_piix3_realize(PCIDevice *dev, Error **errp)
return;
}
+ /* PIC */
+ if (!qdev_realize(DEVICE(&d->pic), NULL, errp)) {
+ return;
+ }
+
+ isa_bus_irqs(isa_bus, d->pic.in_irqs);
+
memory_region_init_io(&d->rcr_mem, OBJECT(dev), &rcr_ops, d,
"piix3-reset-control", 1);
memory_region_add_subregion_overlap(pci_address_space_io(dev),
@@ -360,6 +367,7 @@ static void pci_piix3_init(Object *obj)
{
PIIX3State *d = PIIX3_PCI_DEVICE(obj);
+ object_initialize_child(obj, "pic", &d->pic, TYPE_PROXY_PIC);
object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC);
}
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index 1c291cc954..7b1b4625a3 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -15,6 +15,7 @@
#include "hw/pci/pci.h"
#include "qom/object.h"
#include "hw/acpi/piix4.h"
+#include "hw/core/proxy-pic.h"
#include "hw/rtc/mc146818rtc.h"
#include "hw/usb/hcd-uhci.h"
@@ -50,11 +51,10 @@ struct PIIXState {
#endif
uint64_t pic_levels;
- qemu_irq *pic;
-
/* This member isn't used. Just for save/load compatibility */
int32_t pci_irq_levels_vmstate[PIIX_NUM_PIRQS];
+ ProxyPICState pic;
RTCState rtc;
UHCIState uhci;
PIIX4PMState pm;
--
2.39.0
- [PATCH v4 00/30] This series consolidates the implementations of the PIIX3 and PIIX4 south, Bernhard Beschow, 2022/12/21
- [PATCH v4 02/30] hw/mips/malta: Set PIIX4 IRQ routes in embedded bootloader, Bernhard Beschow, 2022/12/21
- [PATCH v4 01/30] hw/mips/malta: Introduce PIIX4_PCI_DEVFN definition, Bernhard Beschow, 2022/12/21
- [PATCH v4 04/30] hw/mips/Kconfig: Track Malta's PIIX dependencies via Kconfig, Bernhard Beschow, 2022/12/21
- [PATCH v4 07/30] hw/i386/pc_piix: Allow for setting properties before realizing PIIX3 south bridge, Bernhard Beschow, 2022/12/21
- [PATCH v4 06/30] hw/i386/pc_piix: Associate pci_map_irq_fn as soon as PCI bus is created, Bernhard Beschow, 2022/12/21
- [PATCH v4 05/30] hw/usb/hcd-uhci: Introduce TYPE_ defines for device models, Bernhard Beschow, 2022/12/21
- [PATCH v4 08/30] hw/i386/pc: Create RTC controllers in south bridges, Bernhard Beschow, 2022/12/21
- [PATCH v4 13/30] hw/isa/piix3: Create Proxy PIC in host device,
Bernhard Beschow <=
- [PATCH v4 10/30] hw/isa/piix3: Create USB controller in host device, Bernhard Beschow, 2022/12/21
- [PATCH v4 18/30] hw/isa/piix3: Rename piix3_reset() for sharing with PIIX4, Bernhard Beschow, 2022/12/21
- [PATCH v4 09/30] hw/i386/pc: No need for rtc_state to be an out-parameter, Bernhard Beschow, 2022/12/21
- [PATCH v4 14/30] hw/isa/piix3: Create IDE controller in host device, Bernhard Beschow, 2022/12/21
- [PATCH v4 22/30] hw/isa/piix4: Use Proxy PIC device, Bernhard Beschow, 2022/12/21
- [PATCH v4 03/30] hw/isa/piix4: Correct IRQRC[A:D] reset values, Bernhard Beschow, 2022/12/21
- [PATCH v4 11/30] hw/isa/piix3: Create power management controller in host device, Bernhard Beschow, 2022/12/21
- [PATCH v4 19/30] hw/isa/piix3: Drop the "3" from PIIX base class, Bernhard Beschow, 2022/12/21
- [PATCH v4 15/30] hw/isa/piix3: Wire up ACPI interrupt internally, Bernhard Beschow, 2022/12/21
- [PATCH v4 23/30] hw/isa/piix4: Reuse struct PIIXState from PIIX3, Bernhard Beschow, 2022/12/21