[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 06/33] hw/isa/piix4: Decouple INTx-to-LNKx routing which is bo
From: |
Bernhard Beschow |
Subject: |
[PATCH v6 06/33] hw/isa/piix4: Decouple INTx-to-LNKx routing which is board-specific |
Date: |
Mon, 9 Jan 2023 18:23:19 +0100 |
pci_map_irq_fn's in general seem to be board-specific, and PIIX4's
pci_slot_get_pirq() in particular seems very Malta-specific. So move the
latter to malta.c to 1/ keep the board logic in one place and 2/ avoid
PIIX4 to make assumptions about its board.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/isa/piix4.c | 26 --------------------------
hw/mips/malta.c | 27 +++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 9c79c9677b..6e9434129d 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -79,31 +79,6 @@ static void piix4_set_irq(void *opaque, int irq_num, int
level)
}
}
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
-{
- int slot;
-
- slot = PCI_SLOT(pci_dev->devfn);
-
- switch (slot) {
- /* PIIX4 USB */
- case 10:
- return 3;
- /* AMD 79C973 Ethernet */
- case 11:
- return 1;
- /* Crystal 4281 Sound */
- case 12:
- return 2;
- /* PCI slot 1 to 4 */
- case 18 ... 21:
- return ((slot - 18) + irq_num) & 0x03;
- /* Unknown device, don't do any translation */
- default:
- return irq_num;
- }
-}
-
static void piix4_isa_reset(DeviceState *dev)
{
PIIX4State *d = PIIX4_PCI_DEVICE(dev);
@@ -272,7 +247,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS);
- pci_bus_map_irqs(pci_bus, pci_slot_get_pirq);
}
static void piix4_init(Object *obj)
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index c3dcd43f37..94d4c49bf5 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -39,6 +39,7 @@
#include "hw/mips/bootloader.h"
#include "hw/mips/cpudevs.h"
#include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
#include "qemu/log.h"
#include "hw/mips/bios.h"
#include "hw/ide/pci.h"
@@ -1161,6 +1162,31 @@ static void malta_mips_config(MIPSCPU *cpu)
}
}
+static int malta_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+{
+ int slot;
+
+ slot = PCI_SLOT(pci_dev->devfn);
+
+ switch (slot) {
+ /* PIIX4 USB */
+ case 10:
+ return 3;
+ /* AMD 79C973 Ethernet */
+ case 11:
+ return 1;
+ /* Crystal 4281 Sound */
+ case 12:
+ return 2;
+ /* PCI slot 1 to 4 */
+ case 18 ... 21:
+ return ((slot - 18) + irq_num) & 0x03;
+ /* Unknown device, don't do any translation */
+ default:
+ return irq_num;
+ }
+}
+
static void main_cpu_reset(void *opaque)
{
MIPSCPU *cpu = opaque;
@@ -1414,6 +1440,7 @@ void mips_malta_init(MachineState *machine)
/* Northbridge */
dev = sysbus_create_simple("gt64120", -1, NULL);
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
+ pci_bus_map_irqs(pci_bus, malta_pci_slot_get_pirq);
/*
* The whole address space decoded by the GT-64120A doesn't generate
* exception when accessing invalid memory. Create an empty slot to
--
2.39.0
- [PATCH v6 00/33] Consolidate PIIX south bridges, Bernhard Beschow, 2023/01/09
- [PATCH v6 01/33] hw/mips/malta: Introduce PIIX4_PCI_DEVFN definition, Bernhard Beschow, 2023/01/09
- [PATCH v6 03/33] hw/isa/piix4: Correct IRQRC[A:D] reset values, Bernhard Beschow, 2023/01/09
- [PATCH v6 02/33] hw/mips/malta: Set PIIX4 IRQ routes in embedded bootloader, Bernhard Beschow, 2023/01/09
- [PATCH v6 04/33] hw/pci/pci: Factor out pci_bus_map_irqs() from pci_bus_irqs(), Bernhard Beschow, 2023/01/09
- [PATCH v6 05/33] hw/isa/piix3: Decouple INTx-to-LNKx routing which is board-specific, Bernhard Beschow, 2023/01/09
- [PATCH v6 06/33] hw/isa/piix4: Decouple INTx-to-LNKx routing which is board-specific,
Bernhard Beschow <=
- [PATCH v6 07/33] hw/mips/Kconfig: Track Malta's PIIX dependencies via Kconfig, Bernhard Beschow, 2023/01/09
- [PATCH v6 08/33] hw/usb/hcd-uhci: Introduce TYPE_ defines for device models, Bernhard Beschow, 2023/01/09
- [PATCH v6 10/33] hw/intc/i8259: Introduce i8259 proxy TYPE_ISA_PIC, Bernhard Beschow, 2023/01/09
- [PATCH v6 09/33] hw/intc/i8259: Make using the isa_pic singleton more type-safe, Bernhard Beschow, 2023/01/09
- [PATCH v6 11/33] hw/i386/pc: Create RTC controllers in south bridges, Bernhard Beschow, 2023/01/09
- [PATCH v6 12/33] hw/i386/pc: No need for rtc_state to be an out-parameter, Bernhard Beschow, 2023/01/09
- [PATCH v6 17/33] hw/isa/piix3: Create IDE controller in host device, Bernhard Beschow, 2023/01/09
- [PATCH v6 14/33] hw/isa/piix3: Create USB controller in host device, Bernhard Beschow, 2023/01/09