* [Qemu-devel] [PATCH] Merge memory_region_init_reservation() into memory_region_init_io()
@ 2015-07-17 14:11 Pavel Fedin
2015-07-21 8:11 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Fedin @ 2015-07-17 14:11 UTC (permalink / raw)
To: qemu-devel; +Cc: 'Paolo Bonzini'
Just speficying ops = NULL in some cases can be more convenient than having
two functions. See vGICv3 v5 patch set for at least one such case.
GICv2 code can be refactored in a way similar to what is done in the mentioned patchset, killing
some code duplication.
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
include/exec/memory.h | 14 +++++++++++---
memory.c | 10 +---------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 1394715..3b5e44e 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -436,6 +436,9 @@ void memory_region_init_alias(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.
@@ -458,16 +461,21 @@ void memory_region_init_rom_device(MemoryRegion *mr,
* 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(MemoryRegion *mr,
- struct Object *owner,
+static inline void memory_region_init_reservation(MemoryRegion *mr,
+ Object *owner,
const char *name,
- uint64_t size);
+ uint64_t size)
+{
+ memory_region_init_io(mr, owner, NULL, mr, name, size);
+}
/**
* memory_region_init_iommu: Initialize a memory region that translates
diff --git a/memory.c b/memory.c
index 0acebb1..b843952 100644
--- a/memory.c
+++ b/memory.c
@@ -1187,7 +1187,7 @@ void memory_region_init_io(MemoryRegion *mr,
uint64_t size)
{
memory_region_init(mr, owner, name, size);
- mr->ops = ops;
+ mr->ops = ops ? ops : &unassigned_mem_ops;
mr->opaque = opaque;
mr->terminates = true;
}
@@ -1307,14 +1307,6 @@ void memory_region_init_iommu(MemoryRegion *mr,
notifier_list_init(&mr->iommu_notify);
}
-void memory_region_init_reservation(MemoryRegion *mr,
- Object *owner,
- const char *name,
- uint64_t size)
-{
- memory_region_init_io(mr, owner, &unassigned_mem_ops, mr, name, size);
-}
-
static void memory_region_finalize(Object *obj)
{
MemoryRegion *mr = MEMORY_REGION(obj);
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] Merge memory_region_init_reservation() into memory_region_init_io()
2015-07-17 14:11 [Qemu-devel] [PATCH] Merge memory_region_init_reservation() into memory_region_init_io() Pavel Fedin
@ 2015-07-21 8:11 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-07-21 8:11 UTC (permalink / raw)
To: Pavel Fedin, qemu-devel
On 17/07/2015 16:11, Pavel Fedin wrote:
> Just speficying ops = NULL in some cases can be more convenient than having
> two functions. See vGICv3 v5 patch set for at least one such case.
>
> GICv2 code can be refactored in a way similar to what is done in the mentioned patchset, killing
> some code duplication.
>
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Just include it in the vGICv3 series.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-21 8:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-17 14:11 [Qemu-devel] [PATCH] Merge memory_region_init_reservation() into memory_region_init_io() Pavel Fedin
2015-07-21 8:11 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.