From 0201c711455187bc9fa3e98a326f4295d2b64fa2 Mon Sep 17 00:00:00 2001
From: Pavel Fedin
Date: Wed, 21 Feb 2018 11:21:53 -0500
Subject: [PATCH] Merge memory_region_init_reservation() into
memory_region_init_io()
Just specifying ops = NULL in some cases can be more convenient than having
two functions.
Backports commit 6d6d2abf2c2e52c0f404d0a31a963e945b0cc7ad from qemu
---
qemu/include/exec/memory.h | 16 ++++++++++++----
qemu/memory.c | 10 +---------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h
index d488bdee..7e6d3652 100644
--- a/qemu/include/exec/memory.h
+++ b/qemu/include/exec/memory.h
@@ -386,6 +386,9 @@ void memory_region_init_alias(struct uc_struct *uc, MemoryRegion *mr,
* memory_region_init_rom_device: Initialize a ROM memory region. Writes are
* handled via callbacks.
*
+ * If NULL callbacks pointer is given, then I/O space is not supposed to be
+ * handled by QEMU itself. Any access via the memory API will cause an abort().
+ *
* @mr: the #MemoryRegion to be initialized.
* @owner: the object that tracks the region's reference count
* @ops: callbacks for write access handling.
@@ -434,16 +437,21 @@ void memory_region_init_resizeable_ram(struct uc_struct *uc,
* A reservation region primariy serves debugging purposes. It claims I/O
* space that is not supposed to be handled by QEMU itself. Any access via
* the memory API will cause an abort().
+ * This function is deprecated. Use memory_region_init_io() with NULL
+ * callbacks instead.
*
* @mr: the #MemoryRegion to be initialized
* @owner: the object that tracks the region's reference count
* @name: used for debugging; not visible to the user or ABI
* @size: size of the region.
*/
-void memory_region_init_reservation(struct uc_struct *uc, MemoryRegion *mr,
- struct Object *owner,
- const char *name,
- uint64_t size);
+static inline void memory_region_init_reservation(struct uc_struct *uc, MemoryRegion *mr,
+ Object *owner,
+ const char *name,
+ uint64_t size)
+{
+ memory_region_init_io(uc, mr, owner, NULL, mr, name, size);
+}
/**
* memory_region_init_iommu: Initialize a memory region that translates
diff --git a/qemu/memory.c b/qemu/memory.c
index 5c7821c9..8659a8be 100644
--- a/qemu/memory.c
+++ b/qemu/memory.c
@@ -1147,7 +1147,7 @@ void memory_region_init_io(struct uc_struct *uc, MemoryRegion *mr,
uint64_t size)
{
memory_region_init(uc, mr, owner, name, size);
- mr->ops = ops;
+ mr->ops = ops ? ops : &unassigned_mem_ops;
mr->opaque = opaque;
mr->terminates = true;
}
@@ -1225,14 +1225,6 @@ void memory_region_init_alias(struct uc_struct *uc, MemoryRegion *mr,
mr->alias_offset = offset;
}
-void memory_region_init_reservation(struct uc_struct *uc, MemoryRegion *mr,
- Object *owner,
- const char *name,
- uint64_t size)
-{
- memory_region_init_io(uc, mr, owner, &unassigned_mem_ops, mr, name, size);
-}
-
static void memory_region_finalize(struct uc_struct *uc, Object *obj, void *opaque)
{
MemoryRegion *mr = MEMORY_REGION(uc, obj);