mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
memory: add API for observing updates to the physical memory map
Add an API that allows a client to observe changes in the global memory map: - region added (possibly with logging enabled) - region removed (possibly with logging enabled) - logging started on a region - logging stopped on a region - global logging started - global logging removed This API will eventually replace cpu_register_physical_memory_client(). Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
86e775c654
commit
7664e80c84
3 changed files with 145 additions and 0 deletions
47
memory.h
47
memory.h
|
@ -154,6 +154,7 @@ typedef struct MemoryRegionSection MemoryRegionSection;
|
|||
* MemoryRegionSection: describes a fragment of a #MemoryRegion
|
||||
*
|
||||
* @mr: the region, or %NULL if empty
|
||||
* @address_space: the address space the region is mapped in
|
||||
* @offset_within_region: the beginning of the section, relative to @mr's start
|
||||
* @size: the size of the section; will not exceed @mr's boundaries
|
||||
* @offset_within_address_space: the address of the first byte of the section
|
||||
|
@ -161,11 +162,31 @@ typedef struct MemoryRegionSection MemoryRegionSection;
|
|||
*/
|
||||
struct MemoryRegionSection {
|
||||
MemoryRegion *mr;
|
||||
MemoryRegion *address_space;
|
||||
target_phys_addr_t offset_within_region;
|
||||
uint64_t size;
|
||||
target_phys_addr_t offset_within_address_space;
|
||||
};
|
||||
|
||||
typedef struct MemoryListener MemoryListener;
|
||||
|
||||
/**
|
||||
* MemoryListener: callbacks structure for updates to the physical memory map
|
||||
*
|
||||
* Allows a component to adjust to changes in the guest-visible memory map.
|
||||
* Use with memory_listener_register() and memory_listener_unregister().
|
||||
*/
|
||||
struct MemoryListener {
|
||||
void (*region_add)(MemoryListener *listener, MemoryRegionSection *section);
|
||||
void (*region_del)(MemoryListener *listener, MemoryRegionSection *section);
|
||||
void (*log_start)(MemoryListener *listener, MemoryRegionSection *section);
|
||||
void (*log_stop)(MemoryListener *listener, MemoryRegionSection *section);
|
||||
void (*log_sync)(MemoryListener *listener, MemoryRegionSection *section);
|
||||
void (*log_global_start)(MemoryListener *listener);
|
||||
void (*log_global_stop)(MemoryListener *listener);
|
||||
QLIST_ENTRY(MemoryListener) link;
|
||||
};
|
||||
|
||||
/**
|
||||
* memory_region_init: Initialize a memory region
|
||||
*
|
||||
|
@ -631,6 +652,32 @@ void memory_region_transaction_begin(void);
|
|||
*/
|
||||
void memory_region_transaction_commit(void);
|
||||
|
||||
/**
|
||||
* memory_listener_register: register callbacks to be called when memory
|
||||
* sections are mapped or unmapped into an address
|
||||
* space
|
||||
*
|
||||
* @listener: an object containing the callbacks to be called
|
||||
*/
|
||||
void memory_listener_register(MemoryListener *listener);
|
||||
|
||||
/**
|
||||
* memory_listener_unregister: undo the effect of memory_listener_register()
|
||||
*
|
||||
* @listener: an object containing the callbacks to be removed
|
||||
*/
|
||||
void memory_listener_unregister(MemoryListener *listener);
|
||||
|
||||
/**
|
||||
* memory_global_dirty_log_start: begin dirty logging for all regions
|
||||
*/
|
||||
void memory_global_dirty_log_start(void);
|
||||
|
||||
/**
|
||||
* memory_global_dirty_log_stop: begin dirty logging for all regions
|
||||
*/
|
||||
void memory_global_dirty_log_stop(void);
|
||||
|
||||
void mtree_info(fprintf_function mon_printf, void *f);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue