9ae3a8
From e2bf4a6155c08480e42afe12d5ea1ce083c35f00 Mon Sep 17 00:00:00 2001
9ae3a8
From: Juan Quintela <quintela@redhat.com>
9ae3a8
Date: Tue, 14 Jan 2014 15:07:44 +0100
9ae3a8
Subject: [PATCH 33/40] memory: split cpu_physical_memory_* functions to its own include
9ae3a8
9ae3a8
RH-Author: Juan Quintela <quintela@redhat.com>
9ae3a8
Message-id: <1389712071-23303-34-git-send-email-quintela@redhat.com>
9ae3a8
Patchwork-id: 56688
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 33/40] memory: split cpu_physical_memory_* functions to its own include
9ae3a8
Bugzilla: 997559
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
9ae3a8
All the functions that use ram_addr_t should be here.
9ae3a8
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
(cherry picked from commit 220c3ebddbd1ac289ae7fc64733c9501b3921d94)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	exec.c
9ae3a8
	include/exec/memory-internal.h
9ae3a8
9ae3a8
Conflicts due to missing upstream commits:
9ae3a8
9ae3a8
commit d2702032b4746515cff0bf29891a6b6decfc3d86
9ae3a8
Author: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date:   Fri May 24 11:55:06 2013 +0200
9ae3a8
9ae3a8
    memory: export memory_region_access_valid to exec.c
9ae3a8
9ae3a8
commit d197063fcf969e1269dc53c9c9e9a073f87aa3b4
9ae3a8
Author: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date:   Fri May 24 13:23:38 2013 +0200
9ae3a8
9ae3a8
    memory: move unassigned_mem_ops to memory.c
9ae3a8
9ae3a8
commit b40acf99bef69fa8ab0f9092ff162fde945eec12
9ae3a8
Author: Jan Kiszka <jan.kiszka@siemens.com>
9ae3a8
Date:   Mon Jun 24 10:45:09 2013 +0200
9ae3a8
9ae3a8
    ioport: Switch dispatching to memory core layer
9ae3a8
9ae3a8
commit ee983cb3cc8f856b408a272269f434cc9a82ceff
9ae3a8
Author: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date:   Tue May 14 11:47:56 2013 +0200
9ae3a8
9ae3a8
    exec: make qemu_get_ram_ptr private
9ae3a8
9ae3a8
Signed-off-by: Juan Quintela <quintela@trasno.org>
9ae3a8
---
9ae3a8
 cputlb.c                       |  1 +
9ae3a8
 exec.c                         |  1 +
9ae3a8
 include/exec/memory-internal.h | 76 ---------------------------------
9ae3a8
 include/exec/ram_addr.h        | 97 ++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 memory.c                       |  1 +
9ae3a8
 5 files changed, 100 insertions(+), 76 deletions(-)
9ae3a8
 create mode 100644 include/exec/ram_addr.h
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 cputlb.c                       |    1 +
9ae3a8
 exec.c                         |    1 +
9ae3a8
 include/exec/memory-internal.h |   76 -------------------------------
9ae3a8
 include/exec/ram_addr.h        |   97 ++++++++++++++++++++++++++++++++++++++++
9ae3a8
 memory.c                       |    1 +
9ae3a8
 5 files changed, 100 insertions(+), 76 deletions(-)
9ae3a8
 create mode 100644 include/exec/ram_addr.h
9ae3a8
9ae3a8
diff --git a/cputlb.c b/cputlb.c
9ae3a8
index 44ec9bc..7699fdd 100644
9ae3a8
--- a/cputlb.c
9ae3a8
+++ b/cputlb.c
9ae3a8
@@ -26,6 +26,7 @@
9ae3a8
 #include "exec/cputlb.h"
9ae3a8
 
9ae3a8
 #include "exec/memory-internal.h"
9ae3a8
+#include "exec/ram_addr.h"
9ae3a8
 
9ae3a8
 //#define DEBUG_TLB
9ae3a8
 //#define DEBUG_TLB_CHECK
9ae3a8
diff --git a/exec.c b/exec.c
9ae3a8
index 12adb12..b16ef4a 100644
9ae3a8
--- a/exec.c
9ae3a8
+++ b/exec.c
9ae3a8
@@ -50,6 +50,7 @@
9ae3a8
 #include "translate-all.h"
9ae3a8
 
9ae3a8
 #include "exec/memory-internal.h"
9ae3a8
+#include "exec/ram_addr.h"
9ae3a8
 
9ae3a8
 //#define DEBUG_UNASSIGNED
9ae3a8
 //#define DEBUG_SUBPAGE
