[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH memory v3 8/9] memory: MemoryRegion: Add may-overlap
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [PATCH memory v3 8/9] memory: MemoryRegion: Add may-overlap and priority props |
Date: |
Sun, 1 Jun 2014 21:18:33 -0700 |
QOM propertyify the .may-overlap and .priority fields. The setters
will re-add the memory as a subregion if needed (i.e. the values change
when the memory region is already contained).
Signed-off-by: Peter Crosthwaite <address@hidden>
---
changed since v2:
Fixed priority getter
Support signed values in priority set/get
changed since v1:
Converted priority to signed type
include/exec/memory.h | 2 +-
memory.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 371c066..117c0d3 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -157,7 +157,7 @@ struct MemoryRegion {
bool flush_coalesced_mmio;
MemoryRegion *alias;
hwaddr alias_offset;
- int priority;
+ int32_t priority;
bool may_overlap;
QTAILQ_HEAD(subregions, MemoryRegion) subregions;
QTAILQ_ENTRY(MemoryRegion) subregions_link;
diff --git a/memory.c b/memory.c
index 0296675..2d98020 100644
--- a/memory.c
+++ b/memory.c
@@ -954,6 +954,55 @@ static void memory_region_release_container(Object *obj,
const char *name,
}
}
+static void memory_region_get_priority(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ MemoryRegion *mr = MEMORY_REGION(obj);
+ Error *local_err = NULL;
+ int32_t value = mr->priority;
+
+ visit_type_int32(v, &value, name, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+}
+
+static void memory_region_set_priority(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ MemoryRegion *mr = MEMORY_REGION(obj);
+ Error *local_err = NULL;
+ int32_t value;
+
+ visit_type_int32(v, &value, name, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ if (mr->priority != value) {
+ mr->priority = value;
+ memory_region_readd_subregion(mr);
+ }
+}
+
+static bool memory_region_get_may_overlap(Object *obj, Error **errp)
+{
+ MemoryRegion *mr = MEMORY_REGION(obj);
+
+ return mr->may_overlap;
+}
+
+static void memory_region_set_may_overlap(Object *obj, bool value, Error
**errp)
+{
+ MemoryRegion *mr = MEMORY_REGION(obj);
+
+ if (mr->may_overlap != value) {
+ mr->may_overlap = value;
+ memory_region_readd_subregion(mr);
+ }
+}
+
static void memory_region_initfn(Object *obj)
{
MemoryRegion *mr = MEMORY_REGION(obj);
@@ -976,6 +1025,14 @@ static void memory_region_initfn(Object *obj)
memory_region_get_addr,
memory_region_set_addr,
NULL, NULL, &error_abort);
+ object_property_add(OBJECT(mr), "priority", "uint32",
+ memory_region_get_priority,
+ memory_region_set_priority,
+ NULL, NULL, &error_abort);
+ object_property_add_bool(OBJECT(mr), "may-overlap",
+ memory_region_get_may_overlap,
+ memory_region_set_may_overlap,
+ &error_abort);
}
static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
--
2.0.0
- [Qemu-devel] [PATCH memory v3 0/9] Memory Region QOMification, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 1/9] memory: Simplify mr_add_subregion() if-else, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 2/9] qom: object: Ignore refs/unrefs of NULL, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 3/9] qom: Publish object_resolve_link, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 4/9] memory: Coreify subregion add functionality, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 5/9] memory: MemoryRegion: factor out memory region re-adder, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 6/9] memory: MemoryRegion: QOMify, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 7/9] memory: MemoryRegion: Add container and addr props, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [PATCH memory v3 8/9] memory: MemoryRegion: Add may-overlap and priority props,
Peter Crosthwaite <=
- [Qemu-devel] [PATCH memory v3 9/9] memory: MemoryRegion: Add size property, Peter Crosthwaite, 2014/06/02
- Re: [Qemu-devel] [PATCH memory v3 0/9] Memory Region QOMification, Peter Maydell, 2014/06/02