]> git.proxmox.com Git - qemu.git/blame - exec-obsolete.h
qcow2: Add error messages in qcow2_truncate
[qemu.git] / exec-obsolete.h
CommitLineData
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
19#ifndef EXEC_OBSOLETE_H
20#define EXEC_OBSOLETE_H
21
22#ifndef WANT_EXEC_OBSOLETE
23#error Do not include exec-obsolete.h
24#endif
25
26#ifndef CONFIG_USER_ONLY
27
c5705a77 28ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
67d95c15 29 MemoryRegion *mr);
c5705a77 30ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
67d95c15
AK
31void qemu_ram_free(ram_addr_t addr);
32void qemu_ram_free_from_ptr(ram_addr_t addr);
33
a621f38d
AK
34struct MemoryRegion;
35int cpu_register_io_memory(MemoryRegion *mr);
67d95c15
AK
36void cpu_unregister_io_memory(int table_address);
37
dd81124b
AK
38struct MemoryRegionSection;
39void cpu_register_physical_memory_log(struct MemoryRegionSection *section,
d7ec83e6 40 bool readonly);
67d95c15
AK
41
42void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
43void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
44
8f77558f
AK
45int cpu_physical_memory_set_dirty_tracking(int enable);
46
7638e0d2
AK
47#define VGA_DIRTY_FLAG 0x01
48#define CODE_DIRTY_FLAG 0x02
49#define MIGRATION_DIRTY_FLAG 0x08
50
51/* read dirty bit (return 0 or 1) */
52static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
53{
54 return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
55}
56
57static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
58{
59 return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
60}
61
cd7a45c9
BS
62static inline int cpu_physical_memory_get_dirty(ram_addr_t start,
63 ram_addr_t length,
7638e0d2
AK
64 int dirty_flags)
65{
cd7a45c9
BS
66 int ret = 0;
67 uint8_t *p;
68 ram_addr_t addr, end;
69
70 end = TARGET_PAGE_ALIGN(start + length);
71 start &= TARGET_PAGE_MASK;
72 p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
73 for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
74 ret |= *p++ & dirty_flags;
75 }
76 return ret;
7638e0d2
AK
77}
78
79static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
80{
81 ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
82}
83
84static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
85 int dirty_flags)
86{
87 return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
88}
89
fd4aa979
BS
90static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
91 ram_addr_t length,
92 int dirty_flags)
93{
94 uint8_t *p;
95 ram_addr_t addr, end;
96
fd39941a
AK
97 end = TARGET_PAGE_ALIGN(start + length);
98 start &= TARGET_PAGE_MASK;
fd4aa979 99 p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
fd39941a 100 for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
fd4aa979
BS
101 *p++ |= dirty_flags;
102 }
103}
104
7638e0d2 105static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
59abb061 106 ram_addr_t length,
7638e0d2
AK
107 int dirty_flags)
108{
59abb061 109 int mask;
7638e0d2 110 uint8_t *p;
59abb061 111 ram_addr_t addr, end;
7638e0d2 112
fd39941a
AK
113 end = TARGET_PAGE_ALIGN(start + length);
114 start &= TARGET_PAGE_MASK;
7638e0d2
AK
115 mask = ~dirty_flags;
116 p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
fd39941a 117 for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
59abb061 118 *p++ &= mask;
7638e0d2
AK
119 }
120}
121
122void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
123 int dirty_flags);
93632747
AK
124
125extern const IORangeOps memory_region_iorange_ops;
126
67d95c15
AK
127#endif
128
129#endif