@@ -1894,6 +1894,9 @@ bool memory_region_present(MemoryRegion *container, hwaddr addr);
*/
bool memory_region_is_mapped(MemoryRegion *mr);
+typedef int (*qemu_flat_walk_cb)(MemoryRegionSection *s, void *handle);
+int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, void *handle);
+
/**
* memory_region_find: translate an address/size relative to a
* MemoryRegion into a #MemoryRegionSection.
@@ -2513,6 +2513,23 @@ bool memory_region_is_mapped(MemoryRegion *mr)
return mr->container ? true : false;
}
+int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, void *handle)
+{
+ FlatView *view = address_space_get_flatview(as);
+ FlatRange *fr;
+ int ret;
+
+ FOR_EACH_FLAT_RANGE(fr, view) {
+ MemoryRegionSection section = section_from_flat_range(fr, view);
+ ret = func(§ion, handle);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
/* Same as memory_region_find, but it does not add a reference to the
* returned region. It must be called from an RCU critical section.
*/
Add an iterator over the sections of a flattened address space. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- include/exec/memory.h | 3 +++ softmmu/memory.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+)