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"
25 typedef struct PhysPageEntry PhysPageEntry
;
27 struct PhysPageEntry
{
29 /* index into phys_sections (is_leaf) or phys_map_nodes (!is_leaf) */
33 typedef struct AddressSpaceDispatch AddressSpaceDispatch
;
35 struct AddressSpaceDispatch
{
36 /* This is a multi-level map on the physical address space.
37 * The bottom level has pointers to MemoryRegionSections.
39 PhysPageEntry phys_map
;
40 MemoryListener listener
;
43 void address_space_init_dispatch(AddressSpace
*as
);
44 void address_space_destroy_dispatch(AddressSpace
*as
);
46 extern const MemoryRegionOps unassigned_mem_ops
;
48 ram_addr_t
qemu_ram_alloc_from_ptr(ram_addr_t size
, void *host
,
50 ram_addr_t
qemu_ram_alloc(ram_addr_t size
, MemoryRegion
*mr
);
51 void *qemu_get_ram_ptr(ram_addr_t addr
);
52 void qemu_ram_free(ram_addr_t addr
);
53 void qemu_ram_free_from_ptr(ram_addr_t addr
);
55 #define VGA_DIRTY_FLAG 0x01
56 #define CODE_DIRTY_FLAG 0x02
57 #define MIGRATION_DIRTY_FLAG 0x08
59 static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr
)
61 return ram_list
.phys_dirty
[addr
>> TARGET_PAGE_BITS
];
64 /* read dirty bit (return 0 or 1) */
65 static inline int cpu_physical_memory_is_dirty(ram_addr_t addr
)
67 return cpu_physical_memory_get_dirty_flags(addr
) == 0xff;
70 static inline int cpu_physical_memory_get_dirty(ram_addr_t start
,
77 end
= TARGET_PAGE_ALIGN(start
+ length
);
78 start
&= TARGET_PAGE_MASK
;
79 for (addr
= start
; addr
< end
; addr
+= TARGET_PAGE_SIZE
) {
80 ret
|= cpu_physical_memory_get_dirty_flags(addr
) & dirty_flags
;
85 static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr
,
88 return ram_list
.phys_dirty
[addr
>> TARGET_PAGE_BITS
] |= dirty_flags
;
91 static inline void cpu_physical_memory_set_dirty(ram_addr_t addr
)
93 cpu_physical_memory_set_dirty_flags(addr
, 0xff);
96 static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr
,
99 int mask
= ~dirty_flags
;
101 return ram_list
.phys_dirty
[addr
>> TARGET_PAGE_BITS
] &= mask
;
104 static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start
,
108 ram_addr_t addr
, end
;
110 end
= TARGET_PAGE_ALIGN(start
+ length
);
111 start
&= TARGET_PAGE_MASK
;
112 for (addr
= start
; addr
< end
; addr
+= TARGET_PAGE_SIZE
) {
113 cpu_physical_memory_set_dirty_flags(addr
, dirty_flags
);
115 xen_modified_memory(addr
, length
);
118 static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start
,
122 ram_addr_t addr
, end
;
124 end
= TARGET_PAGE_ALIGN(start
+ length
);
125 start
&= TARGET_PAGE_MASK
;
126 for (addr
= start
; addr
< end
; addr
+= TARGET_PAGE_SIZE
) {
127 cpu_physical_memory_clear_dirty_flags(addr
, dirty_flags
);
131 void cpu_physical_memory_reset_dirty(ram_addr_t start
, ram_addr_t end
,
134 extern const IORangeOps memory_region_iorange_ops
;