9ae3a8
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
9ae3a8
index 327d54e..8b558bf 100644
9ae3a8
--- a/include/exec/memory-internal.h
9ae3a8
+++ b/include/exec/memory-internal.h
9ae3a8
@@ -20,87 +20,11 @@
9ae3a8
 #define MEMORY_INTERNAL_H
9ae3a8
 
9ae3a8
 #ifndef CONFIG_USER_ONLY
9ae3a8
-#include "hw/xen/xen.h"
9ae3a8
-
9ae3a8
-
9ae3a8
 typedef struct AddressSpaceDispatch AddressSpaceDispatch;
9ae3a8
 
9ae3a8
 void address_space_init_dispatch(AddressSpace *as);
9ae3a8
 void address_space_destroy_dispatch(AddressSpace *as);
9ae3a8
 
9ae3a8
-ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
9ae3a8
-                                   MemoryRegion *mr);
9ae3a8
-ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
9ae3a8
-void qemu_ram_free(ram_addr_t addr);
9ae3a8
-void qemu_ram_free_from_ptr(ram_addr_t addr);
9ae3a8
-
9ae3a8
-static inline bool cpu_physical_memory_get_dirty(ram_addr_t start,
9ae3a8
-                                                 ram_addr_t length,
9ae3a8
-                                                 unsigned client)
9ae3a8
-{
9ae3a8
-    unsigned long end, page, next;
9ae3a8
-
9ae3a8
-    assert(client < DIRTY_MEMORY_NUM);
9ae3a8
-
9ae3a8
-    end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
9ae3a8
-    page = start >> TARGET_PAGE_BITS;
9ae3a8
-    next = find_next_bit(ram_list.dirty_memory[client], end, page);
9ae3a8
-
9ae3a8
-    return next < end;
9ae3a8
-}
9ae3a8
-
9ae3a8
-static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
9ae3a8
-                                                      unsigned client)
9ae3a8
-{
9ae3a8
-    return cpu_physical_memory_get_dirty(addr, 1, client);
9ae3a8
-}
9ae3a8
-
9ae3a8
-static inline bool cpu_physical_memory_is_clean(ram_addr_t addr)
9ae3a8
-{
9ae3a8
-    bool vga = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_VGA);
9ae3a8
-    bool code = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_CODE);
9ae3a8
-    bool migration =
9ae3a8
-        cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_MIGRATION);
9ae3a8
-    return !(vga && code && migration);
9ae3a8
-}
9ae3a8
-
9ae3a8
-static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
9ae3a8
-                                                      unsigned client)
9ae3a8
-{
9ae3a8
-    assert(client < DIRTY_MEMORY_NUM);
9ae3a8
-    set_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
9ae3a8
-}
9ae3a8
-
9ae3a8
-static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
9ae3a8
-                                                       ram_addr_t length)
9ae3a8
-{
9ae3a8
-    unsigned long end, page;
9ae3a8
-
9ae3a8
-    end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
9ae3a8
-    page = start >> TARGET_PAGE_BITS;
9ae3a8
-    bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
9ae3a8
-    bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
9ae3a8
-    bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_CODE], page, end - page);
9ae3a8
-    xen_modified_memory(start, length);
9ae3a8
-}
9ae3a8
-
9ae3a8
-static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
9ae3a8
-                                                         ram_addr_t length,
9ae3a8
-                                                         unsigned client)
9ae3a8
-{
9ae3a8
-    unsigned long end, page;
9ae3a8
-
9ae3a8
-    assert(client < DIRTY_MEMORY_NUM);
9ae3a8
-    end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
9ae3a8
-    page = start >> TARGET_PAGE_BITS;
9ae3a8
-    bitmap_clear(ram_list.dirty_memory[client], page, end - page);
9ae3a8
-}
9ae3a8
-
9ae3a8
-void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length,
9ae3a8
-                                     unsigned client);
9ae3a8
-
9ae3a8
 extern const IORangeOps memory_region_iorange_ops;
9ae3a8
-
9ae3a8
 #endif
9ae3a8
-
9ae3a8
 #endif
