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