diff mbox

[11/12] hw/sysbus: Add sysbus_mmio_unmap() for unmapping a region

Message ID 1310741906-1606-12-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell July 15, 2011, 2:58 p.m. UTC
From: Juha Riihimäki <juha.riihimaki@nokia.com>

Add support for unmapping a SysBus device's mmio region, via a new
function sysbus_mmio_unmap(). This simply reverses the effect of
sysbus_mmio_map().

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/sysbus.c |   17 +++++++++++++++++
 hw/sysbus.h |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/hw/sysbus.c b/hw/sysbus.c
index 2e22be7..021c653 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -39,6 +39,23 @@  void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
     }
 }
 
+void sysbus_mmio_unmap(SysBusDevice *dev, int n)
+{
+    assert(n >= 0 && n < dev->num_mmio);
+
+    if (dev->mmio[n].addr == (target_phys_addr_t)-1) {
+        /* region already unmapped */
+        return;
+    }
+    if (dev->mmio[n].cb) {
+        dev->mmio[n].cb(dev, (target_phys_addr_t)-1);
+    } else {
+        cpu_register_physical_memory(dev->mmio[n].addr, dev->mmio[n].size,
+                                     IO_MEM_UNASSIGNED);
+    }
+    dev->mmio[n].addr = (target_phys_addr_t)-1;
+}
+
 void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr)
 {
     assert(n >= 0 && n < dev->num_mmio);
diff --git a/hw/sysbus.h b/hw/sysbus.h
index 4e8cb16..4f93b70 100644
--- a/hw/sysbus.h
+++ b/hw/sysbus.h
@@ -53,6 +53,7 @@  void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
 
 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
 void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
+void sysbus_mmio_unmap(SysBusDevice *dev, int n);
 
 /* Legacy helper function for creating devices.  */
 DeviceState *sysbus_create_varargs(const char *name,