qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC v1 18/25] sysbus: Rework sysbus_mmio_map to use mr QOM


From: Peter Crosthwaite
Subject: [Qemu-devel] [RFC v1 18/25] sysbus: Rework sysbus_mmio_map to use mr QOMification
Date: Thu, 15 May 2014 19:00:13 -0700

The QOMified MemoryRegion properties "parent", "may-overlap",
"priority" and "addr" now handle all these semantics. Just set them
unconditionally. The Memory API also preserves the fast path API
behaviour implemented where if nothing changes don't bounce the
subregion. So all conditional logic can be removed. This also
allow for removal of the mmio.addr field within SysBus.
Another annoying and redundant piece of SysBus state bites the dust!

Signed-off-by: Peter Crosthwaite <address@hidden>
---

 hw/core/sysbus.c    | 39 +++++++++++++++------------------------
 include/hw/sysbus.h |  1 -
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 2fae2bd..7cdc428 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -47,28 +47,17 @@ void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq 
irq)
 static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
                                    bool may_overlap, int priority)
 {
+    MemoryRegion *mr;
     assert(n >= 0 && n < dev->num_mmio);
 
-    if (dev->mmio[n].addr == addr) {
-        /* ??? region already mapped here.  */
-        return;
-    }
-    if (dev->mmio[n].addr != (hwaddr)-1) {
-        /* Unregister previous mapping.  */
-        memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory);
-    }
-    dev->mmio[n].addr = addr;
-    if (may_overlap) {
-        memory_region_add_subregion_overlap(get_system_memory(),
-                                            addr,
-                                            dev->mmio[n].memory,
-                                            priority);
-    }
-    else {
-        memory_region_add_subregion(get_system_memory(),
-                                    addr,
-                                    dev->mmio[n].memory);
-    }
+    mr = dev->mmio[n].memory;
+
+    object_property_set_link(OBJECT(mr), OBJECT(get_system_memory()),
+                             "container", &error_abort);
+    object_property_set_bool(OBJECT(mr), may_overlap, "may-overlap",
+                             &error_abort);
+    object_property_set_int(OBJECT(mr), priority, "priority", &error_abort);
+    object_property_set_int(OBJECT(mr), addr, "addr", &error_abort);
 }
 
 void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)
@@ -100,7 +89,6 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion 
*memory)
 
     assert(dev->num_mmio < QDEV_MAX_MMIO);
     n = dev->num_mmio++;
-    dev->mmio[n].addr = -1;
     dev->mmio[n].memory = memory;
 }
 
@@ -198,9 +186,11 @@ static void sysbus_dev_print(Monitor *mon, DeviceState 
*dev, int indent)
     int i;
 
     for (i = 0; i < s->num_mmio; i++) {
+        hwaddr addr = object_property_get_int(OBJECT(s->mmio[i].memory),
+                                              "addr", &error_abort);
         size = memory_region_size(s->mmio[i].memory);
         monitor_printf(mon, "%*smmio " TARGET_FMT_plx "/" TARGET_FMT_plx "\n",
-                       indent, "", s->mmio[i].addr, size);
+                       indent, "", addr, size);
     }
 }
 
@@ -213,8 +203,9 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev)
     off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
 
     if (s->num_mmio) {
-        snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx,
-                 s->mmio[0].addr);
+        hwaddr addr = object_property_get_int(OBJECT(s->mmio[0].memory),
+                                              "addr", &error_abort);
+        snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx, addr);
     } else if (s->num_pio) {
         snprintf(path + off, sizeof(path) - off, "@i%04x", s->pio[0]);
     }
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 7ee4a04..4499020 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -50,7 +50,6 @@ struct SysBusDevice {
 
     int num_mmio;
     struct {
-        hwaddr addr;
         MemoryRegion *memory;
     } mmio[QDEV_MAX_MMIO];
     int num_pio;
-- 
1.9.3.1.ga73a6ad




reply via email to

[Prev in Thread] Current Thread [Next in Thread]