2012-05-07 08:03:46 +04:00
|
|
|
/*
|
|
|
|
* QEMU memory mapping
|
|
|
|
*
|
|
|
|
* Copyright Fujitsu, Corp. 2011, 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Wen Congyang <wency@cn.fujitsu.com>
|
|
|
|
*
|
2012-06-10 23:49:18 +04:00
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
2012-05-07 08:03:46 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MEMORY_MAPPING_H
|
|
|
|
#define MEMORY_MAPPING_H
|
|
|
|
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/queue.h"
|
2021-05-16 20:59:38 +03:00
|
|
|
#include "exec/cpu-common.h"
|
2012-05-07 08:03:46 +04:00
|
|
|
|
2013-08-06 14:37:09 +04:00
|
|
|
typedef struct GuestPhysBlock {
|
|
|
|
/* visible to guest, reflects PCI hole, etc */
|
|
|
|
hwaddr target_start;
|
|
|
|
|
|
|
|
/* implies size */
|
|
|
|
hwaddr target_end;
|
|
|
|
|
|
|
|
/* points into host memory */
|
|
|
|
uint8_t *host_addr;
|
|
|
|
|
2016-02-18 08:16:52 +03:00
|
|
|
/* points to the MemoryRegion that this block belongs to */
|
|
|
|
MemoryRegion *mr;
|
|
|
|
|
2013-08-06 14:37:09 +04:00
|
|
|
QTAILQ_ENTRY(GuestPhysBlock) next;
|
|
|
|
} GuestPhysBlock;
|
|
|
|
|
|
|
|
/* point-in-time snapshot of guest-visible physical mappings */
|
|
|
|
typedef struct GuestPhysBlockList {
|
|
|
|
unsigned num;
|
2018-12-06 15:10:34 +03:00
|
|
|
QTAILQ_HEAD(, GuestPhysBlock) head;
|
2013-08-06 14:37:09 +04:00
|
|
|
} GuestPhysBlockList;
|
|
|
|
|
2012-05-07 08:03:46 +04:00
|
|
|
/* The physical and virtual address in the memory mapping are contiguous. */
|
|
|
|
typedef struct MemoryMapping {
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr phys_addr;
|
2021-05-16 20:59:38 +03:00
|
|
|
vaddr virt_addr;
|
2012-05-07 08:03:46 +04:00
|
|
|
ram_addr_t length;
|
|
|
|
QTAILQ_ENTRY(MemoryMapping) next;
|
|
|
|
} MemoryMapping;
|
|
|
|
|
2013-05-28 16:20:15 +04:00
|
|
|
struct MemoryMappingList {
|
2012-05-07 08:03:46 +04:00
|
|
|
unsigned int num;
|
|
|
|
MemoryMapping *last_mapping;
|
|
|
|
QTAILQ_HEAD(, MemoryMapping) head;
|
2013-05-28 16:20:15 +04:00
|
|
|
};
|
2012-05-07 08:03:46 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* add or merge the memory region [phys_addr, phys_addr + length) into the
|
|
|
|
* memory mapping's list. The region's virtual address starts with virt_addr,
|
|
|
|
* and is contiguous. The list is sorted by phys_addr.
|
|
|
|
*/
|
|
|
|
void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr phys_addr,
|
|
|
|
hwaddr virt_addr,
|
2012-05-07 08:03:46 +04:00
|
|
|
ram_addr_t length);
|
|
|
|
|
|
|
|
void memory_mapping_list_free(MemoryMappingList *list);
|
|
|
|
|
|
|
|
void memory_mapping_list_init(MemoryMappingList *list);
|
|
|
|
|
2013-08-06 14:37:09 +04:00
|
|
|
void guest_phys_blocks_free(GuestPhysBlockList *list);
|
|
|
|
void guest_phys_blocks_init(GuestPhysBlockList *list);
|
2013-08-06 14:37:10 +04:00
|
|
|
void guest_phys_blocks_append(GuestPhysBlockList *list);
|
2013-08-06 14:37:09 +04:00
|
|
|
|
2013-08-06 14:37:11 +04:00
|
|
|
void qemu_get_guest_memory_mapping(MemoryMappingList *list,
|
|
|
|
const GuestPhysBlockList *guest_phys_blocks,
|
|
|
|
Error **errp);
|
2012-05-07 08:06:40 +04:00
|
|
|
|
2012-05-07 08:07:07 +04:00
|
|
|
/* get guest's memory mapping without do paging(virtual address is 0). */
|
2013-08-06 14:37:11 +04:00
|
|
|
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
|
|
|
|
const GuestPhysBlockList *guest_phys_blocks);
|
2012-05-07 08:07:07 +04:00
|
|
|
|
2012-05-07 08:10:47 +04:00
|
|
|
void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
|
|
|
|
int64_t length);
|
|
|
|
|
2012-05-07 08:03:46 +04:00
|
|
|
#endif
|