2 * Physical memory management API
4 * Copyright 2011 Red Hat, Inc. and/or its affiliates
7 * Avi Kivity <avi@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
17 #ifndef CONFIG_USER_ONLY
21 #include "qemu-common.h"
22 #include "exec/cpu-common.h"
23 #include "exec/hwaddr.h"
24 #include "qemu/queue.h"
25 #include "exec/iorange.h"
26 #include "exec/ioport.h"
27 #include "qemu/int128.h"
29 typedef struct MemoryRegionOps MemoryRegionOps
;
30 typedef struct MemoryRegion MemoryRegion
;
31 typedef struct MemoryRegionPortio MemoryRegionPortio
;
32 typedef struct MemoryRegionMmio MemoryRegionMmio
;
34 /* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic
37 #define DIRTY_MEMORY_VGA 0
38 #define DIRTY_MEMORY_CODE 1
39 #define DIRTY_MEMORY_MIGRATION 3
41 struct MemoryRegionMmio
{
42 CPUReadMemoryFunc
*read
[3];
43 CPUWriteMemoryFunc
*write
[3];
46 /* Internal use; thunks between old-style IORange and MemoryRegions. */
47 typedef struct MemoryRegionIORange MemoryRegionIORange
;
48 struct MemoryRegionIORange
{
55 * Memory region callbacks
57 struct MemoryRegionOps
{
58 /* Read from the memory region. @addr is relative to @mr; @size is
60 uint64_t (*read
)(void *opaque
,
63 /* Write to the memory region. @addr is relative to @mr; @size is
65 void (*write
)(void *opaque
,
70 enum device_endian endianness
;
71 /* Guest-visible constraints: */
73 /* If nonzero, specify bounds on access sizes beyond which a machine
76 unsigned min_access_size
;
77 unsigned max_access_size
;
78 /* If true, unaligned accesses are supported. Otherwise unaligned
79 * accesses throw machine checks.
83 * If present, and returns #false, the transaction is not accepted
84 * by the device (and results in machine dependent behaviour such
85 * as a machine check exception).
87 bool (*accepts
)(void *opaque
, hwaddr addr
,
88 unsigned size
, bool is_write
);
90 /* Internal implementation constraints: */
92 /* If nonzero, specifies the minimum size implemented. Smaller sizes
93 * will be rounded upwards and a partial result will be returned.
95 unsigned min_access_size
;
96 /* If nonzero, specifies the maximum size implemented. Larger sizes
97 * will be done as a series of accesses with smaller sizes.
99 unsigned max_access_size
;
100 /* If true, unaligned accesses are supported. Otherwise all accesses
101 * are converted to (possibly multiple) naturally aligned accesses.
106 /* If .read and .write are not present, old_portio may be used for
107 * backwards compatibility with old portio registration
109 const MemoryRegionPortio
*old_portio
;
110 /* If .read and .write are not present, old_mmio may be used for
111 * backwards compatibility with old mmio registration
113 const MemoryRegionMmio old_mmio
;
116 typedef struct CoalescedMemoryRange CoalescedMemoryRange
;
117 typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd
;
119 struct MemoryRegion
{
120 /* All fields are private - violators will be prosecuted */
121 const MemoryRegionOps
*ops
;
123 MemoryRegion
*parent
;
126 void (*destructor
)(MemoryRegion
*mr
);
132 bool readonly
; /* For RAM regions */
135 bool warning_printed
; /* For reservations */
136 bool flush_coalesced_mmio
;
141 QTAILQ_HEAD(subregions
, MemoryRegion
) subregions
;
142 QTAILQ_ENTRY(MemoryRegion
) subregions_link
;
143 QTAILQ_HEAD(coalesced_ranges
, CoalescedMemoryRange
) coalesced
;
145 uint8_t dirty_log_mask
;
146 unsigned ioeventfd_nb
;
147 MemoryRegionIoeventfd
*ioeventfds
;
150 struct MemoryRegionPortio
{
154 IOPortReadFunc
*read
;
155 IOPortWriteFunc
*write
;
158 #define PORTIO_END_OF_LIST() { }
160 typedef struct AddressSpace AddressSpace
;
163 * AddressSpace: describes a mapping of addresses to #MemoryRegion objects
165 struct AddressSpace
{
166 /* All fields are private. */
169 struct FlatView
*current_map
;
171 struct MemoryRegionIoeventfd
*ioeventfds
;
172 struct AddressSpaceDispatch
*dispatch
;
173 QTAILQ_ENTRY(AddressSpace
) address_spaces_link
;
176 typedef struct MemoryRegionSection MemoryRegionSection
;
179 * MemoryRegionSection: describes a fragment of a #MemoryRegion
181 * @mr: the region, or %NULL if empty
182 * @address_space: the address space the region is mapped in
183 * @offset_within_region: the beginning of the section, relative to @mr's start
184 * @size: the size of the section; will not exceed @mr's boundaries
185 * @offset_within_address_space: the address of the first byte of the section
186 * relative to the region's address space
187 * @readonly: writes to this section are ignored
189 struct MemoryRegionSection
{
191 AddressSpace
*address_space
;
192 hwaddr offset_within_region
;
194 hwaddr offset_within_address_space
;
198 typedef struct MemoryListener MemoryListener
;
201 * MemoryListener: callbacks structure for updates to the physical memory map
203 * Allows a component to adjust to changes in the guest-visible memory map.
204 * Use with memory_listener_register() and memory_listener_unregister().
206 struct MemoryListener
{
207 void (*begin
)(MemoryListener
*listener
);
208 void (*commit
)(MemoryListener
*listener
);
209 void (*region_add
)(MemoryListener
*listener
, MemoryRegionSection
*section
);
210 void (*region_del
)(MemoryListener
*listener
, MemoryRegionSection
*section
);
211 void (*region_nop
)(MemoryListener
*listener
, MemoryRegionSection
*section
);
212 void (*log_start
)(MemoryListener
*listener
, MemoryRegionSection
*section
);
213 void (*log_stop
)(MemoryListener
*listener
, MemoryRegionSection
*section
);
214 void (*log_sync
)(MemoryListener
*listener
, MemoryRegionSection
*section
);
215 void (*log_global_start
)(MemoryListener
*listener
);
216 void (*log_global_stop
)(MemoryListener
*listener
);
217 void (*eventfd_add
)(MemoryListener
*listener
, MemoryRegionSection
*section
,
218 bool match_data
, uint64_t data
, EventNotifier
*e
);
219 void (*eventfd_del
)(MemoryListener
*listener
, MemoryRegionSection
*section
,
220 bool match_data
, uint64_t data
, EventNotifier
*e
);
221 void (*coalesced_mmio_add
)(MemoryListener
*listener
, MemoryRegionSection
*section
,
222 hwaddr addr
, hwaddr len
);
223 void (*coalesced_mmio_del
)(MemoryListener
*listener
, MemoryRegionSection
*section
,
224 hwaddr addr
, hwaddr len
);
225 /* Lower = earlier (during add), later (during del) */
227 AddressSpace
*address_space_filter
;
228 QTAILQ_ENTRY(MemoryListener
) link
;
232 * memory_region_init: Initialize a memory region
234 * The region typically acts as a container for other memory regions. Use
235 * memory_region_add_subregion() to add subregions.
237 * @mr: the #MemoryRegion to be initialized
238 * @name: used for debugging; not visible to the user or ABI
239 * @size: size of the region; any subregions beyond this size will be clipped
241 void memory_region_init(MemoryRegion
*mr
,
245 * memory_region_init_io: Initialize an I/O memory region.
247 * Accesses into the region will cause the callbacks in @ops to be called.
248 * if @size is nonzero, subregions will be clipped to @size.
250 * @mr: the #MemoryRegion to be initialized.
251 * @ops: a structure containing read and write callbacks to be used when
252 * I/O is performed on the region.
253 * @opaque: passed to to the read and write callbacks of the @ops structure.
254 * @name: used for debugging; not visible to the user or ABI
255 * @size: size of the region.
257 void memory_region_init_io(MemoryRegion
*mr
,
258 const MemoryRegionOps
*ops
,
264 * memory_region_init_ram: Initialize RAM memory region. Accesses into the
265 * region will modify memory directly.
267 * @mr: the #MemoryRegion to be initialized.
268 * @name: the name of the region.
269 * @size: size of the region.
271 void memory_region_init_ram(MemoryRegion
*mr
,
276 * memory_region_init_ram_ptr: Initialize RAM memory region from a
277 * user-provided pointer. Accesses into the
278 * region will modify memory directly.
280 * @mr: the #MemoryRegion to be initialized.
281 * @name: the name of the region.
282 * @size: size of the region.
283 * @ptr: memory to be mapped; must contain at least @size bytes.
285 void memory_region_init_ram_ptr(MemoryRegion
*mr
,
291 * memory_region_init_alias: Initialize a memory region that aliases all or a
292 * part of another memory region.
294 * @mr: the #MemoryRegion to be initialized.
295 * @name: used for debugging; not visible to the user or ABI
296 * @orig: the region to be referenced; @mr will be equivalent to
297 * @orig between @offset and @offset + @size - 1.
298 * @offset: start of the section in @orig to be referenced.
299 * @size: size of the region.
301 void memory_region_init_alias(MemoryRegion
*mr
,
308 * memory_region_init_rom_device: Initialize a ROM memory region. Writes are
309 * handled via callbacks.
311 * @mr: the #MemoryRegion to be initialized.
312 * @ops: callbacks for write access handling.
313 * @name: the name of the region.
314 * @size: size of the region.
316 void memory_region_init_rom_device(MemoryRegion
*mr
,
317 const MemoryRegionOps
*ops
,
323 * memory_region_init_reservation: Initialize a memory region that reserves
326 * A reservation region primariy serves debugging purposes. It claims I/O
327 * space that is not supposed to be handled by QEMU itself. Any access via
328 * the memory API will cause an abort().
330 * @mr: the #MemoryRegion to be initialized
331 * @name: used for debugging; not visible to the user or ABI
332 * @size: size of the region.
334 void memory_region_init_reservation(MemoryRegion
*mr
,
338 * memory_region_destroy: Destroy a memory region and reclaim all resources.
340 * @mr: the region to be destroyed. May not currently be a subregion
341 * (see memory_region_add_subregion()) or referenced in an alias
342 * (see memory_region_init_alias()).
344 void memory_region_destroy(MemoryRegion
*mr
);
347 * memory_region_size: get a memory region's size.
349 * @mr: the memory region being queried.
351 uint64_t memory_region_size(MemoryRegion
*mr
);
354 * memory_region_is_ram: check whether a memory region is random access
356 * Returns %true is a memory region is random access.
358 * @mr: the memory region being queried
360 bool memory_region_is_ram(MemoryRegion
*mr
);
363 * memory_region_is_romd: check whether a memory region is ROMD
365 * Returns %true is a memory region is ROMD and currently set to allow
368 * @mr: the memory region being queried
370 static inline bool memory_region_is_romd(MemoryRegion
*mr
)
372 return mr
->rom_device
&& mr
->readable
;
376 * memory_region_name: get a memory region's name
378 * Returns the string that was used to initialize the memory region.
380 * @mr: the memory region being queried
382 const char *memory_region_name(MemoryRegion
*mr
);
385 * memory_region_is_logging: return whether a memory region is logging writes
387 * Returns %true if the memory region is logging writes
389 * @mr: the memory region being queried
391 bool memory_region_is_logging(MemoryRegion
*mr
);
394 * memory_region_is_rom: check whether a memory region is ROM
396 * Returns %true is a memory region is read-only memory.
398 * @mr: the memory region being queried
400 bool memory_region_is_rom(MemoryRegion
*mr
);
403 * memory_region_get_ram_ptr: Get a pointer into a RAM memory region.
405 * Returns a host pointer to a RAM memory region (created with
406 * memory_region_init_ram() or memory_region_init_ram_ptr()). Use with
409 * @mr: the memory region being queried.
411 void *memory_region_get_ram_ptr(MemoryRegion
*mr
);
414 * memory_region_set_log: Turn dirty logging on or off for a region.
416 * Turns dirty logging on or off for a specified client (display, migration).
417 * Only meaningful for RAM regions.
419 * @mr: the memory region being updated.
420 * @log: whether dirty logging is to be enabled or disabled.
421 * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or
424 void memory_region_set_log(MemoryRegion
*mr
, bool log
, unsigned client
);
427 * memory_region_get_dirty: Check whether a range of bytes is dirty
428 * for a specified client.
430 * Checks whether a range of bytes has been written to since the last
431 * call to memory_region_reset_dirty() with the same @client. Dirty logging
434 * @mr: the memory region being queried.
435 * @addr: the address (relative to the start of the region) being queried.
436 * @size: the size of the range being queried.
437 * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or
440 bool memory_region_get_dirty(MemoryRegion
*mr
, hwaddr addr
,
441 hwaddr size
, unsigned client
);
444 * memory_region_set_dirty: Mark a range of bytes as dirty in a memory region.
446 * Marks a range of bytes as dirty, after it has been dirtied outside
449 * @mr: the memory region being dirtied.
450 * @addr: the address (relative to the start of the region) being dirtied.
451 * @size: size of the range being dirtied.
453 void memory_region_set_dirty(MemoryRegion
*mr
, hwaddr addr
,
457 * memory_region_test_and_clear_dirty: Check whether a range of bytes is dirty
458 * for a specified client. It clears them.
460 * Checks whether a range of bytes has been written to since the last
461 * call to memory_region_reset_dirty() with the same @client. Dirty logging
464 * @mr: the memory region being queried.
465 * @addr: the address (relative to the start of the region) being queried.
466 * @size: the size of the range being queried.
467 * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or
470 bool memory_region_test_and_clear_dirty(MemoryRegion
*mr
, hwaddr addr
,
471 hwaddr size
, unsigned client
);
473 * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap with
474 * any external TLBs (e.g. kvm)
476 * Flushes dirty information from accelerators such as kvm and vhost-net
477 * and makes it available to users of the memory API.
479 * @mr: the region being flushed.
481 void memory_region_sync_dirty_bitmap(MemoryRegion
*mr
);
484 * memory_region_reset_dirty: Mark a range of pages as clean, for a specified
487 * Marks a range of pages as no longer dirty.
489 * @mr: the region being updated.
490 * @addr: the start of the subrange being cleaned.
491 * @size: the size of the subrange being cleaned.
492 * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or
495 void memory_region_reset_dirty(MemoryRegion
*mr
, hwaddr addr
,
496 hwaddr size
, unsigned client
);
499 * memory_region_set_readonly: Turn a memory region read-only (or read-write)
501 * Allows a memory region to be marked as read-only (turning it into a ROM).
502 * only useful on RAM regions.
504 * @mr: the region being updated.
505 * @readonly: whether rhe region is to be ROM or RAM.
507 void memory_region_set_readonly(MemoryRegion
*mr
, bool readonly
);
510 * memory_region_rom_device_set_readable: enable/disable ROM readability
512 * Allows a ROM device (initialized with memory_region_init_rom_device() to
513 * to be marked as readable (default) or not readable. When it is readable,
514 * the device is mapped to guest memory. When not readable, reads are
515 * forwarded to the #MemoryRegion.read function.
517 * @mr: the memory region to be updated
518 * @readable: whether reads are satisified directly (%true) or via callbacks
521 void memory_region_rom_device_set_readable(MemoryRegion
*mr
, bool readable
);
524 * memory_region_set_coalescing: Enable memory coalescing for the region.
526 * Enabled writes to a region to be queued for later processing. MMIO ->write
527 * callbacks may be delayed until a non-coalesced MMIO is issued.
528 * Only useful for IO regions. Roughly similar to write-combining hardware.
530 * @mr: the memory region to be write coalesced
532 void memory_region_set_coalescing(MemoryRegion
*mr
);
535 * memory_region_add_coalescing: Enable memory coalescing for a sub-range of
538 * Like memory_region_set_coalescing(), but works on a sub-range of a region.
539 * Multiple calls can be issued coalesced disjoint ranges.
541 * @mr: the memory region to be updated.
542 * @offset: the start of the range within the region to be coalesced.
543 * @size: the size of the subrange to be coalesced.
545 void memory_region_add_coalescing(MemoryRegion
*mr
,
550 * memory_region_clear_coalescing: Disable MMIO coalescing for the region.
552 * Disables any coalescing caused by memory_region_set_coalescing() or
553 * memory_region_add_coalescing(). Roughly equivalent to uncacheble memory
556 * @mr: the memory region to be updated.
558 void memory_region_clear_coalescing(MemoryRegion
*mr
);
561 * memory_region_set_flush_coalesced: Enforce memory coalescing flush before
564 * Ensure that pending coalesced MMIO request are flushed before the memory
565 * region is accessed. This property is automatically enabled for all regions
566 * passed to memory_region_set_coalescing() and memory_region_add_coalescing().
568 * @mr: the memory region to be updated.
570 void memory_region_set_flush_coalesced(MemoryRegion
*mr
);
573 * memory_region_clear_flush_coalesced: Disable memory coalescing flush before
576 * Clear the automatic coalesced MMIO flushing enabled via
577 * memory_region_set_flush_coalesced. Note that this service has no effect on
578 * memory regions that have MMIO coalescing enabled for themselves. For them,
579 * automatic flushing will stop once coalescing is disabled.
581 * @mr: the memory region to be updated.
583 void memory_region_clear_flush_coalesced(MemoryRegion
*mr
);
586 * memory_region_add_eventfd: Request an eventfd to be triggered when a word
587 * is written to a location.
589 * Marks a word in an IO region (initialized with memory_region_init_io())
590 * as a trigger for an eventfd event. The I/O callback will not be called.
591 * The caller must be prepared to handle failure (that is, take the required
592 * action if the callback _is_ called).
594 * @mr: the memory region being updated.
595 * @addr: the address within @mr that is to be monitored
596 * @size: the size of the access to trigger the eventfd
597 * @match_data: whether to match against @data, instead of just @addr
598 * @data: the data to match against the guest write
599 * @fd: the eventfd to be triggered when @addr, @size, and @data all match.
601 void memory_region_add_eventfd(MemoryRegion
*mr
,
609 * memory_region_del_eventfd: Cancel an eventfd.
611 * Cancels an eventfd trigger requested by a previous
612 * memory_region_add_eventfd() call.
614 * @mr: the memory region being updated.
615 * @addr: the address within @mr that is to be monitored
616 * @size: the size of the access to trigger the eventfd
617 * @match_data: whether to match against @data, instead of just @addr
618 * @data: the data to match against the guest write
619 * @fd: the eventfd to be triggered when @addr, @size, and @data all match.
621 void memory_region_del_eventfd(MemoryRegion
*mr
,
629 * memory_region_add_subregion: Add a subregion to a container.
631 * Adds a subregion at @offset. The subregion may not overlap with other
632 * subregions (except for those explicitly marked as overlapping). A region
633 * may only be added once as a subregion (unless removed with
634 * memory_region_del_subregion()); use memory_region_init_alias() if you
635 * want a region to be a subregion in multiple locations.
637 * @mr: the region to contain the new subregion; must be a container
638 * initialized with memory_region_init().
639 * @offset: the offset relative to @mr where @subregion is added.
640 * @subregion: the subregion to be added.
642 void memory_region_add_subregion(MemoryRegion
*mr
,
644 MemoryRegion
*subregion
);
646 * memory_region_add_subregion_overlap: Add a subregion to a container
649 * Adds a subregion at @offset. The subregion may overlap with other
650 * subregions. Conflicts are resolved by having a higher @priority hide a
651 * lower @priority. Subregions without priority are taken as @priority 0.
652 * A region may only be added once as a subregion (unless removed with
653 * memory_region_del_subregion()); use memory_region_init_alias() if you
654 * want a region to be a subregion in multiple locations.
656 * @mr: the region to contain the new subregion; must be a container
657 * initialized with memory_region_init().
658 * @offset: the offset relative to @mr where @subregion is added.
659 * @subregion: the subregion to be added.
660 * @priority: used for resolving overlaps; highest priority wins.
662 void memory_region_add_subregion_overlap(MemoryRegion
*mr
,
664 MemoryRegion
*subregion
,
668 * memory_region_get_ram_addr: Get the ram address associated with a memory
671 * DO NOT USE THIS FUNCTION. This is a temporary workaround while the Xen
672 * code is being reworked.
674 ram_addr_t
memory_region_get_ram_addr(MemoryRegion
*mr
);
677 * memory_region_del_subregion: Remove a subregion.
679 * Removes a subregion from its container.
681 * @mr: the container to be updated.
682 * @subregion: the region being removed; must be a current subregion of @mr.
684 void memory_region_del_subregion(MemoryRegion
*mr
,
685 MemoryRegion
*subregion
);
688 * memory_region_set_enabled: dynamically enable or disable a region
690 * Enables or disables a memory region. A disabled memory region
691 * ignores all accesses to itself and its subregions. It does not
692 * obscure sibling subregions with lower priority - it simply behaves as
693 * if it was removed from the hierarchy.
695 * Regions default to being enabled.
697 * @mr: the region to be updated
698 * @enabled: whether to enable or disable the region
700 void memory_region_set_enabled(MemoryRegion
*mr
, bool enabled
);
703 * memory_region_set_address: dynamically update the address of a region
705 * Dynamically updates the address of a region, relative to its parent.
706 * May be used on regions are currently part of a memory hierarchy.
708 * @mr: the region to be updated
709 * @addr: new address, relative to parent region
711 void memory_region_set_address(MemoryRegion
*mr
, hwaddr addr
);
714 * memory_region_set_alias_offset: dynamically update a memory alias's offset
716 * Dynamically updates the offset into the target region that an alias points
717 * to, as if the fourth argument to memory_region_init_alias() has changed.
719 * @mr: the #MemoryRegion to be updated; should be an alias.
720 * @offset: the new offset into the target memory region
722 void memory_region_set_alias_offset(MemoryRegion
*mr
,
726 * memory_region_find: locate a MemoryRegion in an address space
728 * Locates the first #MemoryRegion within an address space given by
729 * @address_space that overlaps the range given by @addr and @size.
731 * Returns a #MemoryRegionSection that describes a contiguous overlap.
732 * It will have the following characteristics:
733 * .@offset_within_address_space >= @addr
734 * .@offset_within_address_space + .@size <= @addr + @size
735 * .@size = 0 iff no overlap was found
736 * .@mr is non-%NULL iff an overlap was found
738 * @address_space: a top-level (i.e. parentless) region that contains
739 * the region to be found
740 * @addr: start of the area within @address_space to be searched
741 * @size: size of the area to be searched
743 MemoryRegionSection
memory_region_find(MemoryRegion
*address_space
,
744 hwaddr addr
, uint64_t size
);
747 * memory_region_section_addr: get offset within MemoryRegionSection
749 * Returns offset within MemoryRegionSection
751 * @section: the memory region section being queried
752 * @addr: address in address space
755 memory_region_section_addr(MemoryRegionSection
*section
,
758 addr
-= section
->offset_within_address_space
;
759 addr
+= section
->offset_within_region
;
764 * memory_global_sync_dirty_bitmap: synchronize the dirty log for all memory
766 * Synchronizes the dirty page log for an entire address space.
767 * @address_space: a top-level (i.e. parentless) region that contains the
768 * memory being synchronized
770 void memory_global_sync_dirty_bitmap(MemoryRegion
*address_space
);
773 * memory_region_transaction_begin: Start a transaction.
775 * During a transaction, changes will be accumulated and made visible
776 * only when the transaction ends (is committed).
778 void memory_region_transaction_begin(void);
781 * memory_region_transaction_commit: Commit a transaction and make changes
782 * visible to the guest.
784 void memory_region_transaction_commit(void);
787 * memory_listener_register: register callbacks to be called when memory
788 * sections are mapped or unmapped into an address
791 * @listener: an object containing the callbacks to be called
792 * @filter: if non-%NULL, only regions in this address space will be observed
794 void memory_listener_register(MemoryListener
*listener
, AddressSpace
*filter
);
797 * memory_listener_unregister: undo the effect of memory_listener_register()
799 * @listener: an object containing the callbacks to be removed
801 void memory_listener_unregister(MemoryListener
*listener
);
804 * memory_global_dirty_log_start: begin dirty logging for all regions
806 void memory_global_dirty_log_start(void);
809 * memory_global_dirty_log_stop: end dirty logging for all regions
811 void memory_global_dirty_log_stop(void);
813 void mtree_info(fprintf_function mon_printf
, void *f
);
816 * address_space_init: initializes an address space
818 * @as: an uninitialized #AddressSpace
819 * @root: a #MemoryRegion that routes addesses for the address space
821 void address_space_init(AddressSpace
*as
, MemoryRegion
*root
);
825 * address_space_destroy: destroy an address space
827 * Releases all resources associated with an address space. After an address space
828 * is destroyed, its root memory region (given by address_space_init()) may be destroyed
831 * @as: address space to be destroyed
833 void address_space_destroy(AddressSpace
*as
);
836 * address_space_rw: read from or write to an address space.
838 * @as: #AddressSpace to be accessed
839 * @addr: address within that address space
840 * @buf: buffer with the data transferred
841 * @is_write: indicates the transfer direction
843 void address_space_rw(AddressSpace
*as
, hwaddr addr
, uint8_t *buf
,
844 int len
, bool is_write
);
847 * address_space_write: write to address space.
849 * @as: #AddressSpace to be accessed
850 * @addr: address within that address space
851 * @buf: buffer with the data transferred
853 void address_space_write(AddressSpace
*as
, hwaddr addr
,
854 const uint8_t *buf
, int len
);
857 * address_space_read: read from an address space.
859 * @as: #AddressSpace to be accessed
860 * @addr: address within that address space
861 * @buf: buffer with the data transferred
863 void address_space_read(AddressSpace
*as
, hwaddr addr
, uint8_t *buf
, int len
);
865 /* address_space_map: map a physical memory region into a host virtual address
867 * May map a subset of the requested range, given by and returned in @plen.
868 * May return %NULL if resources needed to perform the mapping are exhausted.
869 * Use only for reads OR writes - not for read-modify-write operations.
870 * Use cpu_register_map_client() to know when retrying the map operation is
873 * @as: #AddressSpace to be accessed
874 * @addr: address within that address space
875 * @plen: pointer to length of buffer; updated on return
876 * @is_write: indicates the transfer direction
878 void *address_space_map(AddressSpace
*as
, hwaddr addr
,
879 hwaddr
*plen
, bool is_write
);
881 /* address_space_unmap: Unmaps a memory region previously mapped by address_space_map()
883 * Will also mark the memory as dirty if @is_write == %true. @access_len gives
884 * the amount of memory that was actually read or written by the caller.
886 * @as: #AddressSpace used
887 * @addr: address within that address space
888 * @len: buffer length as returned by address_space_map()
889 * @access_len: amount of data actually transferred
890 * @is_write: indicates the transfer direction
892 void address_space_unmap(AddressSpace
*as
, void *buffer
, hwaddr len
,
893 int is_write
, hwaddr access_len
);