4 * Copyright Fujitsu, Corp. 2011, 2012
7 * Wen Congyang <wency@cn.fujitsu.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
14 #ifndef MEMORY_MAPPING_H
15 #define MEMORY_MAPPING_H
17 #include "qemu/queue.h"
18 #include "qemu/typedefs.h"
20 typedef struct GuestPhysBlock
{
21 /* visible to guest, reflects PCI hole, etc */
27 /* points into host memory */
30 QTAILQ_ENTRY(GuestPhysBlock
) next
;
33 /* point-in-time snapshot of guest-visible physical mappings */
34 typedef struct GuestPhysBlockList
{
36 QTAILQ_HEAD(GuestPhysBlockHead
, GuestPhysBlock
) head
;
39 /* The physical and virtual address in the memory mapping are contiguous. */
40 typedef struct MemoryMapping
{
42 target_ulong virt_addr
;
44 QTAILQ_ENTRY(MemoryMapping
) next
;
47 struct MemoryMappingList
{
49 MemoryMapping
*last_mapping
;
50 QTAILQ_HEAD(, MemoryMapping
) head
;
54 * add or merge the memory region [phys_addr, phys_addr + length) into the
55 * memory mapping's list. The region's virtual address starts with virt_addr,
56 * and is contiguous. The list is sorted by phys_addr.
58 void memory_mapping_list_add_merge_sorted(MemoryMappingList
*list
,
63 void memory_mapping_list_free(MemoryMappingList
*list
);
65 void memory_mapping_list_init(MemoryMappingList
*list
);
67 void guest_phys_blocks_free(GuestPhysBlockList
*list
);
68 void guest_phys_blocks_init(GuestPhysBlockList
*list
);
69 void guest_phys_blocks_append(GuestPhysBlockList
*list
);
71 void qemu_get_guest_memory_mapping(MemoryMappingList
*list
,
72 const GuestPhysBlockList
*guest_phys_blocks
,
75 /* get guest's memory mapping without do paging(virtual address is 0). */
76 void qemu_get_guest_simple_memory_mapping(MemoryMappingList
*list
,
77 const GuestPhysBlockList
*guest_phys_blocks
);
79 void memory_mapping_filter(MemoryMappingList
*list
, int64_t begin
,