1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef _CPU_MOXIE_H
20#define _CPU_MOXIE_H
21
22#include "config.h"
23#include "qemu-common.h"
24
25#define TARGET_LONG_BITS 32
26
27#define CPUArchState struct CPUMoxieState
28
29#define TARGET_HAS_ICE 1
30
31#define ELF_MACHINE 0xFEED
32
33#define MOXIE_EX_DIV0 0
34#define MOXIE_EX_BAD 1
35#define MOXIE_EX_IRQ 2
36#define MOXIE_EX_SWI 3
37#define MOXIE_EX_MMU_MISS 4
38#define MOXIE_EX_BREAK 16
39
40#include "exec/cpu-defs.h"
41#include "fpu/softfloat.h"
42
43#define TARGET_PAGE_BITS 12
44
45#define TARGET_PHYS_ADDR_SPACE_BITS 32
46#define TARGET_VIRT_ADDR_SPACE_BITS 32
47
48#define NB_MMU_MODES 1
49
50typedef struct CPUMoxieState {
51
52 uint32_t flags;
53 uint32_t gregs[16];
54 uint32_t sregs[256];
55 uint32_t pc;
56
57
58 uint32_t cc_a;
59 uint32_t cc_b;
60
61 void *irq[8];
62
63 CPU_COMMON
64
65} CPUMoxieState;
66
67#include "qom/cpu.h"
68
69#define TYPE_MOXIE_CPU "moxie-cpu"
70
71#define MOXIE_CPU_CLASS(klass) \
72 OBJECT_CLASS_CHECK(MoxieCPUClass, (klass), TYPE_MOXIE_CPU)
73#define MOXIE_CPU(obj) \
74 OBJECT_CHECK(MoxieCPU, (obj), TYPE_MOXIE_CPU)
75#define MOXIE_CPU_GET_CLASS(obj) \
76 OBJECT_GET_CLASS(MoxieCPUClass, (obj), TYPE_MOXIE_CPU)
77
78
79
80
81
82
83
84typedef struct MoxieCPUClass {
85
86 CPUClass parent_class;
87
88
89 DeviceRealize parent_realize;
90 void (*parent_reset)(CPUState *cpu);
91} MoxieCPUClass;
92
93
94
95
96
97
98
99typedef struct MoxieCPU {
100
101 CPUState parent_obj;
102
103
104 CPUMoxieState env;
105} MoxieCPU;
106
107static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env)
108{
109 return container_of(env, MoxieCPU, env);
110}
111
112#define ENV_GET_CPU(e) CPU(moxie_env_get_cpu(e))
113
114#define ENV_OFFSET offsetof(MoxieCPU, env)
115
116MoxieCPU *cpu_moxie_init(const char *cpu_model);
117int cpu_moxie_exec(CPUMoxieState *s);
118void moxie_cpu_do_interrupt(CPUState *cs);
119void moxie_cpu_dump_state(CPUState *cpu, FILE *f,
120 fprintf_function cpu_fprintf, int flags);
121hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
122void moxie_translate_init(void);
123int cpu_moxie_signal_handler(int host_signum, void *pinfo,
124 void *puc);
125
126static inline CPUMoxieState *cpu_init(const char *cpu_model)
127{
128 MoxieCPU *cpu = cpu_moxie_init(cpu_model);
129 if (cpu == NULL) {
130 return NULL;
131 }
132 return &cpu->env;
133}
134
135#define cpu_exec cpu_moxie_exec
136#define cpu_gen_code cpu_moxie_gen_code
137#define cpu_signal_handler cpu_moxie_signal_handler
138
139static inline int cpu_mmu_index(CPUMoxieState *env)
140{
141 return 0;
142}
143
144#include "exec/cpu-all.h"
145#include "exec/exec-all.h"
146
147static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc,
148 target_ulong *cs_base, int *flags)
149{
150 *pc = env->pc;
151 *cs_base = 0;
152 *flags = 0;
153}
154
155static inline int cpu_has_work(CPUState *cpu)
156{
157 return cpu->interrupt_request & CPU_INTERRUPT_HARD;
158}
159
160int cpu_moxie_handle_mmu_fault(CPUMoxieState *env, target_ulong address,
161 int rw, int mmu_idx);
162
163#endif
164