[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/3] Add qemu_is_ram_block
From: |
Nikolay Nikolaev |
Subject: |
[Qemu-devel] [PATCH 1/3] Add qemu_is_ram_block |
Date: |
Tue, 08 Jul 2014 17:05:49 +0300 |
User-agent: |
StGit/0.17.1-dirty |
This function will check if given address maps into a RAMBlock.
Signed-off-by: Nikolay Nikolaev <address@hidden>
---
exec.c | 15 +++++++++++++++
include/exec/ram_addr.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/exec.c b/exec.c
index 5a2a25e..0b1457b 100644
--- a/exec.c
+++ b/exec.c
@@ -743,6 +743,21 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
}
#if !defined(CONFIG_USER_ONLY)
+bool qemu_is_ram_block(ram_addr_t addr)
+{
+ RAMBlock *block;
+ bool found = false;
+
+ QTAILQ_FOREACH(block, &ram_list.blocks, next) {
+ if (addr - block->offset < block->length) {
+ found = true;
+ break;
+ }
+ }
+
+ return found;
+}
+
static RAMBlock *qemu_get_ram_block(ram_addr_t addr)
{
RAMBlock *block;
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index e9eb831..a4b2c3e 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -28,6 +28,7 @@ ram_addr_t qemu_ram_alloc_from_file(ram_addr_t size,
MemoryRegion *mr,
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
MemoryRegion *mr);
ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
+bool qemu_is_ram_block(ram_addr_t addr);
int qemu_get_ram_fd(ram_addr_t addr);
void *qemu_get_ram_block_host_ptr(ram_addr_t addr);
void *qemu_get_ram_ptr(ram_addr_t addr);