diff mbox series

[v3,01/16] memory: Add FlatView foreach function

Message ID 20200921022506.873303-2-alxndr@bu.edu
State New
Headers show
Series Add a General Virtual Device Fuzzer | expand

Commit Message

Alexander Bulekov Sept. 21, 2020, 2:24 a.m. UTC
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
---
 include/exec/memory.h | 5 +++++
 softmmu/memory.c      | 9 +++++++++
 2 files changed, 14 insertions(+)

Comments

Paolo Bonzini Oct. 8, 2020, 6:57 a.m. UTC | #1
On 21/09/20 04:24, Alexander Bulekov wrote:
> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>

> ---

>  include/exec/memory.h | 5 +++++

>  softmmu/memory.c      | 9 +++++++++

>  2 files changed, 14 insertions(+)

> 

> diff --git a/include/exec/memory.h b/include/exec/memory.h

> index f1bb2a7df5..975a90c871 100644

> --- a/include/exec/memory.h

> +++ b/include/exec/memory.h

> @@ -688,6 +688,11 @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)

>      return atomic_rcu_read(&as->current_map);

>  }

>  

> +typedef int (*flatview_cb)(ram_addr_t start,

> +                           ram_addr_t len,

> +                           const MemoryRegion*, void*);

> +

> +void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque);

>  

>  /**

>   * MemoryRegionSection: describes a fragment of a #MemoryRegion

> diff --git a/softmmu/memory.c b/softmmu/memory.c

> index d030eb6f7c..9db5fbe43a 100644

> --- a/softmmu/memory.c

> +++ b/softmmu/memory.c

> @@ -655,6 +655,15 @@ static void render_memory_region(FlatView *view,

>      }

>  }

>  

> +void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque)

> +{

> +    FlatRange *fr;

> +    FOR_EACH_FLAT_RANGE(fr, fv) {

> +        if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque))

> +            break;

> +    }

> +}


Acked-by: Paolo Bonzini <pbonzini@redhat.com>


>  static MemoryRegion *memory_region_get_flatview_root(MemoryRegion *mr)

>  {

>      while (mr->enabled) {

>
diff mbox series

Patch

diff --git a/include/exec/memory.h b/include/exec/memory.h
index f1bb2a7df5..975a90c871 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -688,6 +688,11 @@  static inline FlatView *address_space_to_flatview(AddressSpace *as)
     return atomic_rcu_read(&as->current_map);
 }
 
+typedef int (*flatview_cb)(ram_addr_t start,
+                           ram_addr_t len,
+                           const MemoryRegion*, void*);
+
+void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque);
 
 /**
  * MemoryRegionSection: describes a fragment of a #MemoryRegion
diff --git a/softmmu/memory.c b/softmmu/memory.c
index d030eb6f7c..9db5fbe43a 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -655,6 +655,15 @@  static void render_memory_region(FlatView *view,
     }
 }
 
+void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque)
+{
+    FlatRange *fr;
+    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) {