2 * Declarations for obsolete exec.c functions
4 * Copyright 2011 Red Hat, Inc. and/or its affiliates
7 * Avi Kivity <avi@redhat.com>
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.
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.
19 #ifndef MEMORY_INTERNAL_H
20 #define MEMORY_INTERNAL_H
22 #ifndef CONFIG_USER_ONLY
23 #include "hw/xen/xen.h"
26 typedef struct AddressSpaceDispatch AddressSpaceDispatch
;
28 void address_space_init_dispatch(AddressSpace
*as
);
29 void address_space_destroy_dispatch(AddressSpace
*as
);
31 extern const MemoryRegionOps unassigned_mem_ops
;
33 bool memory_region_access_valid(MemoryRegion
*mr
, hwaddr addr
,
34 unsigned size
, bool is_write
);
36 ram_addr_t
qemu_ram_alloc_from_ptr(ram_addr_t size
, void *host
,
38 ram_addr_t
qemu_ram_alloc(ram_addr_t size
, MemoryRegion
*mr
);
39 void *qemu_get_ram_ptr(ram_addr_t addr
);
40 void qemu_ram_free(ram_addr_t addr
);
41 void qemu_ram_free_from_ptr(ram_addr_t addr
);
43 static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr
,
46 assert(client
< DIRTY_MEMORY_NUM
);
47 return test_bit(addr
>> TARGET_PAGE_BITS
, ram_list
.dirty_memory
[client
]);
50 /* read dirty bit (return 0 or 1) */
51 static inline bool cpu_physical_memory_is_dirty(ram_addr_t addr
)
53 bool vga
= cpu_physical_memory_get_dirty_flag(addr
, DIRTY_MEMORY_VGA
);
54 bool code
= cpu_physical_memory_get_dirty_flag(addr
, DIRTY_MEMORY_CODE
);
56 cpu_physical_memory_get_dirty_flag(addr
, DIRTY_MEMORY_MIGRATION
);
57 return vga
&& code
&& migration
;
60 static inline int cpu_physical_memory_get_dirty(ram_addr_t start
,
67 end
= TARGET_PAGE_ALIGN(start
+ length
);
68 start
&= TARGET_PAGE_MASK
;
69 for (addr
= start
; addr
< end
; addr
+= TARGET_PAGE_SIZE
) {
70 ret
|= cpu_physical_memory_get_dirty_flag(addr
, client
);
75 static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr
,
78 assert(client
< DIRTY_MEMORY_NUM
);
79 set_bit(addr
>> TARGET_PAGE_BITS
, ram_list
.dirty_memory
[client
]);
82 static inline void cpu_physical_memory_set_dirty(ram_addr_t addr
)
84 cpu_physical_memory_set_dirty_flag(addr
, DIRTY_MEMORY_MIGRATION
);
85 cpu_physical_memory_set_dirty_flag(addr
, DIRTY_MEMORY_VGA
);
86 cpu_physical_memory_set_dirty_flag(addr
, DIRTY_MEMORY_CODE
);
89 static inline void cpu_physical_memory_clear_dirty_flag(ram_addr_t addr
,
92 assert(client
< DIRTY_MEMORY_NUM
);
93 clear_bit(addr
>> TARGET_PAGE_BITS
, ram_list
.dirty_memory
[client
]);
96 static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start
,
101 end
= TARGET_PAGE_ALIGN(start
+ length
);
102 start
&= TARGET_PAGE_MASK
;
103 for (addr
= start
; addr
< end
; addr
+= TARGET_PAGE_SIZE
) {
104 cpu_physical_memory_set_dirty(addr
);
106 xen_modified_memory(addr
, length
);
109 static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start
,
113 ram_addr_t addr
, end
;
115 end
= TARGET_PAGE_ALIGN(start
+ length
);
116 start
&= TARGET_PAGE_MASK
;
117 for (addr
= start
; addr
< end
; addr
+= TARGET_PAGE_SIZE
) {
118 cpu_physical_memory_clear_dirty_flag(addr
, client
);
122 void cpu_physical_memory_reset_dirty(ram_addr_t start
, ram_addr_t end
,