2 * Declarations for cpu physical memory 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.
22 #ifndef CONFIG_USER_ONLY
23 #include "hw/xen/xen.h"
25 ram_addr_t
qemu_ram_alloc_from_ptr(ram_addr_t size
, void *host
,
27 ram_addr_t
qemu_ram_alloc(ram_addr_t size
, MemoryRegion
*mr
);
28 void *qemu_get_ram_ptr(ram_addr_t addr
);
29 void qemu_ram_free(ram_addr_t addr
);
30 void qemu_ram_free_from_ptr(ram_addr_t addr
);
32 static inline bool cpu_physical_memory_get_dirty(ram_addr_t start
,
36 unsigned long end
, page
, next
;
38 assert(client
< DIRTY_MEMORY_NUM
);
40 end
= TARGET_PAGE_ALIGN(start
+ length
) >> TARGET_PAGE_BITS
;
41 page
= start
>> TARGET_PAGE_BITS
;
42 next
= find_next_bit(ram_list
.dirty_memory
[client
], end
, page
);
47 static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr
,
50 return cpu_physical_memory_get_dirty(addr
, 1, client
);
53 static inline bool cpu_physical_memory_is_clean(ram_addr_t addr
)
55 bool vga
= cpu_physical_memory_get_dirty_flag(addr
, DIRTY_MEMORY_VGA
);
56 bool code
= cpu_physical_memory_get_dirty_flag(addr
, DIRTY_MEMORY_CODE
);
58 cpu_physical_memory_get_dirty_flag(addr
, DIRTY_MEMORY_MIGRATION
);
59 return !(vga
&& code
&& migration
);
62 static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr
,
65 assert(client
< DIRTY_MEMORY_NUM
);
66 set_bit(addr
>> TARGET_PAGE_BITS
, ram_list
.dirty_memory
[client
]);
69 static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start
,
72 unsigned long end
, page
;
74 end
= TARGET_PAGE_ALIGN(start
+ length
) >> TARGET_PAGE_BITS
;
75 page
= start
>> TARGET_PAGE_BITS
;
76 bitmap_set(ram_list
.dirty_memory
[DIRTY_MEMORY_MIGRATION
], page
, end
- page
);
77 bitmap_set(ram_list
.dirty_memory
[DIRTY_MEMORY_VGA
], page
, end
- page
);
78 bitmap_set(ram_list
.dirty_memory
[DIRTY_MEMORY_CODE
], page
, end
- page
);
79 xen_modified_memory(start
, length
);
82 static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start
,
86 unsigned long end
, page
;
88 assert(client
< DIRTY_MEMORY_NUM
);
89 end
= TARGET_PAGE_ALIGN(start
+ length
) >> TARGET_PAGE_BITS
;
90 page
= start
>> TARGET_PAGE_BITS
;
91 bitmap_clear(ram_list
.dirty_memory
[client
], page
, end
- page
);
94 void cpu_physical_memory_reset_dirty(ram_addr_t start
, ram_addr_t length
,