]> git.proxmox.com Git - qemu.git/blame - include/sysemu/memory_mapping.h
Merge remote-tracking branch 'bonzini/scsi-next' into staging
[qemu.git] / include / sysemu / memory_mapping.h
CommitLineData
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"
6d4d3ae7 18#include "qemu/typedefs.h"
80167a8a 19
5ee163e8
LE
20typedef struct GuestPhysBlock {
21 /* visible to guest, reflects PCI hole, etc */
22 hwaddr target_start;
23
24 /* implies size */
25 hwaddr target_end;
26
27 /* points into host memory */
28 uint8_t *host_addr;
29
30 QTAILQ_ENTRY(GuestPhysBlock) next;
31} GuestPhysBlock;
32
33/* point-in-time snapshot of guest-visible physical mappings */
34typedef struct GuestPhysBlockList {
35 unsigned num;
36 QTAILQ_HEAD(GuestPhysBlockHead, GuestPhysBlock) head;
37} GuestPhysBlockList;
38
80167a8a
WC
39/* The physical and virtual address in the memory mapping are contiguous. */
40typedef struct MemoryMapping {
a8170e5e 41 hwaddr phys_addr;
80167a8a
WC
42 target_ulong virt_addr;
43 ram_addr_t length;
44 QTAILQ_ENTRY(MemoryMapping) next;
45} MemoryMapping;
46
6d4d3ae7 47struct MemoryMappingList {
80167a8a
WC
48 unsigned int num;
49 MemoryMapping *last_mapping;
50 QTAILQ_HEAD(, MemoryMapping) head;
6d4d3ae7 51};
80167a8a
WC
52
53/*
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.
57 */
58void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
a8170e5e
AK
59 hwaddr phys_addr,
60 hwaddr virt_addr,
80167a8a
WC
61 ram_addr_t length);
62
63void memory_mapping_list_free(MemoryMappingList *list);
64
65void memory_mapping_list_init(MemoryMappingList *list);
66
5ee163e8
LE
67void guest_phys_blocks_free(GuestPhysBlockList *list);
68void guest_phys_blocks_init(GuestPhysBlockList *list);
c5d7f60f 69void guest_phys_blocks_append(GuestPhysBlockList *list);
5ee163e8 70
56c4bfb3
LE
71void qemu_get_guest_memory_mapping(MemoryMappingList *list,
72 const GuestPhysBlockList *guest_phys_blocks,
73 Error **errp);
c517076d 74
2b05ab52 75/* get guest's memory mapping without do paging(virtual address is 0). */
56c4bfb3
LE
76void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
77 const GuestPhysBlockList *guest_phys_blocks);
2b05ab52 78
783e9b48
WC
79void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
80 int64_t length);
81
80167a8a 82#endif