dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0001-malta-Fix-regression-i8259-interrupts-did-not-work.patch

Justin M. Forbes 45e84a
From 0b23c5d40ea933cfece3b4f69427f79c8a23256d Mon Sep 17 00:00:00 2001
Justin M. Forbes 45e84a
From: Stefan Weil <sw@weilnetz.de>
Justin M. Forbes 45e84a
Date: Tue, 29 Nov 2011 06:34:48 +0100
Justin M. Forbes 45e84a
Subject: [PATCH 01/25] malta: Fix regression (i8259 interrupts did not work)
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
Commit 5632ae46d5bda798e971dae48ebb318ac2c3686a passes the address
Justin M. Forbes 45e84a
of i8259 to qemu_irq_proxy. i8259 is an auto variable with undefined
Justin M. Forbes 45e84a
value outside of mips_malta_init.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
This made the interrupt proxy unusable: either QEMU crashes, or
Justin M. Forbes 45e84a
the interrupt handler was not called.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
Ethernet for example no longer worked with MIPS Malta.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
v2:
Justin M. Forbes 45e84a
While v1 used a static variable for i8259, this patch introduces
Justin M. Forbes 45e84a
a qdev for the malta machine. i8259 is now part of the device status.
Justin M. Forbes 45e84a
This is a minimal qdev implementation to keep the patch small.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Justin M. Forbes 45e84a
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Justin M. Forbes 45e84a
(cherry picked from commit e9b40fd34ceb23461083d505a444a389c094455b)
Justin M. Forbes 45e84a
---
Justin M. Forbes 45e84a
 hw/mips_malta.c |   39 +++++++++++++++++++++++++++++++++++----
Justin M. Forbes 45e84a
 1 files changed, 35 insertions(+), 4 deletions(-)
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
Justin M. Forbes 45e84a
index bb49749..941b9bd 100644
Justin M. Forbes 45e84a
--- a/hw/mips_malta.c
Justin M. Forbes 45e84a
+++ b/hw/mips_malta.c
Justin M. Forbes 45e84a
@@ -47,6 +47,7 @@
Justin M. Forbes 45e84a
 #include "mc146818rtc.h"
Justin M. Forbes 45e84a
 #include "blockdev.h"
Justin M. Forbes 45e84a
 #include "exec-memory.h"
