]> git.proxmox.com Git - qemu.git/blame - memory_mapping.h
introduce a new monitor command 'dump-guest-memory' to dump guest's memory
[qemu.git] / 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 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef MEMORY_MAPPING_H
15#define MEMORY_MAPPING_H
16
17#include "qemu-queue.h"
18
fae001f5 19#ifndef CONFIG_USER_ONLY
80167a8a
WC
20/* The physical and virtual address in the memory mapping are contiguous. */
21typedef struct MemoryMapping {
22 target_phys_addr_t phys_addr;
23 target_ulong virt_addr;
24 ram_addr_t length;
25 QTAILQ_ENTRY(MemoryMapping) next;
26} MemoryMapping;
27
28typedef struct MemoryMappingList {
29 unsigned int num;
30 MemoryMapping *last_mapping;
31 QTAILQ_HEAD(, MemoryMapping) head;
32} MemoryMappingList;
33
34/*
35 * add or merge the memory region [phys_addr, phys_addr + length) into the
36 * memory mapping's list. The region's virtual address starts with virt_addr,
37 * and is contiguous. The list is sorted by phys_addr.
38 */
39void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
40 target_phys_addr_t phys_addr,
41 target_phys_addr_t virt_addr,
42 ram_addr_t length);
43
44void memory_mapping_list_free(MemoryMappingList *list);
45
46void memory_mapping_list_init(MemoryMappingList *list);
47
c517076d
WC
48/*
49 * Return value:
50 * 0: success
51 * -1: failed
52 * -2: unsupported
53 */
54#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING)
55int qemu_get_guest_memory_mapping(MemoryMappingList *list);
56#else
57static inline int qemu_get_guest_memory_mapping(MemoryMappingList *list)
58{
59 return -2;
60}
61#endif
62
2b05ab52
WC
63/* get guest's memory mapping without do paging(virtual address is 0). */
64void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);
65
783e9b48
WC
66void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
67 int64_t length);
68
fae001f5
WC
69#else
70
71/* We use MemoryMappingList* in cpu-all.h */
72typedef struct MemoryMappingList MemoryMappingList;
73#endif
80167a8a 74#endif