]>
Commit | Line | Data |
---|---|---|
80167a8a WC |
1 | /* |
2 | * QEMU memory mapping | |
3 | * | |
4 | * Copyright Fujitsu, Corp. 2011, 2012 | |
5 | * | |
6 | * Authors: | |
7 | * Wen Congyang <wency@cn.fujitsu.com> | |
8 | * | |
fc0608ac SW |
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. | |
80167a8a WC |
11 | * |
12 | */ | |
13 | ||
14 | #ifndef MEMORY_MAPPING_H | |
15 | #define MEMORY_MAPPING_H | |
16 | ||
1de7afc9 | 17 | #include "qemu/queue.h" |
ec150c7e | 18 | #include "exec/cpu-defs.h" |
1fbeff72 | 19 | #include "exec/memory.h" |
80167a8a | 20 | |
5ee163e8 LE |
21 | typedef struct GuestPhysBlock { |
22 | /* visible to guest, reflects PCI hole, etc */ | |
23 | hwaddr target_start; | |
24 | ||
25 | /* implies size */ | |
26 | hwaddr target_end; | |
27 | ||
28 | /* points into host memory */ | |
29 | uint8_t *host_addr; | |
30 | ||
1fbeff72 PX |
31 | /* points to the MemoryRegion that this block belongs to */ |
32 | MemoryRegion *mr; | |
33 | ||
5ee163e8 LE |
34 | QTAILQ_ENTRY(GuestPhysBlock) next; |
35 | } GuestPhysBlock; | |
36 | ||
37 | /* point-in-time snapshot of guest-visible physical mappings */ | |
38 | typedef struct GuestPhysBlockList { | |
39 | unsigned num; | |
eae3eb3e | 40 | QTAILQ_HEAD(, GuestPhysBlock) head; |
5ee163e8 LE |
41 | } GuestPhysBlockList; |
42 | ||
80167a8a WC |
43 | /* The physical and virtual address in the memory mapping are contiguous. */ |
44 | typedef struct MemoryMapping { | |
a8170e5e | 45 | hwaddr phys_addr; |
80167a8a WC |
46 | target_ulong virt_addr; |
47 | ram_addr_t length; | |
48 | QTAILQ_ENTRY(MemoryMapping) next; | |
49 | } MemoryMapping; | |
50 | ||
6d4d3ae7 | 51 | struct MemoryMappingList { |
80167a8a WC |
52 | unsigned int num; |
53 | MemoryMapping *last_mapping; | |
54 | QTAILQ_HEAD(, MemoryMapping) head; | |
6d4d3ae7 | 55 | }; |
80167a8a WC |
56 | |
57 | /* | |
58 | * add or merge the memory region [phys_addr, phys_addr + length) into the | |
59 | * memory mapping's list. The region's virtual address starts with virt_addr, | |
60 | * and is contiguous. The list is sorted by phys_addr. | |
61 | */ | |
62 | void memory_mapping_list_add_merge_sorted(MemoryMappingList *list, | |
a8170e5e AK |
63 | hwaddr phys_addr, |
64 | hwaddr virt_addr, | |
80167a8a WC |
65 | ram_addr_t length); |
66 | ||
67 | void memory_mapping_list_free(MemoryMappingList *list); | |
68 | ||
69 | void memory_mapping_list_init(MemoryMappingList *list); | |
70 | ||
5ee163e8 LE |
71 | void guest_phys_blocks_free(GuestPhysBlockList *list); |
72 | void guest_phys_blocks_init(GuestPhysBlockList *list); | |
c5d7f60f | 73 | void guest_phys_blocks_append(GuestPhysBlockList *list); |
5ee163e8 | 74 | |
56c4bfb3 LE |
75 | void qemu_get_guest_memory_mapping(MemoryMappingList *list, |
76 | const GuestPhysBlockList *guest_phys_blocks, | |
77 | Error **errp); | |
c517076d | 78 | |
2b05ab52 | 79 | /* get guest's memory mapping without do paging(virtual address is 0). */ |
56c4bfb3 LE |
80 | void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list, |
81 | const GuestPhysBlockList *guest_phys_blocks); | |
2b05ab52 | 82 | |
783e9b48 WC |
83 | void memory_mapping_filter(MemoryMappingList *list, int64_t begin, |
84 | int64_t length); | |
85 | ||
80167a8a | 86 | #endif |