Wen Congyang | 80167a8 | 2012-05-07 12:03:46 +0800 | [diff] [blame] | 1 | /* |
| 2 | * QEMU memory mapping |
| 3 | * |
| 4 | * Copyright Fujitsu, Corp. 2011, 2012 |
| 5 | * |
| 6 | * Authors: |
| 7 | * Wen Congyang <wency@cn.fujitsu.com> |
| 8 | * |
Stefan Weil | fc0608a | 2012-06-10 19:49:18 +0000 | [diff] [blame] | 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. |
Wen Congyang | 80167a8 | 2012-05-07 12:03:46 +0800 | [diff] [blame] | 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef MEMORY_MAPPING_H |
| 15 | #define MEMORY_MAPPING_H |
| 16 | |
| 17 | #include "qemu-queue.h" |
| 18 | |
| 19 | /* The physical and virtual address in the memory mapping are contiguous. */ |
| 20 | typedef struct MemoryMapping { |
| 21 | target_phys_addr_t phys_addr; |
| 22 | target_ulong virt_addr; |
| 23 | ram_addr_t length; |
| 24 | QTAILQ_ENTRY(MemoryMapping) next; |
| 25 | } MemoryMapping; |
| 26 | |
| 27 | typedef struct MemoryMappingList { |
| 28 | unsigned int num; |
| 29 | MemoryMapping *last_mapping; |
| 30 | QTAILQ_HEAD(, MemoryMapping) head; |
| 31 | } MemoryMappingList; |
| 32 | |
Paolo Bonzini | 5f86146 | 2012-06-07 08:22:56 +0200 | [diff] [blame] | 33 | int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); |
| 34 | bool cpu_paging_enabled(CPUArchState *env); |
| 35 | |
Wen Congyang | 80167a8 | 2012-05-07 12:03:46 +0800 | [diff] [blame] | 36 | /* |
| 37 | * add or merge the memory region [phys_addr, phys_addr + length) into the |
| 38 | * memory mapping's list. The region's virtual address starts with virt_addr, |
| 39 | * and is contiguous. The list is sorted by phys_addr. |
| 40 | */ |
| 41 | void memory_mapping_list_add_merge_sorted(MemoryMappingList *list, |
| 42 | target_phys_addr_t phys_addr, |
| 43 | target_phys_addr_t virt_addr, |
| 44 | ram_addr_t length); |
| 45 | |
| 46 | void memory_mapping_list_free(MemoryMappingList *list); |
| 47 | |
| 48 | void memory_mapping_list_init(MemoryMappingList *list); |
| 49 | |
Wen Congyang | c517076 | 2012-05-07 12:06:40 +0800 | [diff] [blame] | 50 | /* |
| 51 | * Return value: |
| 52 | * 0: success |
| 53 | * -1: failed |
| 54 | * -2: unsupported |
| 55 | */ |
Wen Congyang | c517076 | 2012-05-07 12:06:40 +0800 | [diff] [blame] | 56 | int qemu_get_guest_memory_mapping(MemoryMappingList *list); |
Wen Congyang | c517076 | 2012-05-07 12:06:40 +0800 | [diff] [blame] | 57 | |
Wen Congyang | 2b05ab5 | 2012-05-07 12:07:07 +0800 | [diff] [blame] | 58 | /* get guest's memory mapping without do paging(virtual address is 0). */ |
| 59 | void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); |
| 60 | |
Wen Congyang | 783e9b4 | 2012-05-07 12:10:47 +0800 | [diff] [blame] | 61 | void memory_mapping_filter(MemoryMappingList *list, int64_t begin, |
| 62 | int64_t length); |
| 63 | |
Wen Congyang | 80167a8 | 2012-05-07 12:03:46 +0800 | [diff] [blame] | 64 | #endif |