1
+ /*
2
+ * Declarations for cpu physical memory functions
3
+ *
4
+ * Copyright 2011 Red Hat, Inc. and/or its affiliates
5
+ *
6
+ * Authors:
7
+
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 RAM_ADDR_H
20
+ #define RAM_ADDR_H
21
+
22
+ #ifndef CONFIG_USER_ONLY
23
+ #include "hw/xen/xen.h"
24
+
25
+ ram_addr_t qemu_ram_alloc_from_ptr (DeviceState * dev , const char * name ,
26
+ ram_addr_t size , void * host );
27
+ ram_addr_t qemu_ram_alloc (DeviceState * dev , const char * name , ram_addr_t size );
28
+ /* This should only be used for ram local to a device. */
29
+ void * qemu_get_ram_ptr (ram_addr_t addr );
30
+ /* This should only be used for ram local to a device. */
31
+ /* Same but slower, to use for migration, where the order of
32
+ * RAMBlocks must not change. */
33
+ void * qemu_safe_ram_ptr (ram_addr_t addr );
34
+ /* This should not be used by devices. */
35
+ int qemu_ram_addr_from_host (void * ptr , ram_addr_t * ram_addr );
36
+ void qemu_ram_free (ram_addr_t addr );
37
+ void qemu_ram_remap (ram_addr_t addr , ram_addr_t length );
38
+ ram_addr_t qemu_ram_addr_from_host_nofail (void * ptr );
39
+
40
+ static inline int cpu_physical_memory_get_dirty (ram_addr_t addr ,
41
+ int dirty_flags )
42
+ {
43
+ return ram_list .phys_dirty [addr >> TARGET_PAGE_BITS ] & dirty_flags ;
44
+ }
45
+
46
+ static inline int cpu_physical_memory_get_dirty_flags (ram_addr_t addr )
47
+ {
48
+ return ram_list .phys_dirty [addr >> TARGET_PAGE_BITS ];
49
+ }
50
+
51
+ /* read dirty bit (return 0 or 1) */
52
+ static 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
+
57
+ static inline void cpu_physical_memory_set_dirty (ram_addr_t addr )
58
+ {
59
+ ram_list .phys_dirty [addr >> TARGET_PAGE_BITS ] = 0xff ;
60
+ }
61
+
62
+ static inline int cpu_physical_memory_set_dirty_flags (ram_addr_t addr ,
63
+ int dirty_flags )
64
+ {
65
+ return ram_list .phys_dirty [addr >> TARGET_PAGE_BITS ] |= dirty_flags ;
66
+ }
67
+
68
+ static inline void cpu_physical_memory_mask_dirty_range (ram_addr_t start ,
69
+ int length ,
70
+ int dirty_flags )
71
+ {
72
+ int i , mask , len ;
73
+ uint8_t * p ;
74
+
75
+ len = length >> TARGET_PAGE_BITS ;
76
+ mask = ~dirty_flags ;
77
+ p = ram_list .phys_dirty + (start >> TARGET_PAGE_BITS );
78
+ for (i = 0 ; i < len ; i ++ ) {
79
+ p [i ] &= mask ;
80
+ }
81
+ }
82
+
83
+ int cpu_physical_memory_set_dirty_tracking (int enable );
84
+
85
+ int cpu_physical_memory_get_dirty_tracking (void );
86
+
87
+ int cpu_physical_sync_dirty_bitmap (hwaddr start_addr ,
88
+ hwaddr end_addr );
89
+
90
+ void cpu_physical_memory_reset_dirty (ram_addr_t start , ram_addr_t end ,
91
+ int dirty_flags );
92
+
93
+ #endif
94
+ #endif
0 commit comments