From 6bba19ba4e2b8c89496569439ca38a328cf29a77 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 14 Sep 2011 11:54:58 +0300 Subject: memory: introduce memory_region_set_enabled() This allows users to disable a memory region without removing it from the hierarchy, simplifying the implementation of memory routers. Signed-off-by: Avi Kivity --- memory.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'memory.h') diff --git a/memory.h b/memory.h index 53bf261792..c6997c4ee3 100644 --- a/memory.h +++ b/memory.h @@ -123,6 +123,7 @@ struct MemoryRegion { bool terminates; bool readable; bool readonly; /* For RAM regions */ + bool enabled; MemoryRegion *alias; target_phys_addr_t alias_offset; unsigned priority; @@ -501,6 +502,22 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr, void memory_region_del_subregion(MemoryRegion *mr, MemoryRegion *subregion); + +/* + * memory_region_set_enabled: dynamically enable or disable a region + * + * Enables or disables a memory region. A disabled memory region + * ignores all accesses to itself and its subregions. It does not + * obscure sibling subregions with lower priority - it simply behaves as + * if it was removed from the hierarchy. + * + * Regions default to being enabled. + * + * @mr: the region to be updated + * @enabled: whether to enable or disable the region + */ +void memory_region_set_enabled(MemoryRegion *mr, bool enabled); + /* Start a transaction; changes will be accumulated and made visible only * when the transaction ends. */ -- cgit v1.2.3 From 2282e1af408db47bab0f900344c0ba0935835f48 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 14 Sep 2011 12:10:12 +0300 Subject: memory: introduce memory_region_set_address() Allow changing the address of a memory region while it is in the memory hierarchy. Signed-off-by: Avi Kivity --- memory.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'memory.h') diff --git a/memory.h b/memory.h index c6997c4ee3..db53422b2b 100644 --- a/memory.h +++ b/memory.h @@ -518,6 +518,17 @@ void memory_region_del_subregion(MemoryRegion *mr, */ void memory_region_set_enabled(MemoryRegion *mr, bool enabled); +/* + * memory_region_set_address: dynamically update the address of a region + * + * Dynamically updates the address of a region, relative to its parent. + * May be used on regions are currently part of a memory hierarchy. + * + * @mr: the region to be updated + * @addr: new address, relative to parent region + */ +void memory_region_set_address(MemoryRegion *mr, target_phys_addr_t addr); + /* Start a transaction; changes will be accumulated and made visible only * when the transaction ends. */ -- cgit v1.2.3 From 4703359e0eeb27c382fdf2951b842cf8bde26672 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 4 Dec 2011 19:16:50 +0200 Subject: memory: introduce memory_region_set_alias_offset() Add an API to update an alias offset of an active alias. This can be used to simplify implementation of dynamic memory banks. Signed-off-by: Avi Kivity --- memory.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'memory.h') diff --git a/memory.h b/memory.h index db53422b2b..c07bcca306 100644 --- a/memory.h +++ b/memory.h @@ -529,6 +529,18 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled); */ void memory_region_set_address(MemoryRegion *mr, target_phys_addr_t addr); +/* + * memory_region_set_alias_offset: dynamically update a memory alias's offset + * + * Dynamically updates the offset into the target region that an alias points + * to, as if the fourth argument to memory_region_init_alias() has changed. + * + * @mr: the #MemoryRegion to be updated; should be an alias. + * @offset: the new offset into the target memory region + */ +void memory_region_set_alias_offset(MemoryRegion *mr, + target_phys_addr_t offset); + /* Start a transaction; changes will be accumulated and made visible only * when the transaction ends. */ -- cgit v1.2.3