diff mbox

[RFC,2/8,v3] Add API to check whether a physical address is I/O address

Message ID 4EF050B0.6070104@cn.fujitsu.com
State New
Headers show

Commit Message

Wen Congyang Dec. 20, 2011, 9:09 a.m. UTC
This API will be used in the following patch.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 cpu-common.h |    1 +
 exec.c       |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/cpu-common.h b/cpu-common.h
index 8295e4f..75c01c3 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -91,6 +91,7 @@  struct CPUPhysMemoryClient {
     QLIST_ENTRY(CPUPhysMemoryClient) list;
 };
 
+bool is_io_addr(target_phys_addr_t phys_addr);
 void cpu_register_phys_memory_client(CPUPhysMemoryClient *);
 void cpu_unregister_phys_memory_client(CPUPhysMemoryClient *);
 
diff --git a/exec.c b/exec.c
index 32782b4..cf0ae8b 100644
--- a/exec.c
+++ b/exec.c
@@ -4853,3 +4853,23 @@  void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
 #undef env
 
 #endif
+
+bool is_io_addr(target_phys_addr_t phys_addr)
+{
+    ram_addr_t pd;
+    PhysPageDesc *p;
+
+    p = phys_page_find(phys_addr >> TARGET_PAGE_BITS);
+    if (!p) {
+        pd = IO_MEM_UNASSIGNED;
+    } else {
+        pd = p->phys_offset;
+    }
+
+    if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) {
+        /* I/O region */
+        return true;
+    }
+
+    return false;
+}