Patchwork [v3,07/16] sun4u: improve bus implementation of EBus bridge

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

Comments

Hervé Poussineau - Oct. 2, 2011, 4:10 p.m.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/sun4u.c |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/sun4u.c b/hw/sun4u.c
index cdf15ff..d8b8054 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -38,6 +38,7 @@ 
 #include "loader.h"
 #include "elf.h"
 #include "blockdev.h"
+#include "exec-memory.h"
 
 //#define DEBUG_IRQ
 //#define DEBUG_EBUS
@@ -93,6 +94,8 @@  struct hwdef {
 
 typedef struct EbusState {
     PCIDevice pci_dev;
+    ISABus bus;
+    qemu_irq *isa_irq;
     MemoryRegion bar0;
     MemoryRegion bar1;
 } EbusState;
@@ -536,20 +539,42 @@  static void dummy_isa_irq_handler(void *opaque, int n, int level)
 static void
 pci_ebus_init(PCIBus *bus, int devfn)
 {
-    qemu_irq *isa_irq;
-
     pci_create_simple(bus, devfn, "ebus");
-    isa_irq = qemu_allocate_irqs(dummy_isa_irq_handler, NULL, 16);
-    isa_bus_irqs(isa_irq);
 }
 
+static qemu_irq pci_ebus_get_irq(ISABus *bus, int isairq)
+{
+    EbusState *s = container_of(bus, EbusState, bus);
+    if (isairq < 0 || isairq >= 16) {
+        hw_error("isa irq %d invalid", isairq);
+    }
+    return s->isa_irq[isairq];
+}
+
+static MemoryRegion *pci_ebus_get_io_space(ISABus *bus)
+{
+    EbusState *s = container_of(bus, EbusState, bus);
+    return pci_address_space_io(&s->pci_dev);
+}
+
+static MemoryRegion *pci_ebus_get_memory_space(ISABus *bus)
+{
+    return get_system_memory();
+}
+
+static ISABusOps pci_ebus_ops = {
+    .get_irq = pci_ebus_get_irq,
+    .get_io_space = pci_ebus_get_io_space,
+    .get_memory_space = pci_ebus_get_memory_space,
+};
+
 static int
 pci_ebus_init1(PCIDevice *pci_dev)
 {
     EbusState *s = DO_UPCAST(EbusState, pci_dev, pci_dev);
 
-    isa_bus_bridge_init(&pci_dev->qdev, pci_address_space_io(pci_dev));
-
+    isa_bus_new(&s->bus, &pci_ebus_ops, &pci_dev->qdev);
+    s->isa_irq = qemu_allocate_irqs(dummy_isa_irq_handler, NULL, 16);
     pci_dev->config[0x04] = 0x06; // command = bus master, pci mem
     pci_dev->config[0x05] = 0x00;
     pci_dev->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error