]>
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 | |
0d09e41a | 23 | #include "hw/xen/xen.h" |
67d95c15 | 24 | |
ac1970fb AK |
25 | |
26 | typedef struct AddressSpaceDispatch AddressSpaceDispatch; | |
27 | ||
ac1970fb | 28 | void address_space_init_dispatch(AddressSpace *as); |
83f3c251 | 29 | void address_space_destroy_dispatch(AddressSpace *as); |
ac1970fb | 30 | |
d197063f PB |
31 | extern const MemoryRegionOps unassigned_mem_ops; |
32 | ||
d2702032 PB |
33 | bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr, |
34 | unsigned size, bool is_write); | |
35 | ||
c5705a77 | 36 | ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, |
67d95c15 | 37 | MemoryRegion *mr); |
c5705a77 | 38 | ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); |
ee983cb3 | 39 | void *qemu_get_ram_ptr(ram_addr_t addr); |
67d95c15 AK |
40 | void qemu_ram_free(ram_addr_t addr); |
41 | void qemu_ram_free_from_ptr(ram_addr_t addr); | |
42 | ||
7638e0d2 AK |
43 | #define VGA_DIRTY_FLAG 0x01 |
44 | #define CODE_DIRTY_FLAG 0x02 | |
45 | #define MIGRATION_DIRTY_FLAG 0x08 | |
46 | ||
1720aeee | 47 | static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) |
7638e0d2 | 48 | { |
1720aeee | 49 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; |
7638e0d2 AK |
50 | } |
51 | ||
1720aeee JQ |
52 | /* read dirty bit (return 0 or 1) */ |
53 | static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) | |
7638e0d2 | 54 | { |
1720aeee | 55 | return cpu_physical_memory_get_dirty_flags(addr) == 0xff; |
7638e0d2 AK |
56 | } |
57 | ||
cd7a45c9 BS |
58 | static inline int cpu_physical_memory_get_dirty(ram_addr_t start, |
59 | ram_addr_t length, | |
7638e0d2 AK |
60 | int dirty_flags) |
61 | { | |
cd7a45c9 | 62 | int ret = 0; |
cd7a45c9 BS |
63 | ram_addr_t addr, end; |
64 | ||
65 | end = TARGET_PAGE_ALIGN(start + length); | |
66 | start &= TARGET_PAGE_MASK; | |
cd7a45c9 | 67 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 68 | ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; |
cd7a45c9 BS |
69 | } |
70 | return ret; | |
7638e0d2 AK |
71 | } |
72 | ||
1720aeee JQ |
73 | static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, |
74 | int dirty_flags) | |
75 | { | |
76 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; | |
77 | } | |
78 | ||
7638e0d2 AK |
79 | static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) |
80 | { | |
1720aeee | 81 | cpu_physical_memory_set_dirty_flags(addr, 0xff); |
7638e0d2 AK |
82 | } |
83 | ||
1720aeee JQ |
84 | static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, |
85 | int dirty_flags) | |
7638e0d2 | 86 | { |
1720aeee JQ |
87 | int mask = ~dirty_flags; |
88 | ||
89 | return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; | |
7638e0d2 AK |
90 | } |
91 | ||
fd4aa979 BS |
92 | static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, |
93 | ram_addr_t length, | |
94 | int dirty_flags) | |
95 | { | |
fd4aa979 BS |
96 | ram_addr_t addr, end; |
97 | ||
fd39941a AK |
98 | end = TARGET_PAGE_ALIGN(start + length); |
99 | start &= TARGET_PAGE_MASK; | |
fd39941a | 100 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 101 | cpu_physical_memory_set_dirty_flags(addr, dirty_flags); |
fd4aa979 | 102 | } |
e226939d | 103 | xen_modified_memory(addr, length); |
fd4aa979 BS |
104 | } |
105 | ||
7638e0d2 | 106 | static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, |
59abb061 | 107 | ram_addr_t length, |
7638e0d2 AK |
108 | int dirty_flags) |
109 | { | |
59abb061 | 110 | ram_addr_t addr, end; |
7638e0d2 | 111 | |
fd39941a AK |
112 | end = TARGET_PAGE_ALIGN(start + length); |
113 | start &= TARGET_PAGE_MASK; | |
fd39941a | 114 | for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { |
1720aeee | 115 | cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); |
7638e0d2 AK |
116 | } |
117 | } | |
118 | ||
119 | void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, | |
120 | int dirty_flags); | |
93632747 | 121 | |
67d95c15 AK |
122 | #endif |
123 | ||
124 | #endif |