diff options
author | Avi Kivity <avi@redhat.com> | 2011-08-08 19:58:49 +0300 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-12 08:31:30 -0500 |
commit | d0a9b5bc0a6abdab182ad55dcc1c71508c163c5c (patch) | |
tree | 37c0df9b94f5d4faeffaa6384f505ae9908a2e12 /memory.h | |
parent | 545e92e06aa4f5eda46f4be2018a595d1adf66f8 (diff) |
memory: add API for creating ROM/device regions
ROM/device regions act as mapped RAM for reads, can I/O memory for
writes. This allow emulation of flash devices.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'memory.h')
-rw-r--r-- | memory.h | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -113,6 +113,7 @@ struct MemoryRegion { ram_addr_t ram_addr; IORange iorange; bool terminates; + bool readable; MemoryRegion *alias; target_phys_addr_t alias_offset; unsigned priority; @@ -219,6 +220,25 @@ void memory_region_init_alias(MemoryRegion *mr, MemoryRegion *orig, target_phys_addr_t offset, uint64_t size); + +/** + * memory_region_init_rom_device: Initialize a ROM memory region. Writes are + * handled via callbacks. + * + * @mr: the #MemoryRegion to be initialized. + * @ops: callbacks for write access handling. + * @dev: a device associated with the region; may be %NULL. + * @name: the name of the region; the pair (@dev, @name) must be globally + * unique. The name is part of the save/restore ABI and so cannot be + * changed. + * @size: size of the region. + */ +void memory_region_init_rom_device(MemoryRegion *mr, + const MemoryRegionOps *ops, + DeviceState *dev, /* FIXME: layering violation */ + const char *name, + uint64_t size); + /** * memory_region_destroy: Destroy a memory region and relaim all resources. * @@ -331,6 +351,20 @@ void memory_region_reset_dirty(MemoryRegion *mr, target_phys_addr_t addr, void memory_region_set_readonly(MemoryRegion *mr, bool readonly); /** + * memory_region_rom_device_set_readable: enable/disable ROM readability + * + * Allows a ROM device (initialized with memory_region_init_rom_device() to + * to be marked as readable (default) or not readable. When it is readable, + * the device is mapped to guest memory. When not readable, reads are + * forwarded to the #MemoryRegion.read function. + * + * @mr: the memory region to be updated + * @readable: whether reads are satisified directly (%true) or via callbacks + * (%false) + */ +void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable); + +/** * memory_region_set_coalescing: Enable memory coalescing for the region. * * Enabled writes to a region to be queued for later processing. MMIO ->write |