[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/41] exec.c: factor out qemu_get_ram_ptr()
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v2 13/41] exec.c: factor out qemu_get_ram_ptr() |
Date: |
Mon, 4 Jun 2012 18:57:15 +0900 |
Signed-off-by: Isaku Yamahata <address@hidden>
---
cpu-all.h | 2 ++
exec.c | 51 +++++++++++++++++++++++++++++----------------------
2 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h
index 028528f..ff7f827 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -508,6 +508,8 @@ extern RAMList ram_list;
extern const char *mem_path;
extern int mem_prealloc;
+RAMBlock *qemu_get_ram_block(ram_addr_t adar);
+
/* Flags stored in the low bits of the TLB virtual address. These are
defined so that fast path ram access is all zeros. */
/* Zero if TLB entry is valid. */
diff --git a/exec.c b/exec.c
index 078a408..7f44893 100644
--- a/exec.c
+++ b/exec.c
@@ -2799,15 +2799,7 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
}
#endif /* !_WIN32 */
-/* Return a host pointer to ram allocated with qemu_ram_alloc.
- With the exception of the softmmu code in this file, this should
- only be used for local memory (e.g. video ram) that the device owns,
- and knows it isn't going to access beyond the end of the block.
-
- It should not be used for general purpose DMA.
- Use cpu_physical_memory_map/cpu_physical_memory_rw instead.
- */
-void *qemu_get_ram_ptr(ram_addr_t addr)
+RAMBlock *qemu_get_ram_block(ram_addr_t addr)
{
RAMBlock *block;
@@ -2818,19 +2810,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
QLIST_REMOVE(block, next);
QLIST_INSERT_HEAD(&ram_list.blocks, block, next);
}
- if (xen_enabled()) {
- /* We need to check if the requested address is in the RAM
- * because we don't want to map the entire memory in QEMU.
- * In that case just map until the end of the page.
- */
- if (block->offset == 0) {
- return xen_map_cache(addr, 0, 0);
- } else if (block->host == NULL) {
- block->host =
- xen_map_cache(block->offset, block->length, 1);
- }
- }
- return block->host + (addr - block->offset);
+ return block;
}
}
@@ -2841,6 +2821,33 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
}
/* Return a host pointer to ram allocated with qemu_ram_alloc.
+ With the exception of the softmmu code in this file, this should
+ only be used for local memory (e.g. video ram) that the device owns,
+ and knows it isn't going to access beyond the end of the block.
+
+ It should not be used for general purpose DMA.
+ Use cpu_physical_memory_map/cpu_physical_memory_rw instead.
+ */
+void *qemu_get_ram_ptr(ram_addr_t addr)
+{
+ RAMBlock *block = qemu_get_ram_block(addr);
+
+ if (xen_enabled()) {
+ /* We need to check if the requested address is in the RAM
+ * because we don't want to map the entire memory in QEMU.
+ * In that case just map until the end of the page.
+ */
+ if (block->offset == 0) {
+ return xen_map_cache(addr, 0, 0);
+ } else if (block->host == NULL) {
+ block->host =
+ xen_map_cache(block->offset, block->length, 1);
+ }
+ }
+ return block->host + (addr - block->offset);
+}
+
+/* Return a host pointer to ram allocated with qemu_ram_alloc.
* Same as qemu_get_ram_ptr but avoid reordering ramblocks.
*/
void *qemu_safe_ram_ptr(ram_addr_t addr)
--
1.7.1.1
- [Qemu-devel] [PATCH v2 17/41] savevm, buffered_file: introduce method to drain buffer of buffered file, (continued)
- [Qemu-devel] [PATCH v2 17/41] savevm, buffered_file: introduce method to drain buffer of buffered file, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 20/41] savevm/QEMUFileSocket: drop duplicated member fd, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 01/41] arch_init: export sort_ram_list() and ram_save_block(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 18/41] QEMUFile: add qemu_file_fd() for later use, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 24/41] migration: export migrate_fd_completed() and migrate_fd_cleanup(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 05/41] arch_init/ram_save_live: factor out RAM_SAVE_FLAG_MEM_SIZE case, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 31/41] configure: add CONFIG_POSTCOPY option, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 22/41] savevm/QEMUFile: introduce qemu_fopen_fd, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 09/41] arch_init: introduce helper function to find ram block with id string, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 02/41] arch_init: export RAM_SAVE_xxx flags for postcopy, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 13/41] exec.c: factor out qemu_get_ram_ptr(),
Isaku Yamahata <=
- [Qemu-devel] [PATCH v2 21/41] savevm: rename QEMUFileSocket to QEMUFileFD, socket_close to fd_close, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 11/41] arch_init: factor out counting transferred bytes, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 27/41] buffered_file: Introduce QEMUFileNonblock for nonblock write, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 07/41] arch_init/ram_save_live: factor out ram_save_limit, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 23/41] migration.c: remove redundant line in migrate_init(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 29/41] umem.h: import Linux umem.h, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 19/41] savevm/QEMUFile: drop qemu_stdio_fd, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 32/41] savevm: add new section that is used by postcopy, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 15/41] savevm: export qemu_peek_buffer, qemu_peek_byte, qemu_file_skip, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 25/41] migration: factor out parameters into MigrationParams, Isaku Yamahata, 2012/06/04