1#ifndef CPU_COMMON_H
2#define CPU_COMMON_H
3
4
5
6#ifndef CONFIG_USER_ONLY
7#include "exec/hwaddr.h"
8#endif
9
10
11
12
13
14typedef uint64_t vaddr;
15#define VADDR_PRId PRId64
16#define VADDR_PRIu PRIu64
17#define VADDR_PRIo PRIo64
18#define VADDR_PRIx PRIx64
19#define VADDR_PRIX PRIX64
20#define VADDR_MAX UINT64_MAX
21
22void cpu_exec_init_all(void);
23void cpu_exec_step_atomic(CPUState *cpu);
24
25
26
27
28extern uintptr_t qemu_host_page_size;
29extern intptr_t qemu_host_page_mask;
30
31#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
32#define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size())
33
34
35void qemu_init_cpu_list(void);
36void cpu_list_lock(void);
37void cpu_list_unlock(void);
38unsigned int cpu_list_generation_id_get(void);
39
40void tcg_flush_softmmu_tlb(CPUState *cs);
41void tcg_flush_jmp_cache(CPUState *cs);
42
43void tcg_iommu_init_notifier_list(CPUState *cpu);
44void tcg_iommu_free_notifier_list(CPUState *cpu);
45
46#if !defined(CONFIG_USER_ONLY)
47
48enum device_endian {
49 DEVICE_NATIVE_ENDIAN,
50 DEVICE_BIG_ENDIAN,
51 DEVICE_LITTLE_ENDIAN,
52};
53
54#if HOST_BIG_ENDIAN
55#define DEVICE_HOST_ENDIAN DEVICE_BIG_ENDIAN
56#else
57#define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN
58#endif
59
60
61#if defined(CONFIG_XEN_BACKEND)
62typedef uint64_t ram_addr_t;
63# define RAM_ADDR_MAX UINT64_MAX
64# define RAM_ADDR_FMT "%" PRIx64
65#else
66typedef uintptr_t ram_addr_t;
67# define RAM_ADDR_MAX UINTPTR_MAX
68# define RAM_ADDR_FMT "%" PRIxPTR
69#endif
70
71
72
73void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
74
75ram_addr_t qemu_ram_addr_from_host(void *ptr);
76ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
77RAMBlock *qemu_ram_block_by_name(const char *name);
78RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
79 ram_addr_t *offset);
80ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
81void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
82void qemu_ram_unset_idstr(RAMBlock *block);
83const char *qemu_ram_get_idstr(RAMBlock *rb);
84void *qemu_ram_get_host_addr(RAMBlock *rb);
85ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
86ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
87ram_addr_t qemu_ram_get_max_length(RAMBlock *rb);
88bool qemu_ram_is_shared(RAMBlock *rb);
89bool qemu_ram_is_noreserve(RAMBlock *rb);
90bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
91void qemu_ram_set_uf_zeroable(RAMBlock *rb);
92bool qemu_ram_is_migratable(RAMBlock *rb);
93void qemu_ram_set_migratable(RAMBlock *rb);
94void qemu_ram_unset_migratable(RAMBlock *rb);
95int qemu_ram_get_fd(RAMBlock *rb);
96
97size_t qemu_ram_pagesize(RAMBlock *block);
98size_t qemu_ram_pagesize_largest(void);
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119void cpu_address_space_init(CPUState *cpu, int asidx,
120 const char *prefix, MemoryRegion *mr);
121
122void cpu_physical_memory_rw(hwaddr addr, void *buf,
123 hwaddr len, bool is_write);
124static inline void cpu_physical_memory_read(hwaddr addr,
125 void *buf, hwaddr len)
126{
127 cpu_physical_memory_rw(addr, buf, len, false);
128}
129static inline void cpu_physical_memory_write(hwaddr addr,
130 const void *buf, hwaddr len)
131{
132 cpu_physical_memory_rw(addr, (void *)buf, len, true);
133}
134void cpu_reloading_memory_map(void);
135void *cpu_physical_memory_map(hwaddr addr,
136 hwaddr *plen,
137 bool is_write);
138void cpu_physical_memory_unmap(void *buffer, hwaddr len,
139 bool is_write, hwaddr access_len);
140void cpu_register_map_client(QEMUBH *bh);
141void cpu_unregister_map_client(QEMUBH *bh);
142
143bool cpu_physical_memory_is_io(hwaddr phys_addr);
144
145
146
147
148
149
150void qemu_flush_coalesced_mmio_buffer(void);
151
152void cpu_flush_icache_range(hwaddr start, hwaddr len);
153
154typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);
155
156int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
157int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
158
159#endif
160
161
162int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
163 void *ptr, size_t len, bool is_write);
164
165
166extern int singlestep;
167
168void list_cpus(const char *optarg);
169
170#endif
171