Justin M. Forbes 45e84a
+#include "sysbus.h"             /* SysBusDevice */
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
 //#define DEBUG_BOARD_INIT
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
@@ -72,6 +73,11 @@ typedef struct {
Justin M. Forbes 45e84a
     SerialState *uart;
Justin M. Forbes 45e84a
 } MaltaFPGAState;
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
+typedef struct {
Justin M. Forbes 45e84a
+    SysBusDevice busdev;
Justin M. Forbes 45e84a
+    qemu_irq *i8259;
Justin M. Forbes 45e84a
+} MaltaState;
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
 static ISADevice *pit;
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
 static struct _loaderparams {
Justin M. Forbes 45e84a
@@ -775,7 +781,7 @@ void mips_malta_init (ram_addr_t ram_size,
Justin M. Forbes 45e84a
     int64_t kernel_entry;
Justin M. Forbes 45e84a
     PCIBus *pci_bus;
Justin M. Forbes 45e84a
     CPUState *env;
Justin M. Forbes 45e84a
-    qemu_irq *i8259 = NULL, *isa_irq;
Justin M. Forbes 45e84a
+    qemu_irq *isa_irq;
Justin M. Forbes 45e84a
     qemu_irq *cpu_exit_irq;
Justin M. Forbes 45e84a
     int piix4_devfn;
Justin M. Forbes 45e84a
     i2c_bus *smbus;
Justin M. Forbes 45e84a
@@ -787,6 +793,11 @@ void mips_malta_init (ram_addr_t ram_size,
Justin M. Forbes 45e84a
     int fl_sectors = 0;
Justin M. Forbes 45e84a
     int be;
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
+    DeviceState *dev = qdev_create(NULL, "mips-malta");
Justin M. Forbes 45e84a
+    MaltaState *s = DO_UPCAST(MaltaState, busdev.qdev, dev);
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
+    qdev_init_nofail(dev);
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
     /* Make sure the first 3 serial ports are associated with a device. */
Justin M. Forbes 45e84a
     for(i = 0; i < 3; i++) {
Justin M. Forbes 45e84a
         if (!serial_hds[i]) {
Justin M. Forbes 45e84a
@@ -932,7 +943,7 @@ void mips_malta_init (ram_addr_t ram_size,
Justin M. Forbes 45e84a
      * qemu_irq_proxy() adds an extra bit of indirection, allowing us
Justin M. Forbes 45e84a
      * to resolve the isa_irq -> i8259 dependency after i8259 is initialized.
Justin M. Forbes 45e84a
      */
Justin M. Forbes 45e84a
-    isa_irq = qemu_irq_proxy(&i8259, 16);
Justin M. Forbes 45e84a
+    isa_irq = qemu_irq_proxy(&s->i8259, 16);
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
     /* Northbridge */
Justin M. Forbes 45e84a
     pci_bus = gt64120_register(isa_irq);
Justin M. Forbes 45e84a
@@ -944,9 +955,9 @@ void mips_malta_init (ram_addr_t ram_size,
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
     /* Interrupt controller */
Justin M. Forbes 45e84a
     /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
Justin M. Forbes 45e84a
-    i8259 = i8259_init(env->irq[2]);
Justin M. Forbes 45e84a
+    s->i8259 = i8259_init(env->irq[2]);
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
-    isa_bus_irqs(i8259);
Justin M. Forbes 45e84a
+    isa_bus_irqs(s->i8259);
Justin M. Forbes 45e84a
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
Justin M. Forbes 45e84a
     usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
Justin M. Forbes 45e84a
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(9),
Justin M. Forbes 45e84a
@@ -990,6 +1001,20 @@ void mips_malta_init (ram_addr_t ram_size,
Justin M. Forbes 45e84a
     }
Justin M. Forbes 45e84a
 }
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
+static int mips_malta_sysbus_device_init(SysBusDevice *sysbusdev)
Justin M. Forbes 45e84a
+{
Justin M. Forbes 45e84a
+    return 0;
Justin M. Forbes 45e84a
+}
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
+static SysBusDeviceInfo mips_malta_device = {
Justin M. Forbes 45e84a
+    .init = mips_malta_sysbus_device_init,
Justin M. Forbes 45e84a
+    .qdev.name  = "mips-malta",
Justin M. Forbes 45e84a
+    .qdev.size  = sizeof(MaltaState),
Justin M. Forbes 45e84a
+    .qdev.props = (Property[]) {
Justin M. Forbes 45e84a
+        DEFINE_PROP_END_OF_LIST(),
Justin M. Forbes 45e84a
+    }
Justin M. Forbes 45e84a
+};
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
 static QEMUMachine mips_malta_machine = {
Justin M. Forbes 45e84a
     .name = "malta",
Justin M. Forbes 45e84a
     .desc = "MIPS Malta Core LV",
Justin M. Forbes 45e84a
@@ -998,9 +1023,15 @@ static QEMUMachine mips_malta_machine = {
Justin M. Forbes 45e84a
     .is_default = 1,
Justin M. Forbes 45e84a
 };
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
+static void mips_malta_device_init(void)
Justin M. Forbes 45e84a
+{
Justin M. Forbes 45e84a
+    sysbus_register_withprop(&mips_malta_device);
Justin M. Forbes 45e84a
+}
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
 static void mips_malta_machine_init(void)
Justin M. Forbes 45e84a
 {
Justin M. Forbes 45e84a
     qemu_register_machine(&mips_malta_machine);
Justin M. Forbes 45e84a
 }
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
+device_init(mips_malta_device_init);
Justin M. Forbes 45e84a
 machine_init(mips_malta_machine_init);
Justin M. Forbes 45e84a
-- 
Justin M. Forbes 45e84a
1.7.7.5
Justin M. Forbes 45e84a