qemu-io: add "abort" command to simulate program crash
[qemu/agraf.git] / exec-obsolete.h
blobc09925610d0ddc6c6bfdc2482e92310e137dbd40
1 /*
2 * Declarations for obsolete exec.c functions
4 * Copyright 2011 Red Hat, Inc. and/or its affiliates
6 * Authors:
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 EXEC_OBSOLETE_H
20 #define EXEC_OBSOLETE_H
22 #ifndef WANT_EXEC_OBSOLETE
23 #error Do not include exec-obsolete.h
24 #endif
26 #ifndef CONFIG_USER_ONLY
28 ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
29 MemoryRegion *mr);
30 ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
31 void qemu_ram_free(ram_addr_t addr);
32 void qemu_ram_free_from_ptr(ram_addr_t addr);
34 struct MemoryRegion;
35 struct MemoryRegionSection;
36 void cpu_register_physical_memory_log(struct MemoryRegionSection *section,
37 bool readonly);
39 void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
40 void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
42 int cpu_physical_memory_set_dirty_tracking(int enable);
44 #define VGA_DIRTY_FLAG 0x01
45 #define CODE_DIRTY_FLAG 0x02
46 #define MIGRATION_DIRTY_FLAG 0x08
48 static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
50 return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
53 /* read dirty bit (return 0 or 1) */
54 static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
56 return cpu_physical_memory_get_dirty_flags(addr) == 0xff;
59 static inline int cpu_physical_memory_get_dirty(ram_addr_t start,
60 ram_addr_t length,
61 int dirty_flags)
63 int ret = 0;
64 ram_addr_t addr, end;
66 end = TARGET_PAGE_ALIGN(start + length);
67 start &= TARGET_PAGE_MASK;
68 for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
69 ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags;
71 return ret;
74 static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
75 int dirty_flags)
77 if ((dirty_flags & MIGRATION_DIRTY_FLAG) &&
78 !cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE,
79 MIGRATION_DIRTY_FLAG)) {
80 ram_list.dirty_pages++;
82 return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
85 static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
87 cpu_physical_memory_set_dirty_flags(addr, 0xff);
90 static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr,
91 int dirty_flags)
93 int mask = ~dirty_flags;
95 if ((dirty_flags & MIGRATION_DIRTY_FLAG) &&
96 cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE,
97 MIGRATION_DIRTY_FLAG)) {
98 ram_list.dirty_pages--;
100 return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask;
103 static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
104 ram_addr_t length,
105 int dirty_flags)
107 ram_addr_t addr, end;
109 end = TARGET_PAGE_ALIGN(start + length);
110 start &= TARGET_PAGE_MASK;
111 for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
112 cpu_physical_memory_set_dirty_flags(addr, dirty_flags);
116 static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
117 ram_addr_t length,
118 int dirty_flags)
120 ram_addr_t addr, end;
122 end = TARGET_PAGE_ALIGN(start + length);
123 start &= TARGET_PAGE_MASK;
124 for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
125 cpu_physical_memory_clear_dirty_flags(addr, dirty_flags);
129 void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
130 int dirty_flags);
132 extern const IORangeOps memory_region_iorange_ops;
134 #endif
136 #endif