exec/ram_addr.h: New header to match upstream.

This moves some ram_addr_t declarations to a new header to match
upstream. Later patches will modify the code itself.

Change-Id: Iff9936c97c5d4fba51b645c6d533958e621f14f4
diff --git a/arch_init.c b/arch_init.c
index 7ed8a8b..16d6690 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -41,6 +41,7 @@
 #include "migration/qemu-file.h"
 #include "net/net.h"
 #include "exec/gdbstub.h"
+#include "exec/ram_addr.h"
 #include "hw/i386/smbios.h"
 
 #ifdef TARGET_SPARC
diff --git a/cputlb.c b/cputlb.c
index 84e382d..c721f58 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -21,6 +21,7 @@
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "exec/cputlb.h"
+#include "exec/ram_addr.h"
 
 /* statistics */
 int tlb_flush_count;
diff --git a/exec.c b/exec.c
index b0ec6e2..4818eaf 100644
--- a/exec.c
+++ b/exec.c
@@ -44,6 +44,7 @@
 #include "sysemu/kvm.h"
 #include "exec/cputlb.h"
 #include "exec/hax.h"
+#include "exec/ram_addr.h"
 #include "qemu/timer.h"
 #if defined(CONFIG_USER_ONLY)
 #include <qemu.h>
diff --git a/hw/android/android_arm.c b/hw/android/android_arm.c
index 52ad2ab..1bc2456 100644
--- a/hw/android/android_arm.c
+++ b/hw/android/android_arm.c
@@ -19,6 +19,7 @@
 #include "android/globals.h"
 #include "audio/audio.h"
 #include "hw/arm/arm.h"
+#include "exec/ram_addr.h"
 #include "ui/console.h"
 #include "sysemu/blockdev.h"
 #include "hw/android/goldfish/pipe.h"
diff --git a/hw/android/android_mips.c b/hw/android/android_mips.c
index c6725c4..03c93e8 100644
--- a/hw/android/android_mips.c
+++ b/hw/android/android_mips.c
@@ -20,6 +20,7 @@
 #include "hw/android/goldfish/pipe.h"
 #include "android/globals.h"
 #include "audio/audio.h"
+#include "exec/ram_addr.h"
 #include "sysemu/blockdev.h"
 
 #include "android/utils/debug.h"
diff --git a/hw/android/goldfish/fb.c b/hw/android/goldfish/fb.c
index d6eba54..5fb3215 100644
--- a/hw/android/goldfish/fb.c
+++ b/hw/android/goldfish/fb.c
@@ -14,6 +14,7 @@
 #include "android/android.h"
 #include "android/utils/debug.h"
 #include "android/utils/duff.h"
+#include "exec/ram_addr.h"
 #include "hw/android/goldfish/device.h"
 #include "hw/hw.h"
 #include "ui/console.h"
diff --git a/hw/android/goldfish/pipe.c b/hw/android/goldfish/pipe.c
index 574516c..642d9f5 100644
--- a/hw/android/goldfish/pipe.c
+++ b/hw/android/goldfish/pipe.c
@@ -14,6 +14,7 @@
 #include "hw/android/goldfish/pipe.h"
 #include "hw/android/goldfish/device.h"
 #include "hw/android/goldfish/vmem.h"
+#include "exec/ram_addr.h"
 #include "qemu/timer.h"
 
 #define  DEBUG 0
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index efee5b6..8a0cc02 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -9,6 +9,7 @@
 
 #include "hw/sysbus.h"
 #include "hw/arm/arm.h"
+#include "exec/ram_addr.h"
 #include "sysemu/sysemu.h"
 
 /* Bitbanded IO.  Each word corresponds to a single bit.  */
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f7f84ad..70a5303 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -25,6 +25,7 @@
 #include "hw/i386/pc.h"
 #include "hw/loader.h"
 #include "hw/pci/pci.h"
+#include "exec/ram_addr.h"
 #include "block/block.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/blockdev.h"
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 48e3354..cd04011 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -498,60 +498,8 @@
 #define CODE_DIRTY_FLAG      0x02
 #define MIGRATION_DIRTY_FLAG 0x08
 
