]>
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 <[email protected]> | |
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 | |
e226939d | 27 | #include "hw/xen.h" |
67d95c15 | 28 | |
c5705a77 | 29 | ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, |
67d95c15 | 30 | MemoryRegion *mr); |
c5705a77 | 31 | ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); |
67d95c15 AK |
32 | void qemu_ram_free(ram_addr_t addr); |
33 | void qemu_ram_free_from_ptr(ram_addr_t addr); | |
34 | ||
a621f38d | 35 | struct MemoryRegion; |
dd81124b AK |
36 | struct MemoryRegionSection; |
37 | void cpu_register_physical_memory_log(struct MemoryRegionSection *section, | |
d7ec83e6 | 38 | bool readonly); |
67d95c15 AK |
39 | |
40 | void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); | |
41 | void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); | |
42 | ||
8f77558f AK |
43 | int cpu_physical_memory_set_dirty_tracking(int enable); |
44 | ||
7638e0d2 AK |
45 | #define VGA_DIRTY_FLAG 0x01 |
46 | #define CODE_DIRTY_FLAG 0x02 | |
47 | #define MIGRATION_DIRTY_FLAG 0x08 | |
48 | ||
1720aeee | 49 | static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) |
7638e0d2 | 50 | { |
1720aeee | 51 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; |
7638e0d2 AK |
52 | } |
53 | ||
1720aeee JQ |
54 | /* read dirty bit (return 0 or 1) */ |
55 | static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) | |
7638e0d2 | 56 | { |
1720aeee | 57 | return cpu_physical_memory_get_dirty_flags(addr) == 0xff; |
7638e0d2 AK |
58 | } |
59 | ||
cd7a45c9 BS |
60 | static inline int cpu_physical_memory_get_dirty(ram_addr_t start, |
61 | ram_addr_t length, | |
7638e0d2 AK |
62 | int dirty_flags) |
63 | { | |
cd7a45c9 | 64 | int ret = 0; |
cd7a45c9 BS |
65 | ram_addr_t addr, end; |
66 | ||
67 | end = TARGET_PAGE_ALIGN(start + length); | |
68 | start &= TARGET_PAGE_MASK; | |
cd7a45c9 | 69 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 70 | ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; |
cd7a45c9 BS |
71 | } |
72 | return ret; | |
7638e0d2 AK |
73 | } |
74 | ||
1720aeee JQ |
75 | static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, |
76 | int dirty_flags) | |
77 | { | |
45f33f01 JQ |
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 | } | |
1720aeee JQ |
83 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; |
84 | } | |
85 | ||
7638e0d2 AK |
86 | static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) |
87 | { | |
1720aeee | 88 | cpu_physical_memory_set_dirty_flags(addr, 0xff); |
7638e0d2 AK |
89 | } |
90 | ||
1720aeee JQ |
91 | static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, |
92 | int dirty_flags) | |
7638e0d2 | 93 | { |
1720aeee JQ |
94 | int mask = ~dirty_flags; |
95 | ||
45f33f01 JQ |
96 | if ((dirty_flags & MIGRATION_DIRTY_FLAG) && |
97 | cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE, | |
98 | MIGRATION_DIRTY_FLAG)) { | |
99 | ram_list.dirty_pages--; | |
100 | } | |
1720aeee | 101 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; |
7638e0d2 AK |
102 | } |
103 | ||
fd4aa979 BS |
104 | static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, |
105 | ram_addr_t length, | |
106 | int dirty_flags) | |
107 | { | |
fd4aa979 BS |
108 | ram_addr_t addr, end; |
109 | ||
fd39941a AK |
110 | end = TARGET_PAGE_ALIGN(start + length); |
111 | start &= TARGET_PAGE_MASK; | |
fd39941a | 112 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 113 | cpu_physical_memory_set_dirty_flags(addr, dirty_flags); |
fd4aa979 | 114 | } |
e226939d | 115 | xen_modified_memory(addr, length); |
fd4aa979 BS |
116 | } |
117 | ||
7638e0d2 | 118 | static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, |
59abb061 | 119 | ram_addr_t length, |
7638e0d2 AK |
120 | int dirty_flags) |
121 | { | |
59abb061 | 122 | ram_addr_t addr, end; |
7638e0d2 | 123 | |
fd39941a AK |
124 | end = TARGET_PAGE_ALIGN(start + length); |
125 | start &= TARGET_PAGE_MASK; | |
fd39941a | 126 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 127 | cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); |
7638e0d2 AK |
128 | } |
129 | } | |
130 | ||
131 | void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, | |
132 | int dirty_flags); | |
93632747 AK |
133 | |
134 | extern const IORangeOps memory_region_iorange_ops; | |
135 | ||
67d95c15 AK |
136 | #endif |
137 | ||
138 | #endif |