9ae3a8
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
9ae3a8
new file mode 100644
9ae3a8
index 0000000..0caa239
9ae3a8
--- /dev/null
9ae3a8
+++ b/include/exec/ram_addr.h
9ae3a8
@@ -0,0 +1,97 @@
9ae3a8
+/*
9ae3a8
+ * Declarations for cpu physical memory functions
9ae3a8
+ *
9ae3a8
+ * Copyright 2011 Red Hat, Inc. and/or its affiliates
9ae3a8
+ *
9ae3a8
+ * Authors:
9ae3a8
+ *  Avi Kivity <avi@redhat.com>
9ae3a8
+ *
9ae3a8
+ * This work is licensed under the terms of the GNU GPL, version 2 or
9ae3a8
+ * later.  See the COPYING file in the top-level directory.
9ae3a8
+ *
9ae3a8
+ */
9ae3a8
+
9ae3a8
+/*
9ae3a8
+ * This header is for use by exec.c and memory.c ONLY.  Do not include it.
9ae3a8
+ * The functions declared here will be removed soon.
9ae3a8
+ */
9ae3a8
+
9ae3a8
+#ifndef RAM_ADDR_H
9ae3a8
+#define RAM_ADDR_H
9ae3a8
+
9ae3a8
+#ifndef CONFIG_USER_ONLY
9ae3a8
+#include "hw/xen/xen.h"
9ae3a8
+
9ae3a8
+ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
9ae3a8
+                                   MemoryRegion *mr);
9ae3a8
+ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
9ae3a8
+void qemu_ram_free(ram_addr_t addr);
9ae3a8
+void qemu_ram_free_from_ptr(ram_addr_t addr);
9ae3a8
+
9ae3a8
+static inline bool cpu_physical_memory_get_dirty(ram_addr_t start,
9ae3a8
+                                                 ram_addr_t length,
9ae3a8
+                                                 unsigned client)
9ae3a8
+{
9ae3a8
+    unsigned long end, page, next;
9ae3a8
+
9ae3a8
+    assert(client < DIRTY_MEMORY_NUM);
9ae3a8
+
9ae3a8
+    end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
9ae3a8
+    page = start >> TARGET_PAGE_BITS;
9ae3a8
+    next = find_next_bit(ram_list.dirty_memory[client], end, page);
9ae3a8
+
9ae3a8
+    return next < end;
9ae3a8
+}
9ae3a8
+
9ae3a8
+static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
9ae3a8
+                                                      unsigned client)
9ae3a8
+{
9ae3a8
+    return cpu_physical_memory_get_dirty(addr, 1, client);
9ae3a8
+}
9ae3a8
+
9ae3a8
+static inline bool cpu_physical_memory_is_clean(ram_addr_t addr)
9ae3a8
+{
9ae3a8
+    bool vga = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_VGA);
9ae3a8
+    bool code = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_CODE);
9ae3a8
+    bool migration =
9ae3a8
+        cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_MIGRATION);
9ae3a8
+    return !(vga && code && migration);
9ae3a8
+}
9ae3a8
+
9ae3a8
+static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
9ae3a8
+                                                      unsigned client)
9ae3a8
+{
9ae3a8
+    assert(client < DIRTY_MEMORY_NUM);
9ae3a8
+    set_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
9ae3a8
+}
9ae3a8
+
9ae3a8
+static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
9ae3a8
+                                                       ram_addr_t length)
9ae3a8
+{
9ae3a8
+    unsigned long end, page;
9ae3a8
+
9ae3a8
+    end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
9ae3a8
+    page = start >> TARGET_PAGE_BITS;
9ae3a8
+    bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
9ae3a8
+    bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
9ae3a8
+    bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_CODE], page, end - page);
9ae3a8
+    xen_modified_memory(start, length);
9ae3a8
+}
9ae3a8
+
9ae3a8
+static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
9ae3a8
+                                                         ram_addr_t length,
9ae3a8
+                                                         unsigned client)
9ae3a8
+{
9ae3a8
+    unsigned long end, page;
9ae3a8
+
9ae3a8
+    assert(client < DIRTY_MEMORY_NUM);
9ae3a8
+    end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
9ae3a8
+    page = start >> TARGET_PAGE_BITS;
9ae3a8
+    bitmap_clear(ram_list.dirty_memory[client], page, end - page);
9ae3a8
+}
9ae3a8
+
9ae3a8
+void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length,
9ae3a8
+                                     unsigned client);
9ae3a8
+
9ae3a8
+#endif
9ae3a8
+#endif
9ae3a8
diff --git a/memory.c b/memory.c
9ae3a8
index b49642b..685912d 100644
9ae3a8
--- a/memory.c
9ae3a8
+++ b/memory.c
9ae3a8
@@ -21,6 +21,7 @@
9ae3a8
 #include <assert.h>
9ae3a8
 
9ae3a8
 #include "exec/memory-internal.h"
9ae3a8
+#include "exec/ram_addr.h"
9ae3a8
 
9ae3a8
 static unsigned memory_region_transaction_depth;
9ae3a8
 static bool memory_region_update_pending;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8