Patchwork [v3,06/16] fulong2e: improve bus implementation of vt82c bridge

login
register
mail settings
Submitter Hervé Poussineau
Date Oct. 2, 2011, 4:10 p.m.
Message ID <1317571828-9059-7-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/117338/
State New
Headers show

Comments

Hervé Poussineau - Oct. 2, 2011, 4:10 p.m.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/mips_fulong2e.c |    9 ++-------
 hw/vt82c686.c      |   31 +++++++++++++++++++++++++++++--
 hw/vt82c686.h      |    2 +-
 3 files changed, 32 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 04921c1..3034a9c 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -262,7 +262,6 @@  static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
     MemoryRegion *bios = g_new(MemoryRegion, 1);
     long bios_size;
     int64_t kernel_entry;
-    qemu_irq *i8259;
     qemu_irq *cpu_exit_irq;
     int via_devfn;
     PCIBus *pci_bus;
@@ -337,17 +336,13 @@  static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
     /* South bridge */
     ide_drive_get(hd, MAX_IDE_BUS);
 
-    via_devfn = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0));
+    via_devfn = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0),
+                               env->irq[5]);
     if (via_devfn < 0) {
         fprintf(stderr, "vt82c686b_init error\n");
         exit(1);
     }
 
-    /* Interrupt controller */
-    /* The 8259 -> IP5  */
-    i8259 = i8259_init(env->irq[5]);
-    isa_bus_irqs(i8259);
-
     vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(FULONG2E_VIA_SLOT, 1));
     usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2));
     usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3));
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 46e85dd..05a70da 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -41,6 +41,8 @@  typedef struct SuperIOConfig
 
 typedef struct VT82C686BState {
     PCIDevice dev;
+    ISABus bus;
+    qemu_irq *pic;
     SuperIOConfig superio_conf;
 } VT82C686BState;
 
@@ -483,14 +485,35 @@  static const VMStateDescription vmstate_via = {
     }
 };
 
+static qemu_irq vt82c_bus_get_irq(ISABus *bus, int isairq)
+{
+    VT82C686BState *vt82c = container_of(bus, VT82C686BState, bus);
+    if (isairq < 0 || isairq >= 16) {
+        hw_error("isa irq %d invalid", isairq);
+    }
+    return vt82c->pic[isairq];
+}
+
+static MemoryRegion *vt82c_bus_get_io_space(ISABus *bus)
+{
+    VT82C686BState *vt82c = container_of(bus, VT82C686BState, bus);
+    return pci_address_space_io(&vt82c->dev);
+}
+
+static ISABusOps vt82c_bus_ops = {
+    .get_irq = vt82c_bus_get_irq,
+    .get_io_space = vt82c_bus_get_io_space,
+};
+
 /* init the PCI-to-ISA bridge */
 static int vt82c686b_initfn(PCIDevice *d)
 {
+    VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d);
     uint8_t *pci_conf;
     uint8_t *wmask;
     int i;
 
-    isa_bus_bridge_init(&d->qdev, pci_address_space_io(d));
+    isa_bus_new(&vt82c->bus, &vt82c_bus_ops, &d->qdev);
 
     pci_conf = d->config;
     pci_config_set_prog_interface(pci_conf, 0x0);
@@ -507,12 +530,16 @@  static int vt82c686b_initfn(PCIDevice *d)
     return 0;
 }
 
-int vt82c686b_init(PCIBus *bus, int devfn)
+int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq)
 {
     PCIDevice *d;
+    VT82C686BState *vt82c;
 
     d = pci_create_simple_multifunction(bus, devfn, true, "VT82C686B");
 
+    vt82c = DO_UPCAST(VT82C686BState, dev, d);
+    vt82c->pic = i8259_init(parent_irq);
+
     return d->devfn;
 }
 
diff --git a/hw/vt82c686.h b/hw/vt82c686.h
index e3270ca..1a026c2 100644
--- a/hw/vt82c686.h
+++ b/hw/vt82c686.h
@@ -2,7 +2,7 @@ 
 #define HW_VT82C686_H
 
 /* vt82c686.c */
-int vt82c686b_init(PCIBus * bus, int devfn);
+int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq);
 void vt82c686b_ac97_init(PCIBus *bus, int devfn);
 void vt82c686b_mc97_init(PCIBus *bus, int devfn);
 i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,