Signed-off-by: Hervé Poussineau <hpous...@reactos.org>
---
 hw/isa-bus.c |   24 ++++++++++++++++++++++++
 hw/isa.h     |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 4757ff9..2bc384a 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -20,10 +20,12 @@
 #include "monitor.h"
 #include "sysbus.h"
 #include "isa.h"
+#include "exec-memory.h"
 
 static ISABus *isabus;
 target_phys_addr_t isa_mem_base = 0;
 static qemu_irq *isa_bus_default_irqs;
+static MemoryRegion *isa_bus_default_mem;
 
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 static char *isabus_get_fw_dev_path(DeviceState *dev);
@@ -48,9 +50,23 @@ static qemu_irq isa_bus_default_get_irq(ISABus *bus, int 
isairq)
     return isa_bus_default_irqs[isairq];
 }
 
+static MemoryRegion *isa_bus_default_get_address_space(ISABus *bus)
+{
+    if (!isa_bus_default_mem) {
+        /* First call to this method, initialize memory region */
+        isa_bus_default_mem = (MemoryRegion 
*)qemu_malloc(sizeof(MemoryRegion));
+        memory_region_init(isa_bus_default_mem, "isa-memory", 0x00100000);
+        memory_region_add_subregion(get_system_memory(),
+                                    isa_mem_base,
+                                    isa_bus_default_mem);
+    }
+    return isa_bus_default_mem;
+}
+
 static ISABusOps isa_bus_default_ops = {
     .set_irqs = isa_bus_default_set_irqs,
     .get_irq = isa_bus_default_get_irq,
+    .get_address_space = isa_bus_default_get_address_space,
 };
 
 ISABus *isa_bus_bridge_init(DeviceState *dev)
@@ -102,6 +118,14 @@ qemu_irq isa_get_irq(int isairq)
     return isabus->ops->get_irq(isabus, isairq);
 }
 
+MemoryRegion *isa_address_space(void)
+{
+    if (!isabus || !isabus->ops->get_address_space) {
+        hw_error("Tried to get isa address space with no isa bus present.");
+    }
+    return isabus->ops->get_address_space(isabus);
+}
+
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
 {
     assert(dev->nirqs < ARRAY_SIZE(dev->isairq));
diff --git a/hw/isa.h b/hw/isa.h
index 8c1583f..19c4720 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -36,6 +36,7 @@ struct ISABus {
 struct ISABusOps {
     void (*set_irqs)(ISABus *bus, qemu_irq *irqs);
     qemu_irq (*get_irq)(ISABus *bus, int isairq);
+    MemoryRegion *(*get_address_space)(ISABus *bus);
 };
 
 ISABus *isa_bus_bridge_init(DeviceState *dev);
@@ -43,6 +44,7 @@ ISABus *isa_bus_bridge_init(DeviceState *dev);
 void isa_bus_new(ISABus *bus, ISABusOps *ops, DeviceState *host);
 void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_get_irq(int isairq);
+MemoryRegion *isa_address_space(void);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
 void isa_init_ioport(ISADevice *dev, uint16_t ioport);
 void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
-- 
1.7.5.4


Reply via email to