-/* read dirty bit (return 0 or 1) */
-static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
-}
-
-static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
-}
-
-static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
-                                                int dirty_flags)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
-}
-
-static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
-{
-    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
-}
-
-static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
-                                                      int dirty_flags)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
-}
-
-static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
-                                                        int length,
-                                                        int dirty_flags)
-{
-    int i, mask, len;
-    uint8_t *p;
-
-    len = length >> TARGET_PAGE_BITS;
-    mask = ~dirty_flags;
-    p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
-    for (i = 0; i < len; i++) {
-        p[i] &= mask;
-    }
-}
-
-void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
-                                     int dirty_flags);
 void cpu_tlb_update_dirty(CPUArchState *env);
 
-int cpu_physical_memory_set_dirty_tracking(int enable);
-
-int cpu_physical_memory_get_dirty_tracking(void);
-
-int cpu_physical_sync_dirty_bitmap(hwaddr start_addr,
-                                   hwaddr end_addr);
-
 void dump_exec_info(FILE *f,
                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
@@ -566,7 +514,6 @@
 
 void qemu_flush_coalesced_mmio_buffer(void);
 
-
 /* profiling */
 #ifdef CONFIG_PROFILER
 static inline int64_t profile_getclock(void)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 689d73c..5164153 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -81,19 +81,6 @@
 }
 
 ram_addr_t cpu_get_physical_page_desc(hwaddr addr);
-ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
-                        ram_addr_t size, void *host);
-ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
-void qemu_ram_free(ram_addr_t addr);
-void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
-/* This should only be used for ram local to a device.  */
-void *qemu_get_ram_ptr(ram_addr_t addr);
-/* Same but slower, to use for migration, where the order of
- * RAMBlocks must not change. */
-void *qemu_safe_ram_ptr(ram_addr_t addr);
-/* This should not be used by devices.  */
-int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
-ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
 
 int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read,
                            CPUWriteMemoryFunc * const *mem_write,
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
new file mode 100644
index 0000000..fd4e834
--- /dev/null
+++ b/include/exec/ram_addr.h
@@ -0,0 +1,94 @@
+/*
+ * Declarations for cpu physical memory functions
+ *
+ * Copyright 2011 Red Hat, Inc. and/or its affiliates
+ *
+ * Authors:
+ *  Avi Kivity <avi@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ *
+ */
+
+/*
+ * This header is for use by exec.c and memory.c ONLY.  Do not include it.
+ * The functions declared here will be removed soon.
+ */
+
+#ifndef RAM_ADDR_H
+#define RAM_ADDR_H
+
+#ifndef CONFIG_USER_ONLY
+#include "hw/xen/xen.h"
+
+ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
+                                   ram_addr_t size, void *host);
+ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
+/* This should only be used for ram local to a device.  */
+void *qemu_get_ram_ptr(ram_addr_t addr);
+/* This should only be used for ram local to a device.  */
+/* Same but slower, to use for migration, where the order of
+ * RAMBlocks must not change. */
+void *qemu_safe_ram_ptr(ram_addr_t addr);
+/* This should not be used by devices.  */
+int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
+void qemu_ram_free(ram_addr_t addr);
+void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
+ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
+
+static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
+                                                int dirty_flags)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
+}
+
+static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
+}
+
+/* read dirty bit (return 0 or 1) */
+static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
+}
+
+static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
+{
+    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
+}
+
+static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
+                                                      int dirty_flags)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
+}
+
+static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
+                                                        int length,
+                                                        int dirty_flags)
+{
+    int i, mask, len;
+    uint8_t *p;
+
+    len = length >> TARGET_PAGE_BITS;
+    mask = ~dirty_flags;
+    p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
+    for (i = 0; i < len; i++) {
+        p[i] &= mask;
+    }
+}
+
+int cpu_physical_memory_set_dirty_tracking(int enable);
+
+int cpu_physical_memory_get_dirty_tracking(void);
+
+int cpu_physical_sync_dirty_bitmap(hwaddr start_addr,
+                                   hwaddr end_addr);
+
+void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
+                                     int dirty_flags);
+
+#endif
+#endif
\ No newline at end of file
diff --git a/kvm-all.c b/kvm-all.c
index 8f0838b..a8bcca4 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -26,6 +26,7 @@
 #include "hw/hw.h"
 #include "android/kvm.h"
 #include "exec/gdbstub.h"
+#include "exec/ram_addr.h"
 #include "sysemu/kvm.h"
 
 /* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */