2 * Alpha emulation cpu definitions for qemu.
4 * Copyright (c) 2007 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #if !defined (__CPU_ALPHA_H__)
22 #define __CPU_ALPHA_H__
26 #define TARGET_LONG_BITS 64
33 #include "softfloat.h"
35 #define TARGET_HAS_ICE 1
37 #define ELF_MACHINE EM_ALPHA
39 #define ICACHE_LINE_SIZE 32
40 #define DCACHE_LINE_SIZE 32
42 #define TARGET_PAGE_BITS 12
46 /* Alpha major type */
52 ALPHA_EV5 = 5, /* 21164 */
53 ALPHA_EV45 = 6, /* 21064A */
54 ALPHA_EV56 = 7, /* 21164A */
65 ALPHA_LCA_1 = 1, /* 21066 */
66 ALPHA_LCA_2 = 2, /* 20166 */
67 ALPHA_LCA_3 = 3, /* 21068 */
68 ALPHA_LCA_4 = 4, /* 21068 */
69 ALPHA_LCA_5 = 5, /* 21066A */
70 ALPHA_LCA_6 = 6, /* 21068A */
75 ALPHA_EV5_1 = 1, /* Rev BA, CA */
76 ALPHA_EV5_2 = 2, /* Rev DA, EA */
77 ALPHA_EV5_3 = 3, /* Pass 3 */
78 ALPHA_EV5_4 = 4, /* Pass 3.2 */
79 ALPHA_EV5_5 = 5, /* Pass 4 */
84 ALPHA_EV45_1 = 1, /* Pass 1 */
85 ALPHA_EV45_2 = 2, /* Pass 1.1 */
86 ALPHA_EV45_3 = 3, /* Pass 2 */
91 ALPHA_EV56_1 = 1, /* Pass 1 */
92 ALPHA_EV56_2 = 2, /* Pass 2 */
96 IMPLVER_2106x = 0, /* EV4, EV45 & LCA45 */
97 IMPLVER_21164 = 1, /* EV5, EV56 & PCA45 */
98 IMPLVER_21264 = 2, /* EV6, EV67 & EV68x */
99 IMPLVER_21364 = 3, /* EV7 & EV79 */
103 AMASK_BWX = 0x00000001,
104 AMASK_FIX = 0x00000002,
105 AMASK_CIX = 0x00000004,
106 AMASK_MVI = 0x00000100,
107 AMASK_TRAP = 0x00000200,
108 AMASK_PREFETCH = 0x00001000,
112 VAX_ROUND_NORMAL = 0,
117 IEEE_ROUND_NORMAL = 0,
124 /* IEEE floating-point operations encoding */
136 FP_ROUND_CHOPPED = 0x0,
137 FP_ROUND_MINUS = 0x1,
138 FP_ROUND_NORMAL = 0x2,
139 FP_ROUND_DYNAMIC = 0x3,
142 /* Internal processor registers */
143 /* XXX: TOFIX: most of those registers are implementation dependant */
164 IPR_HW_INT_CLR = 0x0E,
170 IPR_IC_FLUSH_ASM = 0x12,
180 IPR_DTB_ALTMODE = 0xA6,
227 typedef struct CPUAlphaState CPUAlphaState;
229 typedef struct pal_handler_t pal_handler_t;
230 struct pal_handler_t {
232 void (*reset)(CPUAlphaState *env);
233 /* Uncorrectable hardware error */
234 void (*machine_check)(CPUAlphaState *env);
235 /* Arithmetic exception */
236 void (*arithmetic)(CPUAlphaState *env);
237 /* Interrupt / correctable hardware error */
238 void (*interrupt)(CPUAlphaState *env);
240 void (*dfault)(CPUAlphaState *env);
242 void (*dtb_miss_pal)(CPUAlphaState *env);
243 /* DTB miss native */
244 void (*dtb_miss_native)(CPUAlphaState *env);
245 /* Unaligned access */
246 void (*unalign)(CPUAlphaState *env);
248 void (*itb_miss)(CPUAlphaState *env);
249 /* Instruction stream access violation */
250 void (*itb_acv)(CPUAlphaState *env);
251 /* Reserved or privileged opcode */
252 void (*opcdec)(CPUAlphaState *env);
253 /* Floating point exception */
254 void (*fen)(CPUAlphaState *env);
255 /* Call pal instruction */
256 void (*call_pal)(CPUAlphaState *env, uint32_t palcode);
259 #define NB_MMU_MODES 4
261 struct CPUAlphaState {
264 float_status fp_status;
269 uint64_t ipr[IPR_LAST];
272 int saved_mode; /* Used for HW_LD / HW_ST */
274 #if TARGET_LONG_BITS > HOST_LONG_BITS
275 /* temporary fixed-point registers
276 * used to emulate 64 bits target on 32 bits hosts
278 target_ulong t0, t1, t2;
281 double ft0, ft1, ft2;
283 /* Those resources are used only in Qemu core */
287 int user_mode_only; /* user mode only simulation */
293 int interrupt_request;
298 pal_handler_t *pal_handler;
301 #define CPUState CPUAlphaState
302 #define cpu_init cpu_alpha_init
303 #define cpu_exec cpu_alpha_exec
304 #define cpu_gen_code cpu_alpha_gen_code
305 #define cpu_signal_handler cpu_alpha_signal_handler
307 /* MMU modes definitions */
308 #define MMU_MODE0_SUFFIX _kernel
309 #define MMU_MODE1_SUFFIX _executive
310 #define MMU_MODE2_SUFFIX _supervisor
311 #define MMU_MODE3_SUFFIX _user
312 #define MMU_USER_IDX 3
313 static inline int cpu_mmu_index (CPUState *env)
315 return (env->ps >> 3) & 3;
321 FEATURE_ASN = 0x00000001,
322 FEATURE_SPS = 0x00000002,
323 FEATURE_VIRBND = 0x00000004,
324 FEATURE_TBCHK = 0x00000008,
331 EXCP_HW_INTERRUPT = 0x00E0,
332 EXCP_DFAULT = 0x01E0,
333 EXCP_DTB_MISS_PAL = 0x09E0,
334 EXCP_ITB_MISS = 0x03E0,
335 EXCP_ITB_ACV = 0x07E0,
336 EXCP_DTB_MISS_NATIVE = 0x08E0,
337 EXCP_UNALIGN = 0x11E0,
338 EXCP_OPCDEC = 0x13E0,
340 EXCP_CALL_PAL = 0x2000,
341 EXCP_CALL_PALP = 0x3000,
342 EXCP_CALL_PALE = 0x4000,
343 /* Pseudo exception for console */
344 EXCP_CONSOLE_DISPATCH = 0x4001,
345 EXCP_CONSOLE_FIXUP = 0x4002,
348 /* Arithmetic exception */
354 PALCODE_CALL = 0x00000000,
355 PALCODE_LD = 0x01000000,
356 PALCODE_ST = 0x02000000,
357 PALCODE_MFPR = 0x03000000,
358 PALCODE_MTPR = 0x04000000,
359 PALCODE_REI = 0x05000000,
360 PALCODE_INIT = 0xF0000000,
400 CPUAlphaState * cpu_alpha_init (void);
401 int cpu_alpha_exec(CPUAlphaState *s);
402 /* you can call this signal handler from your SIGBUS and SIGSEGV
403 signal handlers to inform the virtual CPU of exceptions. non zero
404 is returned if the signal was handled by the virtual CPU. */
405 int cpu_alpha_signal_handler(int host_signum, void *pinfo,
407 int cpu_alpha_mfpr (CPUState *env, int iprn, uint64_t *valp);
408 int cpu_alpha_mtpr (CPUState *env, int iprn, uint64_t val, uint64_t *oldvalp);
409 void cpu_loop_exit (void);
410 void pal_init (CPUState *env);
411 void call_pal (CPUState *env, int palcode);
413 #endif /* !defined (__CPU_ALPHA_H__) */