Statistics
| Branch: | Revision:

root / cpu-common.h @ 4be403c8

History | View | Annotate | Download (4.1 kB)

1 1ad2134f Paul Brook
#ifndef CPU_COMMON_H
2 1ad2134f Paul Brook
#define CPU_COMMON_H 1
3 1ad2134f Paul Brook
4 07f35073 Dong Xu Wang
/* CPU interfaces that are target independent.  */
5 1ad2134f Paul Brook
6 37b76cfd Paolo Bonzini
#include "targphys.h"
7 37b76cfd Paolo Bonzini
8 37b76cfd Paolo Bonzini
#ifndef NEED_CPU_H
9 37b76cfd Paolo Bonzini
#include "poison.h"
10 37b76cfd Paolo Bonzini
#endif
11 37b76cfd Paolo Bonzini
12 1ad2134f Paul Brook
#include "bswap.h"
13 f6f3fbca Michael S. Tsirkin
#include "qemu-queue.h"
14 1ad2134f Paul Brook
15 b3755a91 Paul Brook
#if !defined(CONFIG_USER_ONLY)
16 b3755a91 Paul Brook
17 dd310534 Alexander Graf
enum device_endian {
18 dd310534 Alexander Graf
    DEVICE_NATIVE_ENDIAN,
19 dd310534 Alexander Graf
    DEVICE_BIG_ENDIAN,
20 dd310534 Alexander Graf
    DEVICE_LITTLE_ENDIAN,
21 dd310534 Alexander Graf
};
22 dd310534 Alexander Graf
23 1ad2134f Paul Brook
/* address in the RAM (different from a physical address) */
24 4be403c8 Avi Kivity
#if defined(CONFIG_XEN_BACKEND)
25 f15fbc4b Anthony PERARD
typedef uint64_t ram_addr_t;
26 f15fbc4b Anthony PERARD
#  define RAM_ADDR_MAX UINT64_MAX
27 f15fbc4b Anthony PERARD
#  define RAM_ADDR_FMT "%" PRIx64
28 f15fbc4b Anthony PERARD
#else
29 53576999 Stefan Weil
typedef uintptr_t ram_addr_t;
30 53576999 Stefan Weil
#  define RAM_ADDR_MAX UINTPTR_MAX
31 53576999 Stefan Weil
#  define RAM_ADDR_FMT "%" PRIxPTR
32 f15fbc4b Anthony PERARD
#endif
33 1ad2134f Paul Brook
34 1ad2134f Paul Brook
/* memory API */
35 1ad2134f Paul Brook
36 c227f099 Anthony Liguori
typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
37 c227f099 Anthony Liguori
typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
38 1ad2134f Paul Brook
39 cd19cfa2 Huang Ying
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
40 1ad2134f Paul Brook
/* This should only be used for ram local to a device.  */
41 c227f099 Anthony Liguori
void *qemu_get_ram_ptr(ram_addr_t addr);
42 8ab934f9 Stefano Stabellini
void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size);
43 b2e0a138 Michael S. Tsirkin
/* Same but slower, to use for migration, where the order of
44 b2e0a138 Michael S. Tsirkin
 * RAMBlocks must not change. */
45 b2e0a138 Michael S. Tsirkin
void *qemu_safe_ram_ptr(ram_addr_t addr);
46 050a0ddf Anthony PERARD
void qemu_put_ram_ptr(void *addr);
47 1ad2134f Paul Brook
/* This should not be used by devices.  */
48 e890261f Marcelo Tosatti
int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
49 e890261f Marcelo Tosatti
ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
50 c5705a77 Avi Kivity
void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev);
51 1ad2134f Paul Brook
52 c227f099 Anthony Liguori
void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
53 1ad2134f Paul Brook
                            int len, int is_write);
54 c227f099 Anthony Liguori
static inline void cpu_physical_memory_read(target_phys_addr_t addr,
55 3bad9814 Stefan Weil
                                            void *buf, int len)
56 1ad2134f Paul Brook
{
57 1ad2134f Paul Brook
    cpu_physical_memory_rw(addr, buf, len, 0);
58 1ad2134f Paul Brook
}
59 c227f099 Anthony Liguori
static inline void cpu_physical_memory_write(target_phys_addr_t addr,
60 3bad9814 Stefan Weil
                                             const void *buf, int len)
