]>
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 | |
ac1970fb AK |
25 | typedef struct PhysPageEntry PhysPageEntry; |
26 | ||
27 | struct PhysPageEntry { | |
28 | uint16_t is_leaf : 1; | |
29 | /* index into phys_sections (is_leaf) or phys_map_nodes (!is_leaf) */ | |
30 | uint16_t ptr : 15; | |
31 | }; | |
32 | ||
33 | typedef struct AddressSpaceDispatch AddressSpaceDispatch; | |
34 | ||
35 | struct AddressSpaceDispatch { | |
36 | /* This is a multi-level map on the physical address space. | |
37 | * The bottom level has pointers to MemoryRegionSections. | |
38 | */ | |
39 | PhysPageEntry phys_map; | |
40 | MemoryListener listener; | |
41 | }; | |
42 | ||
43 | void address_space_init_dispatch(AddressSpace *as); | |
44 | ||
c5705a77 | 45 | ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, |
67d95c15 | 46 | MemoryRegion *mr); |
c5705a77 | 47 | ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); |
67d95c15 AK |
48 | void qemu_ram_free(ram_addr_t addr); |
49 | void qemu_ram_free_from_ptr(ram_addr_t addr); | |
50 | ||
a621f38d | 51 | struct MemoryRegion; |
dd81124b | 52 | struct MemoryRegionSection; |
67d95c15 AK |
53 | |
54 | void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); | |
55 | void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size); | |
56 | ||
8f77558f AK |
57 | int cpu_physical_memory_set_dirty_tracking(int enable); |
58 | ||
7638e0d2 AK |
59 | #define VGA_DIRTY_FLAG 0x01 |
60 | #define CODE_DIRTY_FLAG 0x02 | |
61 | #define MIGRATION_DIRTY_FLAG 0x08 | |
62 | ||
1720aeee | 63 | static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) |
7638e0d2 | 64 | { |
1720aeee | 65 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; |
7638e0d2 AK |
66 | } |
67 | ||
1720aeee JQ |
68 | /* read dirty bit (return 0 or 1) */ |
69 | static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) | |
7638e0d2 | 70 | { |
1720aeee | 71 | return cpu_physical_memory_get_dirty_flags(addr) == 0xff; |
7638e0d2 AK |
72 | } |
73 | ||
cd7a45c9 BS |
74 | static inline int cpu_physical_memory_get_dirty(ram_addr_t start, |
75 | ram_addr_t length, | |
7638e0d2 AK |
76 | int dirty_flags) |
77 | { | |
cd7a45c9 | 78 | int ret = 0; |
cd7a45c9 BS |
79 | ram_addr_t addr, end; |
80 | ||
81 | end = TARGET_PAGE_ALIGN(start + length); | |
82 | start &= TARGET_PAGE_MASK; | |
cd7a45c9 | 83 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 84 | ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; |
cd7a45c9 BS |
85 | } |
86 | return ret; | |
7638e0d2 AK |
87 | } |
88 | ||
1720aeee JQ |
89 | static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, |
90 | int 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 JQ |
97 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; |
98 | } | |
99 | ||
7638e0d2 AK |
100 | static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) |
101 | { | |
1720aeee | 102 | cpu_physical_memory_set_dirty_flags(addr, 0xff); |
7638e0d2 AK |
103 | } |
104 | ||
1720aeee JQ |
105 | static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, |
106 | int dirty_flags) | |
7638e0d2 | 107 | { |
1720aeee JQ |
108 | int mask = ~dirty_flags; |
109 | ||
45f33f01 JQ |
110 | if ((dirty_flags & MIGRATION_DIRTY_FLAG) && |
111 | cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE, | |
112 | MIGRATION_DIRTY_FLAG)) { | |
113 | ram_list.dirty_pages--; | |
114 | } | |
1720aeee | 115 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; |
7638e0d2 AK |
116 | } |
117 | ||
fd4aa979 BS |
118 | static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, |
119 | ram_addr_t length, | |
120 | int dirty_flags) | |
121 | { | |
fd4aa979 BS |
122 | ram_addr_t addr, end; |
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_set_dirty_flags(addr, dirty_flags); |
fd4aa979 | 128 | } |
e226939d | 129 | xen_modified_memory(addr, length); |
fd4aa979 BS |
130 | } |
131 | ||
7638e0d2 | 132 | static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, |
59abb061 | 133 | ram_addr_t length, |
7638e0d2 AK |
134 | int dirty_flags) |
135 | { | |
59abb061 | 136 | ram_addr_t addr, end; |
7638e0d2 | 137 | |
fd39941a AK |
138 | end = TARGET_PAGE_ALIGN(start + length); |
139 | start &= TARGET_PAGE_MASK; | |
fd39941a | 140 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 141 | cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); |
7638e0d2 AK |
142 | } |
143 | } | |
144 | ||
145 | void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, | |
146 | int dirty_flags); | |
93632747 AK |
147 | |
148 | extern const IORangeOps memory_region_iorange_ops; | |
149 | ||
67d95c15 AK |
150 | #endif |
151 | ||
152 | #endif |