summary refs log tree commit diff stats
path: root/include/system/ramblock.h
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-09-29 17:36:46 +0200
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-10-07 03:37:04 +0200
commit6feb119d32ed1b8853e407495fad33795b9c2137 (patch)
tree9accebdf9f8e260889cade9f9443a79532163b94 /include/system/ramblock.h
parentfe11c4957b8120c48ed650e7c970ea004d8432f4 (diff)
downloadfocaccia-qemu-6feb119d32ed1b8853e407495fad33795b9c2137.tar.gz
focaccia-qemu-6feb119d32ed1b8853e407495fad33795b9c2137.zip
system/ramblock: Move RAMBlock helpers out of "system/ram_addr.h"
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Peter Xu <peterx@redhat.com>
Message-Id: <20251002032812.26069-6-philmd@linaro.org>
Diffstat (limited to 'include/system/ramblock.h')
-rw-r--r--include/system/ramblock.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/system/ramblock.h b/include/system/ramblock.h
index 85cceff6bc..76694fe1b5 100644
--- a/include/system/ramblock.h
+++ b/include/system/ramblock.h
@@ -119,4 +119,15 @@ int ram_block_attributes_state_change(RamBlockAttributes *attr, uint64_t offset,
  */
 bool ram_block_is_pmem(RAMBlock *rb);
 
+static inline bool offset_in_ramblock(RAMBlock *b, ram_addr_t offset)
+{
+    return b && b->host && (offset < b->used_length);
+}
+
+static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset)
+{
+    assert(offset_in_ramblock(block, offset));
+    return (char *)block->host + offset;
+}
+
 #endif