Statistics
| Branch: | Revision:

root / include / exec / memory-internal.h @ 7e5609a8

History | View | Annotate | Download (4.1 kB)

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
 *
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.
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 MEMORY_INTERNAL_H
20
#define MEMORY_INTERNAL_H
21

    
22
#ifndef CONFIG_USER_ONLY
23
#include "hw/xen/xen.h"
24

    
25

    
26
typedef struct AddressSpaceDispatch AddressSpaceDispatch;
27

    
28
void address_space_init_dispatch(AddressSpace *as);
29
void address_space_destroy_dispatch(AddressSpace *as);
30

    
31
extern const MemoryRegionOps unassigned_mem_ops;
32

    
33
bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,
34
                                unsigned size, bool is_write);
35

    
36
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
37
                                   MemoryRegion *mr);
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);
42

    
43
#define VGA_DIRTY_FLAG       0x01
44
#define CODE_DIRTY_FLAG      0x02
45
#define MIGRATION_DIRTY_FLAG 0x08
46

    
47
static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
48
{
49
    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
50
}
51

    
52
static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
53
                                                      int dirty_flag)
54
{
55
    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flag;
56
}
57

    
58
/* read dirty bit (return 0 or 1) */
59
static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
60
{
61
    return cpu_physical_memory_get_dirty_flags(addr) == 0xff;
62
}
63

    
64
static inline int cpu_physical_memory_get_dirty(ram_addr_t start,
65
                                                ram_addr_t length,
66
                                                int dirty_flags)
67
{
68
    int ret = 0;
69
    ram_addr_t addr, end;
70

    
71
    end = TARGET_PAGE_ALIGN(start + length);
72
    start &= TARGET_PAGE_MASK;
73
    for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
74
        ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags;
75
    }
76
    return ret;
77
}
78

    
79
static inline void cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
80
                                                      int dirty_flags)
81
{
82
    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
83
}
84

    
85
static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
86
                                                      int dirty_flag)
87
{
88
    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flag;
89
}
90

    
91
static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
92
{
93
    cpu_physical_memory_set_dirty_flags(addr, 0xff);
94
}
95

    
96
static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr,
97
                                                        int dirty_flags)
98
{
99
    int mask = ~dirty_flags;
100

    
101
    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask;
102
}
103

    
104
static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
105
                                                       ram_addr_t length,
106
                                                       int dirty_flags)
107
{
108
    ram_addr_t addr, end;
109

    
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);
114
    }
115
    xen_modified_memory(addr, length);
116
}
117

    
118
static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
119
                                                        ram_addr_t length,
120
                                                        int dirty_flags)
121
{
122
    ram_addr_t addr, end;
123

    
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);
128
    }
129
}
130

    
131
void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
132
                                     int dirty_flags);
133

    
134
#endif
135

    
136
#endif