diff mbox

[v4,18/22] memory: Add address_space_find_by_name()

Message ID 1391420690-23745-19-git-send-email-edgar.iglesias@gmail.com
State New
Headers show

Commit Message

Edgar E. Iglesias Feb. 3, 2014, 9:44 a.m. UTC
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 include/exec/memory.h |  9 +++++++++
 memory.c              | 12 ++++++++++++
 translate-all.c       | 10 ++++++++--
 3 files changed, 29 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 9101fc3..8465d5b 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1054,4 +1054,13 @@  void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,
 
 #endif
 
+/**
+ * address_space_find_by_name: Find an AddressSpace * by name
+ *
+ * Returns an AddressSpace * if found.
+ *
+ * @name: name of an address space too look for.
+ */
+AddressSpace *address_space_find_by_name(const char *name);
+
 #endif
diff --git a/memory.c b/memory.c
index 59ecc28..22fbe16 100644
--- a/memory.c
+++ b/memory.c
@@ -1720,6 +1720,18 @@  void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
     memory_region_transaction_commit();
 }
 
+AddressSpace *address_space_find_by_name(const char *name)
+{
+    AddressSpace *as;
+
+    QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
+        if (strcmp(as->name, name) == 0) {
+            return as;
+        }
+    }
+    return NULL;
+}
+
 void address_space_destroy(AddressSpace *as)
 {
     /* Flush out anything from MemoryListeners listening in on this */
diff --git a/translate-all.c b/translate-all.c
index 1ac0246..9950c3b 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -52,9 +52,8 @@ 
 #include <libutil.h>
 #endif
 #endif
-#else
-#include "exec/address-spaces.h"
 #endif
+#include "exec/address-spaces.h"
 
 #include "exec/cputlb.h"
 #include "translate-all.h"
@@ -1565,6 +1564,13 @@  void cpu_interrupt(CPUState *cpu, int mask)
     cpu->tcg_exit_req = 1;
 }
 
+/* Find an address space by name in user emulation.  */
+AddressSpace *address_space_find_by_name(const char *name)
+{
+    /* Unsupported.  */
+    return NULL;
+}
+
 /*
  * Walks guest process memory "regions" one by one
  * and calls callback function 'fn' for each region.