1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef HPPA_CPU_H
21#define HPPA_CPU_H
22
23#include "cpu-qom.h"
24#include "exec/cpu-defs.h"
25#include "exec/memory.h"
26
27
28
29
30
31#define TCG_GUEST_DEFAULT_MO TCG_MO_ALL
32
33#define MMU_KERNEL_IDX 0
34#define MMU_USER_IDX 3
35#define MMU_PHYS_IDX 4
36#define TARGET_INSN_START_EXTRA_WORDS 1
37
38
39#define EXCP_HPMC 1
40#define EXCP_POWER_FAIL 2
41#define EXCP_RC 3
42#define EXCP_EXT_INTERRUPT 4
43#define EXCP_LPMC 5
44#define EXCP_ITLB_MISS 6
45#define EXCP_IMP 7
46#define EXCP_ILL 8
47#define EXCP_BREAK 9
48#define EXCP_PRIV_OPR 10
49#define EXCP_PRIV_REG 11
50#define EXCP_OVERFLOW 12
51#define EXCP_COND 13
52#define EXCP_ASSIST 14
53#define EXCP_DTLB_MISS 15
54#define EXCP_NA_ITLB_MISS 16
55#define EXCP_NA_DTLB_MISS 17
56#define EXCP_DMP 18
57#define EXCP_DMB 19
58#define EXCP_TLB_DIRTY 20
59#define EXCP_PAGE_REF 21
60#define EXCP_ASSIST_EMU 22
61#define EXCP_HPT 23
62#define EXCP_LPT 24
63#define EXCP_TB 25
64#define EXCP_DMAR 26
65#define EXCP_DMPI 27
66#define EXCP_UNALIGN 28
67#define EXCP_PER_INTERRUPT 29
68
69
70#define EXCP_SYSCALL 30
71#define EXCP_SYSCALL_LWS 31
72
73
74#define PSW_I 0x00000001
75#define PSW_D 0x00000002
76#define PSW_P 0x00000004
77#define PSW_Q 0x00000008
78#define PSW_R 0x00000010
79#define PSW_F 0x00000020
80#define PSW_G 0x00000040
81#define PSW_O 0x00000080
82#define PSW_CB 0x0000ff00
83#define PSW_M 0x00010000
84#define PSW_V 0x00020000
85#define PSW_C 0x00040000
86#define PSW_B 0x00080000
87#define PSW_X 0x00100000
88#define PSW_N 0x00200000
89#define PSW_L 0x00400000
90#define PSW_H 0x00800000
91#define PSW_T 0x01000000
92#define PSW_S 0x02000000
93#define PSW_E 0x04000000
94#ifdef TARGET_HPPA64
95#define PSW_W 0x08000000
96#else
97#define PSW_W 0
98#endif
99#define PSW_Z 0x40000000
100#define PSW_Y 0x80000000
101
102#define PSW_SM (PSW_W | PSW_E | PSW_O | PSW_G | PSW_F \
103 | PSW_R | PSW_Q | PSW_P | PSW_D | PSW_I)
104
105
106#define PSW_SM_I PSW_I
107#define PSW_SM_D PSW_D
108#define PSW_SM_P PSW_P
109#define PSW_SM_Q PSW_Q
110#define PSW_SM_R PSW_R
111#ifdef TARGET_HPPA64
112#define PSW_SM_E 0x100
113#define PSW_SM_W 0x200
114#else
115#define PSW_SM_E 0
116#define PSW_SM_W 0
117#endif
118
119#define CR_RC 0
120#define CR_PID1 8
121#define CR_PID2 9
122#define CR_PID3 12
123#define CR_PID4 13
124#define CR_SCRCCR 10
125#define CR_SAR 11
126#define CR_IVA 14
127#define CR_EIEM 15
128#define CR_IT 16
129#define CR_IIASQ 17
130#define CR_IIAOQ 18
131#define CR_IIR 19
132#define CR_ISR 20
133#define CR_IOR 21
134#define CR_IPSW 22
135#define CR_EIRR 23
136
137typedef struct CPUHPPAState CPUHPPAState;
138
139#if TARGET_REGISTER_BITS == 32
140typedef uint32_t target_ureg;
141typedef int32_t target_sreg;
142#define TREG_FMT_lx "%08"PRIx32
143#define TREG_FMT_ld "%"PRId32
144#else
145typedef uint64_t target_ureg;
146typedef int64_t target_sreg;
147#define TREG_FMT_lx "%016"PRIx64
148#define TREG_FMT_ld "%"PRId64
149#endif
150
151typedef struct {
152 uint64_t va_b;
153 uint64_t va_e;
154 target_ureg pa;
155 unsigned u : 1;
156 unsigned t : 1;
157 unsigned d : 1;
158 unsigned b : 1;
159 unsigned page_size : 4;
160 unsigned ar_type : 3;
161 unsigned ar_pl1 : 2;
162 unsigned ar_pl2 : 2;
163 unsigned entry_valid : 1;
164 unsigned access_id : 16;
165} hppa_tlb_entry;
166
167struct CPUHPPAState {
168 target_ureg gr[32];
169 uint64_t fr[32];
170 uint64_t sr[8];
171
172 target_ureg psw;
173 target_ureg psw_n;
174 target_sreg psw_v;
175
176
177
178
179
180
181
182
183 target_ureg psw_cb;
184 target_ureg psw_cb_msb;
185
186 target_ureg iaoq_f;
187 target_ureg iaoq_b;
188 uint64_t iasq_f;
189 uint64_t iasq_b;
190
191 uint32_t fr0_shadow;
192 float_status fp_status;
193
194 target_ureg cr[32];
195 target_ureg cr_back[2];
196 target_ureg shadow[7];
197
198
199
200
201 hppa_tlb_entry tlb[256];
202 uint32_t tlb_last;
203};
204
205
206
207
208
209
210
211struct HPPACPU {
212
213 CPUState parent_obj;
214
215
216 CPUNegativeOffsetState neg;
217 CPUHPPAState env;
218 QEMUTimer *alarm_timer;
219};
220
221
222typedef CPUHPPAState CPUArchState;
223typedef HPPACPU ArchCPU;
224
225#include "exec/cpu-all.h"
226
227static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
228{
229#ifdef CONFIG_USER_ONLY
230 return MMU_USER_IDX;
231#else
232 if (env->psw & (ifetch ? PSW_C : PSW_D)) {
233 return env->iaoq_f & 3;
234 }
235 return MMU_PHYS_IDX;
236#endif
237}
238
239void hppa_translate_init(void);
240
241#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
242
243static inline target_ulong hppa_form_gva_psw(target_ureg psw, uint64_t spc,
244 target_ureg off)
245{
246#ifdef CONFIG_USER_ONLY
247 return off;
248#else
249 off &= (psw & PSW_W ? 0x3fffffffffffffffull : 0xffffffffull);
250 return spc | off;
251#endif
252}
253
254static inline target_ulong hppa_form_gva(CPUHPPAState *env, uint64_t spc,
255 target_ureg off)
256{
257 return hppa_form_gva_psw(env->psw, spc, off);
258}
259
260
261
262
263
264#define TB_FLAG_SR_SAME PSW_I
265#define TB_FLAG_PRIV_SHIFT 8
266
267static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc,
268 target_ulong *cs_base,
269 uint32_t *pflags)
270{
271 uint32_t flags = env->psw_n * PSW_N;
272
273
274
275
276
277#ifdef CONFIG_USER_ONLY
278 *pc = env->iaoq_f & -4;
279 *cs_base = env->iaoq_b & -4;
280#else
281
282 flags |= env->psw & (PSW_W | PSW_C | PSW_D);
283 flags |= (env->iaoq_f & 3) << TB_FLAG_PRIV_SHIFT;
284
285 *pc = (env->psw & PSW_C
286 ? hppa_form_gva_psw(env->psw, env->iasq_f, env->iaoq_f & -4)
287 : env->iaoq_f & -4);
288 *cs_base = env->iasq_f;
289
290
291
292
293
294 if (env->iasq_f == env->iasq_b) {
295 target_sreg diff = env->iaoq_b - env->iaoq_f;
296 if (TARGET_REGISTER_BITS == 32 || diff == (int32_t)diff) {
297 *cs_base |= (uint32_t)diff;
298 }
299 }
300 if ((env->sr[4] == env->sr[5])
301 & (env->sr[4] == env->sr[6])
302 & (env->sr[4] == env->sr[7])) {
303 flags |= TB_FLAG_SR_SAME;
304 }
305#endif
306
307 *pflags = flags;
308}
309
310target_ureg cpu_hppa_get_psw(CPUHPPAState *env);
311void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg);
312void cpu_hppa_loaded_fr0(CPUHPPAState *env);
313
314#ifdef CONFIG_USER_ONLY
315static inline void cpu_hppa_change_prot_id(CPUHPPAState *env) { }
316#else
317void cpu_hppa_change_prot_id(CPUHPPAState *env);
318#endif
319
320#define cpu_signal_handler cpu_hppa_signal_handler
321
322int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc);
323hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
324int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
325int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
326void hppa_cpu_do_interrupt(CPUState *cpu);
327bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req);
328void hppa_cpu_dump_state(CPUState *cs, FILE *f, int);
329bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
330 MMUAccessType access_type, int mmu_idx,
331 bool probe, uintptr_t retaddr);
332#ifndef CONFIG_USER_ONLY
333int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
334 int type, hwaddr *pphys, int *pprot);
335extern const MemoryRegionOps hppa_io_eir_ops;
336extern const VMStateDescription vmstate_hppa_cpu;
337void hppa_cpu_alarm_timer(void *);
338int hppa_artype_for_page(CPUHPPAState *env, target_ulong vaddr);
339#endif
340void QEMU_NORETURN hppa_dynamic_excp(CPUHPPAState *env, int excp, uintptr_t ra);
341
342#endif
343