From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4W21-0000lv-JR for qemu-devel@nongnu.org; Tue, 08 Jul 2014 10:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4W1t-0003s8-OE for qemu-devel@nongnu.org; Tue, 08 Jul 2014 10:06:05 -0400 Received: from mail-we0-f172.google.com ([74.125.82.172]:49187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4W1t-0003ro-HP for qemu-devel@nongnu.org; Tue, 08 Jul 2014 10:05:57 -0400 Received: by mail-we0-f172.google.com with SMTP id u57so5927987wes.3 for ; Tue, 08 Jul 2014 07:05:56 -0700 (PDT) From: Nikolay Nikolaev Date: Tue, 08 Jul 2014 17:05:49 +0300 Message-ID: <20140708140542.7314.24797.stgit@3820> In-Reply-To: <20140708140447.7314.87628.stgit@3820> References: <20140708140447.7314.87628.stgit@3820> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 1/3] Add qemu_is_ram_block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: snabb-devel@googlegroups.com, qemu-devel@nongnu.org, mst@redhat.com Cc: tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com This function will check if given address maps into a RAMBlock. Signed-off-by: Nikolay Nikolaev --- 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);