exec-obsolete.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Declarations for obsolete exec.c functions
  3. *
  4. * Copyright 2011 Red Hat, Inc. and/or its affiliates
  5. *
  6. * Authors:
  7. * Avi Kivity <avi@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or
  10. * later. See the COPYING file in the top-level directory.
  11. *
  12. */
  13. /*
  14. * This header is for use by exec.c and memory.c ONLY. Do not include it.
  15. * The functions declared here will be removed soon.
  16. */
  17. #ifndef EXEC_OBSOLETE_H
  18. #define EXEC_OBSOLETE_H
  19. #ifndef WANT_EXEC_OBSOLETE
  20. #error Do not include exec-obsolete.h
  21. #endif
  22. #ifndef CONFIG_USER_ONLY
  23. ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
  24. MemoryRegion *mr);
  25. ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
  26. void qemu_ram_free(ram_addr_t addr);
  27. void qemu_ram_free_from_ptr(ram_addr_t addr);
  28. struct MemoryRegion;
  29. struct MemoryRegionSection;
  30. void cpu_register_physical_memory_log(struct MemoryRegionSection *section,
  31. bool readonly);
  32. void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
  33. void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
  34. int cpu_physical_memory_set_dirty_tracking(int enable);
  35. #define VGA_DIRTY_FLAG 0x01
  36. #define CODE_DIRTY_FLAG 0x02
  37. #define MIGRATION_DIRTY_FLAG 0x08
  38. static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
  39. {
  40. return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
  41. }
  42. /* read dirty bit (return 0 or 1) */
  43. static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
  44. {
  45. return cpu_physical_memory_get_dirty_flags(addr) == 0xff;
  46. }
  47. static inline int cpu_physical_memory_get_dirty(ram_addr_t start,
  48. ram_addr_t length,
  49. int dirty_flags)
  50. {
  51. int ret = 0;
  52. ram_addr_t addr, end;
  53. end = TARGET_PAGE_ALIGN(start + length);
  54. start &= TARGET_PAGE_MASK;
  55. for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
  56. ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags;
  57. }
  58. return ret;
  59. }
  60. static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
  61. int dirty_flags)
  62. {
  63. if ((dirty_flags & MIGRATION_DIRTY_FLAG) &&
  64. !cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE,
  65. MIGRATION_DIRTY_FLAG)) {
  66. ram_list.dirty_pages++;
  67. }
  68. return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
  69. }
  70. static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
  71. {
  72. cpu_physical_memory_set_dirty_flags(addr, 0xff);
  73. }
  74. static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr,
  75. int dirty_flags)
  76. {
  77. int mask = ~dirty_flags;
  78. if ((dirty_flags & MIGRATION_DIRTY_FLAG) &&
  79. cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE,
  80. MIGRATION_DIRTY_FLAG)) {
  81. ram_list.dirty_pages--;
  82. }
  83. return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask;
  84. }
  85. static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
  86. ram_addr_t length,
  87. int dirty_flags)
  88. {
  89. ram_addr_t addr, end;
  90. end = TARGET_PAGE_ALIGN(start + length);
  91. start &= TARGET_PAGE_MASK;
  92. for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
  93. cpu_physical_memory_set_dirty_flags(addr, dirty_flags);
  94. }
  95. }
  96. static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
  97. ram_addr_t length,
  98. int dirty_flags)
  99. {
  100. ram_addr_t addr, end;
  101. end = TARGET_PAGE_ALIGN(start + length);
  102. start &= TARGET_PAGE_MASK;
  103. for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
  104. cpu_physical_memory_clear_dirty_flags(addr, dirty_flags);
  105. }
  106. }
  107. void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
  108. int dirty_flags);
  109. extern const IORangeOps memory_region_iorange_ops;
  110. #endif
  111. #endif