Statistics
| Branch: | Revision:

root / cpu-common.h @ 1ad2134f

History | View | Annotate | Download (3.7 kB)

1 1ad2134f Paul Brook
#ifndef CPU_COMMON_H
2 1ad2134f Paul Brook
#define CPU_COMMON_H 1
3 1ad2134f Paul Brook
4 1ad2134f Paul Brook
/* CPU interfaces that are target indpendent.  */
5 1ad2134f Paul Brook
6 1ad2134f Paul Brook
#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__)
7 1ad2134f Paul Brook
#define WORDS_ALIGNED
8 1ad2134f Paul Brook
#endif
9 1ad2134f Paul Brook
10 1ad2134f Paul Brook
#include "bswap.h"
11 1ad2134f Paul Brook
12 1ad2134f Paul Brook
/* address in the RAM (different from a physical address) */
13 1ad2134f Paul Brook
#ifdef CONFIG_KQEMU
14 1ad2134f Paul Brook
/* FIXME: This is wrong.  */
15 1ad2134f Paul Brook
typedef uint32_t ram_addr_t;
16 1ad2134f Paul Brook
#else
17 1ad2134f Paul Brook
typedef unsigned long ram_addr_t;
18 1ad2134f Paul Brook
#endif
19 1ad2134f Paul Brook
20 1ad2134f Paul Brook
/* memory API */
21 1ad2134f Paul Brook
22 1ad2134f Paul Brook
typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
23 1ad2134f Paul Brook
typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
24 1ad2134f Paul Brook
25 1ad2134f Paul Brook
void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
26 1ad2134f Paul Brook
                                         ram_addr_t size,
27 1ad2134f Paul Brook
                                         ram_addr_t phys_offset,
28 1ad2134f Paul Brook
                                         ram_addr_t region_offset);
29 1ad2134f Paul Brook
static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,
30 1ad2134f Paul Brook
                                                ram_addr_t size,
31 1ad2134f Paul Brook
                                                ram_addr_t phys_offset)
32 1ad2134f Paul Brook
{
33 1ad2134f Paul Brook
    cpu_register_physical_memory_offset(start_addr, size, phys_offset, 0);
34 1ad2134f Paul Brook
}
35 1ad2134f Paul Brook
36 1ad2134f Paul Brook
ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr);
37 1ad2134f Paul Brook
ram_addr_t qemu_ram_alloc(ram_addr_t);
38 1ad2134f Paul Brook
void qemu_ram_free(ram_addr_t addr);
39 1ad2134f Paul Brook
/* This should only be used for ram local to a device.  */
40 1ad2134f Paul Brook
void *qemu_get_ram_ptr(ram_addr_t addr);
41 1ad2134f Paul Brook
/* This should not be used by devices.  */
42 1ad2134f Paul Brook
ram_addr_t qemu_ram_addr_from_host(void *ptr);
43 1ad2134f Paul Brook
44 1ad2134f Paul Brook
int cpu_register_io_memory(int io_index,
45 1ad2134f Paul Brook
                           CPUReadMemoryFunc **mem_read,
46 1ad2134f Paul Brook
                           CPUWriteMemoryFunc **mem_write,
47 1ad2134f Paul Brook
                           void *opaque);
48 1ad2134f Paul Brook
void cpu_unregister_io_memory(int table_address);
49 1ad2134f Paul Brook
50 1ad2134f Paul Brook
void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
51 1ad2134f Paul Brook
                            int len, int is_write);
52 1ad2134f Paul Brook
static inline void cpu_physical_memory_read(target_phys_addr_t addr,
53 1ad2134f Paul Brook
                                            uint8_t *buf, int len)
54 1ad2134f Paul Brook
{
55 1ad2134f Paul Brook
    cpu_physical_memory_rw(addr, buf, len, 0);
56 1ad2134f Paul Brook
}
57 1ad2134f Paul Brook
static inline void cpu_physical_memory_write(target_phys_addr_t addr,
58 1ad2134f Paul Brook
                                             const uint8_t *buf, int len)
59 1ad2134f Paul Brook
{
60 1ad2134f Paul Brook
    cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1);
61 1ad2134f Paul Brook
}
62 1ad2134f Paul Brook
void *cpu_physical_memory_map(target_phys_addr_t addr,
63 1ad2134f Paul Brook
                              target_phys_addr_t *plen,
64 1ad2134f Paul Brook
                              int is_write);
65 1ad2134f Paul Brook
void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
66 1ad2134f Paul Brook
                               int is_write, target_phys_addr_t access_len);
67 1ad2134f Paul Brook
void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque));
68 1ad2134f Paul Brook
void cpu_unregister_map_client(void *cookie);
69 1ad2134f Paul Brook
70 1ad2134f Paul Brook
uint32_t ldub_phys(target_phys_addr_t addr);
71 1ad2134f Paul Brook
uint32_t lduw_phys(target_phys_addr_t addr);
72 1ad2134f Paul Brook
uint32_t ldl_phys(target_phys_addr_t addr);
73 1ad2134f Paul Brook
uint64_t ldq_phys(target_phys_addr_t addr);
74 1ad2134f Paul Brook
void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val);
75 1ad2134f Paul Brook
void stq_phys_notdirty(target_phys_addr_t addr, uint64_t val);
76 1ad2134f Paul Brook
void stb_phys(target_phys_addr_t addr, uint32_t val);
77 1ad2134f Paul Brook
void stw_phys(target_phys_addr_t addr, uint32_t val);
78 1ad2134f Paul Brook
void stl_phys(target_phys_addr_t addr, uint32_t val);
79 1ad2134f Paul Brook
void stq_phys(target_phys_addr_t addr, uint64_t val);
80 1ad2134f Paul Brook
81 1ad2134f Paul Brook
void cpu_physical_memory_write_rom(target_phys_addr_t addr,
82 1ad2134f Paul Brook
                                   const uint8_t *buf, int len);
83 1ad2134f Paul Brook
84 1ad2134f Paul Brook
#define IO_MEM_SHIFT       3
85 1ad2134f Paul Brook
86 1ad2134f Paul Brook
#define IO_MEM_RAM         (0 << IO_MEM_SHIFT) /* hardcoded offset */
87 1ad2134f Paul Brook
#define IO_MEM_ROM         (1 << IO_MEM_SHIFT) /* hardcoded offset */
88 1ad2134f Paul Brook
#define IO_MEM_UNASSIGNED  (2 << IO_MEM_SHIFT)
89 1ad2134f Paul Brook
#define IO_MEM_NOTDIRTY    (3 << IO_MEM_SHIFT)
90 1ad2134f Paul Brook
91 1ad2134f Paul Brook
/* Acts like a ROM when read and like a device when written.  */
92 1ad2134f Paul Brook
#define IO_MEM_ROMD        (1)
93 1ad2134f Paul Brook
#define IO_MEM_SUBPAGE     (2)
94 1ad2134f Paul Brook
#define IO_MEM_SUBWIDTH    (4)
95 1ad2134f Paul Brook
96 1ad2134f Paul Brook
#endif /* !CPU_COMMON_H */