Statistics
| Branch: | Revision:

root / cpu-common.h @ c0424934

History | View | Annotate | Download (4.2 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
#ifdef TARGET_PHYS_ADDR_BITS
7 37b76cfd Paolo Bonzini
#include "targphys.h"
8 37b76cfd Paolo Bonzini
#endif
9 37b76cfd Paolo Bonzini
10 37b76cfd Paolo Bonzini
#ifndef NEED_CPU_H
11 37b76cfd Paolo Bonzini
#include "poison.h"
12 37b76cfd Paolo Bonzini
#endif
13 37b76cfd Paolo Bonzini
14 1ad2134f Paul Brook
#include "bswap.h"
15 f6f3fbca Michael S. Tsirkin
#include "qemu-queue.h"
16 1ad2134f Paul Brook
17 b3755a91 Paul Brook
#if !defined(CONFIG_USER_ONLY)
18 b3755a91 Paul Brook
19 dd310534 Alexander Graf
enum device_endian {
20 dd310534 Alexander Graf
    DEVICE_NATIVE_ENDIAN,
21 dd310534 Alexander Graf
    DEVICE_BIG_ENDIAN,
22 dd310534 Alexander Graf
    DEVICE_LITTLE_ENDIAN,
23 dd310534 Alexander Graf
};
24 dd310534 Alexander Graf
25 1ad2134f Paul Brook
/* address in the RAM (different from a physical address) */
26 f15fbc4b Anthony PERARD
#if defined(CONFIG_XEN_BACKEND) && TARGET_PHYS_ADDR_BITS == 64
27 f15fbc4b Anthony PERARD
typedef uint64_t ram_addr_t;
28 f15fbc4b Anthony PERARD
#  define RAM_ADDR_MAX UINT64_MAX
29 f15fbc4b Anthony PERARD
#  define RAM_ADDR_FMT "%" PRIx64
30 f15fbc4b Anthony PERARD
#else
31 53576999 Stefan Weil
typedef uintptr_t ram_addr_t;
32 53576999 Stefan Weil
#  define RAM_ADDR_MAX UINTPTR_MAX
33 53576999 Stefan Weil
#  define RAM_ADDR_FMT "%" PRIxPTR
34 f15fbc4b Anthony PERARD
#endif
35 1ad2134f Paul Brook
36 1ad2134f Paul Brook
/* memory API */
37 1ad2134f Paul Brook
38 c227f099 Anthony Liguori
typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
39 c227f099 Anthony Liguori
typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
40 1ad2134f Paul Brook
41 cd19cfa2 Huang Ying
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
42 1ad2134f Paul Brook
/* This should only be used for ram local to a device.  */
43 c227f099 Anthony Liguori
void *qemu_get_ram_ptr(ram_addr_t addr);
44 8ab934f9 Stefano Stabellini
void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size);
45 b2e0a138 Michael S. Tsirkin
/* Same but slower, to use for migration, where the order of
46 b2e0a138 Michael S. Tsirkin
 * RAMBlocks must not change. */
47 b2e0a138 Michael S. Tsirkin
void *qemu_safe_ram_ptr(ram_addr_t addr);
48 050a0ddf Anthony PERARD
void qemu_put_ram_ptr(void *addr);
49 1ad2134f Paul Brook
/* This should not be used by devices.  */
50 e890261f Marcelo Tosatti
int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
51 e890261f Marcelo Tosatti
ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
52 c5705a77 Avi Kivity
void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev);
53 1ad2134f Paul Brook
54 c227f099 Anthony Liguori
void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
55 1ad2134f Paul Brook
                            int len, int is_write);
56 c227f099 Anthony Liguori
static inline void cpu_physical_memory_read(target_phys_addr_t addr,
57 3bad9814 Stefan Weil
                                            void *buf, int len)
58 1ad2134f Paul Brook
{
59 1ad2134f Paul Brook
    cpu_physical_memory_rw(addr, buf, len, 0);
60 1ad2134f Paul Brook
}
61 c227f099 Anthony Liguori
static inline void cpu_physical_memory_write(target_phys_addr_t addr,
62 3bad9814 Stefan Weil
                                             const void *buf, int len)
63 1ad2134f Paul Brook
{
64 3bad9814 Stefan Weil
    cpu_physical_memory_rw(addr, (void *)buf, len, 1);
65 1ad2134f Paul Brook
}
66 c227f099 Anthony Liguori
void *cpu_physical_memory_map(target_phys_addr_t addr,
67 c227f099 Anthony Liguori
                              target_phys_addr_t *plen,
68 1ad2134f Paul Brook
                              int is_write);
69 c227f099 Anthony Liguori
void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
70 c227f099 Anthony Liguori
                               int is_write, target_phys_addr_t access_len);
71 1ad2134f Paul Brook
void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque));
72 1ad2134f Paul Brook
void cpu_unregister_map_client(void *cookie);
73 1ad2134f Paul Brook
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 */