]>
Commit | Line | Data |
---|---|---|
67d95c15 AK |
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 | * | |
6b620ca3 PB |
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. | |
67d95c15 AK |
11 | * |
12 | */ | |
13 | ||
14 | /* | |
15 | * This header is for use by exec.c and memory.c ONLY. Do not include it. | |
16 | * The functions declared here will be removed soon. | |
17 | */ | |
18 | ||
19 | #ifndef EXEC_OBSOLETE_H | |
20 | #define EXEC_OBSOLETE_H | |
21 | ||
22 | #ifndef WANT_EXEC_OBSOLETE | |
23 | #error Do not include exec-obsolete.h | |
24 | #endif | |
25 | ||
26 | #ifndef CONFIG_USER_ONLY | |
27 | ||
c5705a77 | 28 | ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, |
67d95c15 | 29 | MemoryRegion *mr); |
c5705a77 | 30 | ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); |
67d95c15 AK |
31 | void qemu_ram_free(ram_addr_t addr); |
32 | void qemu_ram_free_from_ptr(ram_addr_t addr); | |
33 | ||
a621f38d | 34 | struct MemoryRegion; |
dd81124b AK |
35 | struct MemoryRegionSection; |
36 | void cpu_register_physical_memory_log(struct MemoryRegionSection *section, | |
d7ec83e6 | 37 | bool readonly); |
67d95c15 AK |
38 | |
39 | void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); | |
40 | void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); | |
41 | ||
8f77558f AK |
42 | int cpu_physical_memory_set_dirty_tracking(int enable); |
43 | ||
7638e0d2 AK |
44 | #define VGA_DIRTY_FLAG 0x01 |
45 | #define CODE_DIRTY_FLAG 0x02 | |
46 | #define MIGRATION_DIRTY_FLAG 0x08 | |
47 | ||
1720aeee | 48 | static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) |
7638e0d2 | 49 | { |
1720aeee | 50 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; |
7638e0d2 AK |
51 | } |
52 | ||
1720aeee JQ |
53 | /* read dirty bit (return 0 or 1) */ |
54 | static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) | |
7638e0d2 | 55 | { |
1720aeee | 56 | return cpu_physical_memory_get_dirty_flags(addr) == 0xff; |
7638e0d2 AK |
57 | } |
58 | ||
cd7a45c9 BS |
59 | static inline int cpu_physical_memory_get_dirty(ram_addr_t start, |
60 | ram_addr_t length, | |
7638e0d2 AK |
61 | int dirty_flags) |
62 | { | |
cd7a45c9 | 63 | int ret = 0; |
cd7a45c9 BS |
64 | ram_addr_t addr, end; |
65 | ||
66 | end = TARGET_PAGE_ALIGN(start + length); | |
67 | start &= TARGET_PAGE_MASK; | |
cd7a45c9 | 68 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 69 | ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; |
cd7a45c9 BS |
70 | } |
71 | return ret; | |
7638e0d2 AK |
72 | } |
73 | ||
1720aeee JQ |
74 | static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, |
75 | int dirty_flags) | |
76 | { | |
45f33f01 JQ |
77 | if ((dirty_flags & MIGRATION_DIRTY_FLAG) && |
78 | !cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE, | |
79 | MIGRATION_DIRTY_FLAG)) { | |
80 | ram_list.dirty_pages++; | |
81 | } | |
1720aeee JQ |
82 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; |
83 | } | |
84 | ||
7638e0d2 AK |
85 | static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) |
86 | { | |
1720aeee | 87 | cpu_physical_memory_set_dirty_flags(addr, 0xff); |
7638e0d2 AK |
88 | } |
89 | ||
1720aeee JQ |
90 | static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, |
91 | int dirty_flags) | |
7638e0d2 | 92 | { |
1720aeee JQ |
93 | int mask = ~dirty_flags; |
94 | ||
45f33f01 JQ |
95 | if ((dirty_flags & MIGRATION_DIRTY_FLAG) && |
96 | cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE, | |
97 | MIGRATION_DIRTY_FLAG)) { | |
98 | ram_list.dirty_pages--; | |
99 | } | |
1720aeee | 100 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; |
7638e0d2 AK |
101 | } |
102 | ||
fd4aa979 BS |
103 | static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, |
104 | ram_addr_t length, | |
105 | int dirty_flags) | |
106 | { | |
fd4aa979 BS |
107 | ram_addr_t addr, end; |
108 | ||
fd39941a AK |
109 | end = TARGET_PAGE_ALIGN(start + length); |
110 | start &= TARGET_PAGE_MASK; | |
fd39941a | 111 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 112 | cpu_physical_memory_set_dirty_flags(addr, dirty_flags); |
fd4aa979 BS |
113 | } |
114 | } | |
115 | ||
7638e0d2 | 116 | static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, |
59abb061 | 117 | ram_addr_t length, |
7638e0d2 AK |
118 | int dirty_flags) |
119 | { | |
59abb061 | 120 | ram_addr_t addr, end; |
7638e0d2 | 121 | |
fd39941a AK |
122 | end = TARGET_PAGE_ALIGN(start + length); |
123 | start &= TARGET_PAGE_MASK; | |
fd39941a | 124 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 125 | cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); |
7638e0d2 AK |
126 | } |
127 | } | |
128 | ||
129 | void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, | |
130 | int dirty_flags); | |
93632747 AK |
131 | |
132 | extern const IORangeOps memory_region_iorange_ops; | |
133 | ||
67d95c15 AK |
134 | #endif |
135 | ||
136 | #endif |