2
0

memory_mapping.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 or later.
  10. * See the COPYING file in the top-level directory.
  11. *
  12. */
  13. #ifndef MEMORY_MAPPING_H
  14. #define MEMORY_MAPPING_H
  15. #include "qemu-queue.h"
  16. /* The physical and virtual address in the memory mapping are contiguous. */
  17. typedef struct MemoryMapping {
  18. target_phys_addr_t phys_addr;
  19. target_ulong virt_addr;
  20. ram_addr_t length;
  21. QTAILQ_ENTRY(MemoryMapping) next;
  22. } MemoryMapping;
  23. typedef struct MemoryMappingList {
  24. unsigned int num;
  25. MemoryMapping *last_mapping;
  26. QTAILQ_HEAD(, MemoryMapping) head;
  27. } MemoryMappingList;
  28. int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
  29. bool cpu_paging_enabled(CPUArchState *env);
  30. /*
  31. * add or merge the memory region [phys_addr, phys_addr + length) into the
  32. * memory mapping's list. The region's virtual address starts with virt_addr,
  33. * and is contiguous. The list is sorted by phys_addr.
  34. */
  35. void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
  36. target_phys_addr_t phys_addr,
  37. target_phys_addr_t virt_addr,
  38. ram_addr_t length);
  39. void memory_mapping_list_free(MemoryMappingList *list);
  40. void memory_mapping_list_init(MemoryMappingList *list);
  41. /*
  42. * Return value:
  43. * 0: success
  44. * -1: failed
  45. * -2: unsupported
  46. */
  47. int qemu_get_guest_memory_mapping(MemoryMappingList *list);
  48. /* get guest's memory mapping without do paging(virtual address is 0). */
  49. void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);
  50. void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
  51. int64_t length);
  52. #endif