2012-05-07 06:03:46 +02:00
|
|
|
/*
|
|
|
|
* QEMU memory mapping
|
|
|
|
*
|
|
|
|
* Copyright Fujitsu, Corp. 2011, 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Wen Congyang <wency@cn.fujitsu.com>
|
|
|
|
*
|
2012-06-10 21:49:18 +02:00
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
2012-05-07 06:03:46 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MEMORY_MAPPING_H
|
|
|
|
#define MEMORY_MAPPING_H
|
|
|
|
|
|
|
|
#include "qemu-queue.h"
|
|
|
|
|
|
|
|
/* The physical and virtual address in the memory mapping are contiguous. */
|
|
|
|
typedef struct MemoryMapping {
|
2012-10-23 12:30:10 +02:00
|
|
|
hwaddr phys_addr;
|
2012-05-07 06:03:46 +02:00
|
|
|
target_ulong virt_addr;
|
|
|
|
ram_addr_t length;
|
|
|
|
QTAILQ_ENTRY(MemoryMapping) next;
|
|
|
|
} MemoryMapping;
|
|
|
|
|
|
|
|
typedef struct MemoryMappingList {
|
|
|
|
unsigned int num;
|
|
|
|
MemoryMapping *last_mapping;
|
|
|
|
QTAILQ_HEAD(, MemoryMapping) head;
|
|
|
|
} MemoryMappingList;
|
|
|
|
|
2012-06-07 08:22:56 +02:00
|
|
|
int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
|
|
|
|
bool cpu_paging_enabled(CPUArchState *env);
|
|
|
|
|
2012-05-07 06:03:46 +02:00
|
|
|
/*
|
|
|
|
* add or merge the memory region [phys_addr, phys_addr + length) into the
|
|
|
|
* memory mapping's list. The region's virtual address starts with virt_addr,
|
|
|
|
* and is contiguous. The list is sorted by phys_addr.
|
|
|
|
*/
|
|
|
|
void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
|
2012-10-23 12:30:10 +02:00
|
|
|
hwaddr phys_addr,
|
|
|
|
hwaddr virt_addr,
|
2012-05-07 06:03:46 +02:00
|
|
|
ram_addr_t length);
|
|
|
|
|
|
|
|
void memory_mapping_list_free(MemoryMappingList *list);
|
|
|
|
|
|
|
|
void memory_mapping_list_init(MemoryMappingList *list);
|
|
|
|
|
2012-05-07 06:06:40 +02:00
|
|
|
/*
|
|
|
|
* Return value:
|
|
|
|
* 0: success
|
|
|
|
* -1: failed
|
|
|
|
* -2: unsupported
|
|
|
|
*/
|
|
|
|
int qemu_get_guest_memory_mapping(MemoryMappingList *list);
|
|
|
|
|
2012-05-07 06:07:07 +02:00
|
|
|
/* get guest's memory mapping without do paging(virtual address is 0). */
|
|
|
|
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);
|
|
|
|
|
2012-05-07 06:10:47 +02:00
|
|
|
void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
|
|
|
|
int64_t length);
|
|
|
|
|
2012-05-07 06:03:46 +02:00
|
|
|
#endif
|