]> git.proxmox.com Git - mirror_qemu.git/commitdiff
memory: Add FlatView foreach function
authorAlexander Bulekov <alxndr@bu.edu>
Fri, 23 Oct 2020 15:07:30 +0000 (11:07 -0400)
committerThomas Huth <thuth@redhat.com>
Sat, 24 Oct 2020 05:43:48 +0000 (07:43 +0200)
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20201023150746.107063-2-alxndr@bu.edu>
Signed-off-by: Thomas Huth <thuth@redhat.com>
include/exec/memory.h
softmmu/memory.c

index 622207bde12b5da4edffbfdce6cd0e19a87fc56c..042918dd16f92f0e47f9deb0f67d2f39988e0e98 100644 (file)
@@ -719,6 +719,11 @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
     return qatomic_rcu_read(&as->current_map);
 }
 
+typedef int (*flatview_cb)(Int128 start,
+                           Int128 len,
+                           const MemoryRegion*, void*);
+
+void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque);
 
 /**
  * struct MemoryRegionSection: describes a fragment of a #MemoryRegion
index 403ff3abc99b781cf5366646ff794703229abc43..a5d1641820d091a2aed405c783b3a276e6d19c35 100644 (file)
@@ -656,6 +656,19 @@ static void render_memory_region(FlatView *view,
     }
 }
 
+void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque)
+{
+    FlatRange *fr;
+
+    assert(fv);
+    assert(cb);
+
+    FOR_EACH_FLAT_RANGE(fr, fv) {
+        if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque))
+            break;
+    }
+}
+
 static MemoryRegion *memory_region_get_flatview_root(MemoryRegion *mr)
 {
     while (mr->enabled) {