]>
Commit | Line | Data |
---|---|---|
1ad2134f | 1 | #ifndef CPU_COMMON_H |
175de524 | 2 | #define CPU_COMMON_H |
1ad2134f | 3 | |
07f35073 | 4 | /* CPU interfaces that are target independent. */ |
1ad2134f | 5 | |
ce927ed9 | 6 | #ifndef CONFIG_USER_ONLY |
022c62cb | 7 | #include "exec/hwaddr.h" |
ce927ed9 | 8 | #endif |
37b76cfd | 9 | |
06445fbd PMD |
10 | /** |
11 | * vaddr: | |
12 | * Type wide enough to contain any #target_ulong virtual address. | |
13 | */ | |
14 | typedef 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 | ||
b269a708 PMD |
22 | /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even |
23 | * when intptr_t is 32-bit and we are aligning a long long. | |
24 | */ | |
25 | extern uintptr_t qemu_host_page_size; | |
26 | extern intptr_t qemu_host_page_mask; | |
27 | ||
28 | #define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) | |
8e3b0cbb | 29 | #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size()) |
b269a708 | 30 | |
0ac20318 | 31 | /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ |
267f685b PB |
32 | void qemu_init_cpu_list(void); |
33 | void cpu_list_lock(void); | |
34 | void cpu_list_unlock(void); | |
35 | ||
2cd53943 TH |
36 | void tcg_flush_softmmu_tlb(CPUState *cs); |
37 | ||
d9f24bf5 PB |
38 | void tcg_iommu_init_notifier_list(CPUState *cpu); |
39 | void tcg_iommu_free_notifier_list(CPUState *cpu); | |
40 | ||
b3755a91 PB |
41 | #if !defined(CONFIG_USER_ONLY) |
42 | ||
dd310534 AG |
43 | enum device_endian { |
44 | DEVICE_NATIVE_ENDIAN, | |
45 | DEVICE_BIG_ENDIAN, | |
46 | DEVICE_LITTLE_ENDIAN, | |
47 | }; | |
48 | ||
e03b5686 | 49 | #if HOST_BIG_ENDIAN |
c99a29e7 YX |
50 | #define DEVICE_HOST_ENDIAN DEVICE_BIG_ENDIAN |
51 | #else | |
52 | #define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN | |
53 | #endif | |
54 | ||
1ad2134f | 55 | /* address in the RAM (different from a physical address) */ |
4be403c8 | 56 | #if defined(CONFIG_XEN_BACKEND) |
f15fbc4b AP |
57 | typedef uint64_t ram_addr_t; |
58 | # define RAM_ADDR_MAX UINT64_MAX | |
59 | # define RAM_ADDR_FMT "%" PRIx64 | |
60 | #else | |
53576999 SW |
61 | typedef uintptr_t ram_addr_t; |
62 | # define RAM_ADDR_MAX UINTPTR_MAX | |
63 | # define RAM_ADDR_FMT "%" PRIxPTR | |
f15fbc4b | 64 | #endif |
1ad2134f PB |
65 | |
66 | /* memory API */ | |
67 | ||
cd19cfa2 | 68 | void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); |
1ad2134f | 69 | /* This should not be used by devices. */ |
07bdaa41 | 70 | ram_addr_t qemu_ram_addr_from_host(void *ptr); |
e3dd7493 | 71 | RAMBlock *qemu_ram_block_by_name(const char *name); |
422148d3 | 72 | RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, |
f615f396 | 73 | ram_addr_t *offset); |
f90bb71b | 74 | ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host); |
fa53a0e5 GA |
75 | void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev); |
76 | void qemu_ram_unset_idstr(RAMBlock *block); | |
422148d3 | 77 | const char *qemu_ram_get_idstr(RAMBlock *rb); |
754cb9c0 YK |
78 | void *qemu_ram_get_host_addr(RAMBlock *rb); |
79 | ram_addr_t qemu_ram_get_offset(RAMBlock *rb); | |
80 | ram_addr_t qemu_ram_get_used_length(RAMBlock *rb); | |
082851a3 | 81 | ram_addr_t qemu_ram_get_max_length(RAMBlock *rb); |
463a4ac2 | 82 | bool qemu_ram_is_shared(RAMBlock *rb); |
8dbe22c6 | 83 | bool qemu_ram_is_noreserve(RAMBlock *rb); |
2ce16640 DDAG |
84 | bool qemu_ram_is_uf_zeroable(RAMBlock *rb); |
85 | void qemu_ram_set_uf_zeroable(RAMBlock *rb); | |
b895de50 CLG |
86 | bool qemu_ram_is_migratable(RAMBlock *rb); |
87 | void qemu_ram_set_migratable(RAMBlock *rb); | |
88 | void qemu_ram_unset_migratable(RAMBlock *rb); | |
2ce16640 | 89 | |
863e9621 | 90 | size_t qemu_ram_pagesize(RAMBlock *block); |
67f11b5c | 91 | size_t qemu_ram_pagesize_largest(void); |
1ad2134f | 92 | |
1f649fe0 PMD |
93 | /** |
94 | * cpu_address_space_init: | |
95 | * @cpu: CPU to add this address space to | |
96 | * @asidx: integer index of this address space | |
97 | * @prefix: prefix to be used as name of address space | |
98 | * @mr: the root memory region of address space | |
99 | * | |
100 | * Add the specified address space to the CPU's cpu_ases list. | |
101 | * The address space added with @asidx 0 is the one used for the | |
102 | * convenience pointer cpu->as. | |
103 | * The target-specific code which registers ASes is responsible | |
104 | * for defining what semantics address space 0, 1, 2, etc have. | |
105 | * | |
106 | * Before the first call to this function, the caller must set | |
107 | * cpu->num_ases to the total number of address spaces it needs | |
108 | * to support. | |
109 | * | |
110 | * Note that with KVM only one address space is supported. | |
111 | */ | |
112 | void cpu_address_space_init(CPUState *cpu, int asidx, | |
113 | const char *prefix, MemoryRegion *mr); | |
114 | ||
d7ef71ef | 115 | void cpu_physical_memory_rw(hwaddr addr, void *buf, |
28c80bfe | 116 | hwaddr len, bool is_write); |
a8170e5e | 117 | static inline void cpu_physical_memory_read(hwaddr addr, |
0c249ff7 | 118 | void *buf, hwaddr len) |
1ad2134f | 119 | { |
85eb7c18 | 120 | cpu_physical_memory_rw(addr, buf, len, false); |
1ad2134f | 121 | } |
a8170e5e | 122 | static inline void cpu_physical_memory_write(hwaddr addr, |
0c249ff7 | 123 | const void *buf, hwaddr len) |
1ad2134f | 124 | { |
85eb7c18 | 125 | cpu_physical_memory_rw(addr, (void *)buf, len, true); |
1ad2134f | 126 | } |
1f649fe0 | 127 | void cpu_reloading_memory_map(void); |
a8170e5e AK |
128 | void *cpu_physical_memory_map(hwaddr addr, |
129 | hwaddr *plen, | |
28c80bfe | 130 | bool is_write); |
a8170e5e | 131 | void cpu_physical_memory_unmap(void *buffer, hwaddr len, |
28c80bfe | 132 | bool is_write, hwaddr access_len); |
e95205e1 FZ |
133 | void cpu_register_map_client(QEMUBH *bh); |
134 | void cpu_unregister_map_client(QEMUBH *bh); | |
1ad2134f | 135 | |
a8170e5e | 136 | bool cpu_physical_memory_is_io(hwaddr phys_addr); |
76f35538 | 137 | |
6842a08e BS |
138 | /* Coalesced MMIO regions are areas where write operations can be reordered. |
139 | * This usually implies that write operations are side-effect free. This allows | |
140 | * batching which can make a major impact on performance when using | |
141 | * virtualization. | |
142 | */ | |
6842a08e BS |
143 | void qemu_flush_coalesced_mmio_buffer(void); |
144 | ||
0c249ff7 | 145 | void cpu_flush_icache_range(hwaddr start, hwaddr len); |
1ad2134f | 146 | |
754cb9c0 | 147 | typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque); |
bd2fa51f | 148 | |
e3807054 | 149 | int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); |
d3a5038c | 150 | int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length); |
bd2fa51f | 151 | |
b3755a91 PB |
152 | #endif |
153 | ||
73842ef0 PMD |
154 | /* Returns: 0 on success, -1 on error */ |
155 | int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, | |
156 | void *ptr, size_t len, bool is_write); | |
157 | ||
c5e3c918 PB |
158 | /* vl.c */ |
159 | extern int singlestep; | |
160 | ||
377bf6f3 PMD |
161 | void list_cpus(const char *optarg); |
162 | ||
175de524 | 163 | #endif /* CPU_COMMON_H */ |