mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
memory.h: Add memory_region_init_{ram, rom, rom_device}() handling migration
Add new utility functions which both initialize a RAM MemoryRegion and arrange for its contents to be migrated; we give thes the memory_region_init_ram(), memory_region_init_rom() and memory_region_init_rom_device() names that we just freed up by renaming the old implementations to _nomigrate(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1499438577-7674-6-git-send-email-peter.maydell@linaro.org
This commit is contained in:
parent
b59821a95b
commit
b08199c6fb
3 changed files with 166 additions and 1 deletions
|
@ -678,6 +678,94 @@ void memory_region_init_iommu(void *_iommu_mr,
|
|||
const char *name,
|
||||
uint64_t size);
|
||||
|
||||
/**
|
||||
* memory_region_init_ram - Initialize RAM memory region. Accesses into the
|
||||
* region will modify memory directly.
|
||||
*
|
||||
* @mr: the #MemoryRegion to be initialized
|
||||
* @owner: the object that tracks the region's reference count (must be
|
||||
* TYPE_DEVICE or a subclass of TYPE_DEVICE, or NULL)
|
||||
* @name: name of the memory region
|
||||
* @size: size of the region in bytes
|
||||
* @errp: pointer to Error*, to store an error if it happens.
|
||||
*
|
||||
* This function allocates RAM for a board model or device, and
|
||||
* arranges for it to be migrated (by calling vmstate_register_ram()
|
||||
* if @owner is a DeviceState, or vmstate_register_ram_global() if
|
||||
* @owner is NULL).
|
||||
*
|
||||
* TODO: Currently we restrict @owner to being either NULL (for
|
||||
* global RAM regions with no owner) or devices, so that we can
|
||||
* give the RAM block a unique name for migration purposes.
|
||||
* We should lift this restriction and allow arbitrary Objects.
|
||||
* If you pass a non-NULL non-device @owner then we will assert.
|
||||
*/
|
||||
void memory_region_init_ram(MemoryRegion *mr,
|
||||
struct Object *owner,
|
||||
const char *name,
|
||||
uint64_t size,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* memory_region_init_rom: Initialize a ROM memory region.
|
||||
*
|
||||
* This has the same effect as calling memory_region_init_ram()
|
||||
* and then marking the resulting region read-only with
|
||||
* memory_region_set_readonly(). This includes arranging for the
|
||||
* contents to be migrated.
|
||||
*
|
||||
* TODO: Currently we restrict @owner to being either NULL (for
|
||||
* global RAM regions with no owner) or devices, so that we can
|
||||
* give the RAM block a unique name for migration purposes.
|
||||
* We should lift this restriction and allow arbitrary Objects.
|
||||
* If you pass a non-NULL non-device @owner then we will assert.
|
||||
*
|
||||
* @mr: the #MemoryRegion to be initialized.
|
||||
* @owner: the object that tracks the region's reference count
|
||||
* @name: Region name, becomes part of RAMBlock name used in migration stream
|
||||
* must be unique within any device
|
||||
* @size: size of the region.
|
||||
* @errp: pointer to Error*, to store an error if it happens.
|
||||
*/
|
||||
void memory_region_init_rom(MemoryRegion *mr,
|
||||
struct Object *owner,
|
||||
const char *name,
|
||||
uint64_t size,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* memory_region_init_rom_device: Initialize a ROM memory region.
|
||||
* Writes are handled via callbacks.
|
||||
*
|
||||
* This function initializes a memory region backed by RAM for reads
|
||||
* and callbacks for writes, and arranges for the RAM backing to
|
||||
* be migrated (by calling vmstate_register_ram()
|
||||
* if @owner is a DeviceState, or vmstate_register_ram_global() if
|
||||
* @owner is NULL).
|
||||
*
|
||||
* TODO: Currently we restrict @owner to being either NULL (for
|
||||
* global RAM regions with no owner) or devices, so that we can
|
||||
* give the RAM block a unique name for migration purposes.
|
||||
* We should lift this restriction and allow arbitrary Objects.
|
||||
* If you pass a non-NULL non-device @owner then we will assert.
|
||||
*
|
||||
* @mr: the #MemoryRegion to be initialized.
|
||||
* @owner: the object that tracks the region's reference count
|
||||
* @ops: callbacks for write access handling (must not be NULL).
|
||||
* @name: Region name, becomes part of RAMBlock name used in migration stream
|
||||
* must be unique within any device
|
||||
* @size: size of the region.
|
||||
* @errp: pointer to Error*, to store an error if it happens.
|
||||
*/
|
||||
void memory_region_init_rom_device(MemoryRegion *mr,
|
||||
struct Object *owner,
|
||||
const MemoryRegionOps *ops,
|
||||
void *opaque,
|
||||
const char *name,
|
||||
uint64_t size,
|
||||
Error **errp);
|
||||
|
||||
|
||||
/**
|
||||
* memory_region_owner: get a memory region's owner.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue