hw/isa/piix4: Decouple INTx-to-LNKx routing which is board-specific
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> Message-Id: <20230109172347.1830-7-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
738c2eb47f
commit
3c73d590e7
@ -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)
|
static void piix4_isa_reset(DeviceState *dev)
|
||||||
{
|
{
|
||||||
PIIX4State *d = PIIX4_PCI_DEVICE(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]);
|
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_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)
|
static void piix4_init(Object *obj)
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "hw/mips/bootloader.h"
|
#include "hw/mips/bootloader.h"
|
||||||
#include "hw/mips/cpudevs.h"
|
#include "hw/mips/cpudevs.h"
|
||||||
#include "hw/pci/pci.h"
|
#include "hw/pci/pci.h"
|
||||||
|
#include "hw/pci/pci_bus.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "hw/mips/bios.h"
|
#include "hw/mips/bios.h"
|
||||||
#include "hw/ide/pci.h"
|
#include "hw/ide/pci.h"
|
||||||
@ -993,6 +994,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)
|
static void main_cpu_reset(void *opaque)
|
||||||
{
|
{
|
||||||
MIPSCPU *cpu = opaque;
|
MIPSCPU *cpu = opaque;
|
||||||
@ -1225,6 +1251,7 @@ void mips_malta_init(MachineState *machine)
|
|||||||
qdev_prop_set_bit(dev, "cpu-little-endian", !be);
|
qdev_prop_set_bit(dev, "cpu-little-endian", !be);
|
||||||
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
||||||
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
|
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
|
||||||
|
pci_bus_map_irqs(pci_bus, malta_pci_slot_get_pirq);
|
||||||
|
|
||||||
/* Southbridge */
|
/* Southbridge */
|
||||||
piix4 = pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, true,
|
piix4 = pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, true,
|
||||||
|
Loading…
Reference in New Issue
Block a user