61 1ad2134f Paul Brook
{
62 3bad9814 Stefan Weil
    cpu_physical_memory_rw(addr, (void *)buf, len, 1);
63 1ad2134f Paul Brook
}
64 c227f099 Anthony Liguori
void *cpu_physical_memory_map(target_phys_addr_t addr,
65 c227f099 Anthony Liguori
                              target_phys_addr_t *plen,
66 1ad2134f Paul Brook
                              int is_write);
67 c227f099 Anthony Liguori
void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
68 c227f099 Anthony Liguori
                               int is_write, target_phys_addr_t access_len);
69 1ad2134f Paul Brook
void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque));
70 1ad2134f Paul Brook
void cpu_unregister_map_client(void *cookie);
71 1ad2134f Paul Brook
72 76f35538 Wen Congyang
bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr);
73 76f35538 Wen Congyang
74 6842a08e Blue Swirl
/* Coalesced MMIO regions are areas where write operations can be reordered.
75 6842a08e Blue Swirl
 * This usually implies that write operations are side-effect free.  This allows
76 6842a08e Blue Swirl
 * batching which can make a major impact on performance when using
77 6842a08e Blue Swirl
 * virtualization.
78 6842a08e Blue Swirl
 */
79 6842a08e Blue Swirl
void qemu_flush_coalesced_mmio_buffer(void);
80 6842a08e Blue Swirl
81 c227f099 Anthony Liguori
uint32_t ldub_phys(target_phys_addr_t addr);
82 1e78bcc1 Alexander Graf
uint32_t lduw_le_phys(target_phys_addr_t addr);
83 1e78bcc1 Alexander Graf
uint32_t lduw_be_phys(target_phys_addr_t addr);
84 1e78bcc1 Alexander Graf
uint32_t ldl_le_phys(target_phys_addr_t addr);
85 1e78bcc1 Alexander Graf
uint32_t ldl_be_phys(target_phys_addr_t addr);
86 1e78bcc1 Alexander Graf
uint64_t ldq_le_phys(target_phys_addr_t addr);
87 1e78bcc1 Alexander Graf
uint64_t ldq_be_phys(target_phys_addr_t addr);
88 c227f099 Anthony Liguori
void stb_phys(target_phys_addr_t addr, uint32_t val);
89 1e78bcc1 Alexander Graf
void stw_le_phys(target_phys_addr_t addr, uint32_t val);
90 1e78bcc1 Alexander Graf
void stw_be_phys(target_phys_addr_t addr, uint32_t val);
91 1e78bcc1 Alexander Graf
void stl_le_phys(target_phys_addr_t addr, uint32_t val);
92 1e78bcc1 Alexander Graf
void stl_be_phys(target_phys_addr_t addr, uint32_t val);
93 1e78bcc1 Alexander Graf
void stq_le_phys(target_phys_addr_t addr, uint64_t val);
94 1e78bcc1 Alexander Graf
void stq_be_phys(target_phys_addr_t addr, uint64_t val);
95 c227f099 Anthony Liguori
96 21673cde Blue Swirl
#ifdef NEED_CPU_H
97 21673cde Blue Swirl
uint32_t lduw_phys(target_phys_addr_t addr);
98 21673cde Blue Swirl
uint32_t ldl_phys(target_phys_addr_t addr);
99 21673cde Blue Swirl
uint64_t ldq_phys(target_phys_addr_t addr);
100 21673cde Blue Swirl
void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val);
101 21673cde Blue Swirl
void stq_phys_notdirty(target_phys_addr_t addr, uint64_t val);
102 21673cde Blue Swirl
void stw_phys(target_phys_addr_t addr, uint32_t val);
103 21673cde Blue Swirl
void stl_phys(target_phys_addr_t addr, uint32_t val);
104 21673cde Blue Swirl
void stq_phys(target_phys_addr_t addr, uint64_t val);
105 21673cde Blue Swirl
#endif
106 21673cde Blue Swirl
107 c227f099 Anthony Liguori
void cpu_physical_memory_write_rom(target_phys_addr_t addr,
108 1ad2134f Paul Brook
                                   const uint8_t *buf, int len);
109 1ad2134f Paul Brook
110 0e0df1e2 Avi Kivity
extern struct MemoryRegion io_mem_ram;
111 0e0df1e2 Avi Kivity
extern struct MemoryRegion io_mem_rom;
112 0e0df1e2 Avi Kivity
extern struct MemoryRegion io_mem_unassigned;
113 0e0df1e2 Avi Kivity
extern struct MemoryRegion io_mem_notdirty;
114 1ad2134f Paul Brook
115 b3755a91 Paul Brook
#endif
116 b3755a91 Paul Brook
117 1ad2134f Paul Brook
#endif /* !CPU_COMMON_H */