[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH memory v3 9/9] memory: MemoryRegion: Add size proper
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [PATCH memory v3 9/9] memory: MemoryRegion: Add size property |
Date: |
Sun, 1 Jun 2014 21:19:07 -0700 |
To allow devices to dynamically resize the device. The motivation is
to allow devices with variable size to init their memory_region
without size early and then correctly populate size at realize() time.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
memory.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/memory.c b/memory.c
index 2d98020..54fdbb2 100644
--- a/memory.c
+++ b/memory.c
@@ -1003,6 +1003,40 @@ static void memory_region_set_may_overlap(Object *obj,
bool value, Error **errp)
}
}
+static void memory_region_get_size(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ MemoryRegion *mr = MEMORY_REGION(obj);
+ Error *local_err = NULL;
+ uint64_t value = int128_get64(mr->size);
+
+ visit_type_uint64(v, &value, name, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+}
+
+static void memory_region_set_size(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ MemoryRegion *mr = MEMORY_REGION(obj);
+ Error *local_err = NULL;
+ uint64_t value;
+ Int128 v128;
+
+ visit_type_uint64(v, &value, name, &local_err);
+ v128 = int128_make64(value);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ if (!int128_eq(v128, mr->size)) {
+ mr->size = v128;
+ memory_region_readd_subregion(mr);
+ }
+}
+
static void memory_region_initfn(Object *obj)
{
MemoryRegion *mr = MEMORY_REGION(obj);
@@ -1033,6 +1067,10 @@ static void memory_region_initfn(Object *obj)
memory_region_get_may_overlap,
memory_region_set_may_overlap,
&error_abort);
+ object_property_add(OBJECT(mr), "size", "uint64",
+ memory_region_get_size,
+ memory_region_set_size,
+ NULL, NULL, &error_abort);
}
static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
--
2.0.0
- [Qemu-devel] [PATCH memory v3 1/9] memory: Simplify mr_add_subregion() if-else, (continued)
- [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, 2014/06/02
- [Qemu-devel] [PATCH memory v3 9/9] memory: MemoryRegion: Add size property,
Peter Crosthwaite <=
- Re: [Qemu-devel] [PATCH memory v3 0/9] Memory Region QOMification, Peter Maydell, 2014/06/02