[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 03/20] piix4: Add a i8259 Interrupt Controller as specified in datasheet
Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> 于2019年10月18日周五 下午9:52写道: From: Hervé Poussineau <hpoussin@xxxxxxxxxxx> Does the piix4 hardware has the GPIO for interrupt? Seems not. memory_region_init_io(&s->rcr_mem, OBJECT(dev), &piix4_rcr_ops, s, In i8259_init, we also allocate 16 input line and 1 output line. Seems it is duplicated with the GPIO allocation in previous. Also Maybe here can uses i8259(isa_bus, qemu_allocate_irq(piix4_request_i8259_irq, s, 0)); + Also here s->i8259 and the piix4 isa point to the same input line. Seems duplicated. I have come up with a more cleaner patch as following: Though 'i8259_init' is called in the mips_malta_init. But is uses the isa bus from piix4 device. And seems it's more clean. You can test it with more tests. Thanks, Li Qiang Author: Li Qiang <liq3ea@xxxxxxx> Date: Mon Oct 21 22:41:17 2019 +0800 piix4 diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index d0b18e0586..66a041040a 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -24,6 +24,7 @@ */ #include "qemu/osdep.h" +#include "hw/irq.h" #include "hw/i386/pc.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" @@ -46,6 +47,7 @@ typedef struct PIIX4State { #define PIIX4_PCI_DEVICE(obj) \ OBJECT_CHECK(PIIX4State, (obj), TYPE_PIIX4_PCI_DEVICE) + static void piix4_isa_reset(DeviceState *dev) { PIIX4State *d = PIIX4_PCI_DEVICE(dev); @@ -141,14 +143,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp) piix4_dev = dev; } -int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn) -{ - PCIDevice *d; - - d = pci_create_simple_multifunction(bus, devfn, true, "PIIX4"); - *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0")); - return d->devfn; -} static void piix4_class_init(ObjectClass *klass, void *data) { diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 4d9c64b36a..420e0e9e80 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -28,6 +28,7 @@ #include "cpu.h" #include "hw/i386/pc.h" #include "hw/isa/superio.h" +//#include "hw/isa/piix4.h" #include "hw/dma/i8257.h" #include "hw/char/serial.h" #include "net/net.h" @@ -97,7 +98,7 @@ typedef struct { SysBusDevice parent_obj; MIPSCPSState cps; - qemu_irq *i8259; + qemu_irq i8259[ISA_NUM_IRQS]; } MaltaState; static ISADevice *pit; @@ -1235,8 +1236,9 @@ void mips_malta_init(MachineState *machine) int64_t kernel_entry, bootloader_run_addr; PCIBus *pci_bus; ISABus *isa_bus; - qemu_irq *isa_irq; qemu_irq cbus_irq, i8259_irq; + qemu_irq *i8259; + PCIDevice *pci; int piix4_devfn; I2CBus *smbus; DriveInfo *dinfo; @@ -1407,29 +1409,24 @@ void mips_malta_init(MachineState *machine) /* Board ID = 0x420 (Malta Board with CoreLV) */ stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); - /* - * We have a circular dependency problem: pci_bus depends on isa_irq, - * isa_irq is provided by i8259, i8259 depends on ISA, ISA depends - * on piix4, and piix4 depends on pci_bus. To stop the cycle we have - * qemu_irq_proxy() adds an extra bit of indirection, allowing us - * to resolve the isa_irq -> i8259 dependency after i8259 is initialized. - */ - isa_irq = qemu_irq_proxy(&s->i8259, 16); - /* Northbridge */ - pci_bus = gt64120_register(isa_irq); + pci_bus = gt64120_register(s->i8259); /* Southbridge */ ide_drive_get(hd, ARRAY_SIZE(hd)); - piix4_devfn = piix4_init(pci_bus, &isa_bus, 80); + pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0), + true, "PIIX4"); + dev = DEVICE(pci); + isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0")); + piix4_devfn = pci->devfn; - /* - * Interrupt controller - * The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 - */ - s->i8259 = i8259_init(isa_bus, i8259_irq); + i8259 = i8259_init(isa_bus, i8259_irq); + for (int i = 0; i < ISA_NUM_IRQS; i++) { + s->i8259[i] = i8259[i]; + } + g_free(i8259); isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); - isa_bus_irqs(isa_bus, s->i8259); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |