]> git.proxmox.com Git - qemu.git/blame - target-alpha/cpu.h
Update TODO.
[qemu.git] / target-alpha / cpu.h
CommitLineData
4c9649a9
JM
1/*
2 * Alpha emulation cpu definitions for qemu.
5fafdf24 3 *
4c9649a9
JM
4 * Copyright (c) 2007 Jocelyn Mayer
5 *
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.
10 *
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.
15 *
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
19 */
20
21#if !defined (__CPU_ALPHA_H__)
22#define __CPU_ALPHA_H__
23
24#include "config.h"
25
26#define TARGET_LONG_BITS 64
27
28#include "cpu-defs.h"
29
30
31#include <setjmp.h>
32
33#include "softfloat.h"
34
4c9649a9
JM
35#define TARGET_HAS_ICE 1
36
37#define ELF_MACHINE EM_ALPHA
38
39#define ICACHE_LINE_SIZE 32
40#define DCACHE_LINE_SIZE 32
41
42#define TARGET_PAGE_BITS 12
43
44#define VA_BITS 43
45
46/* Alpha major type */
47enum {
48 ALPHA_EV3 = 1,
49 ALPHA_EV4 = 2,
50 ALPHA_SIM = 3,
51 ALPHA_LCA = 4,
52 ALPHA_EV5 = 5, /* 21164 */
53 ALPHA_EV45 = 6, /* 21064A */
54 ALPHA_EV56 = 7, /* 21164A */
55};
56
57/* EV4 minor type */
58enum {
59 ALPHA_EV4_2 = 0,
60 ALPHA_EV4_3 = 1,
61};
62
63/* LCA minor type */
64enum {
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 */
71};
72
73/* EV5 minor type */
74enum {
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 */
80};
81
82/* EV45 minor type */
83enum {
84 ALPHA_EV45_1 = 1, /* Pass 1 */
85 ALPHA_EV45_2 = 2, /* Pass 1.1 */
86 ALPHA_EV45_3 = 3, /* Pass 2 */
87};
88
89/* EV56 minor type */
90enum {
91 ALPHA_EV56_1 = 1, /* Pass 1 */
92 ALPHA_EV56_2 = 2, /* Pass 2 */
93};
94
95enum {
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 */
100};
101
102enum {
103 AMASK_BWX = 0x00000001,
104 AMASK_FIX = 0x00000002,
105 AMASK_CIX = 0x00000004,
106 AMASK_MVI = 0x00000100,
107 AMASK_TRAP = 0x00000200,
108 AMASK_PREFETCH = 0x00001000,
109};
110
111enum {
112 VAX_ROUND_NORMAL = 0,
113 VAX_ROUND_CHOPPED,
114};
115
116enum {
117 IEEE_ROUND_NORMAL = 0,
118 IEEE_ROUND_DYNAMIC,
119 IEEE_ROUND_PLUS,
120 IEEE_ROUND_MINUS,
121 IEEE_ROUND_CHOPPED,
122};
123
124/* IEEE floating-point operations encoding */
125/* Trap mode */
126enum {
127 FP_TRAP_I = 0x0,
128 FP_TRAP_U = 0x1,
129 FP_TRAP_S = 0x4,
130 FP_TRAP_SU = 0x5,
131 FP_TRAP_SUI = 0x7,
132};
133
134/* Rounding mode */
135enum {
136 FP_ROUND_CHOPPED = 0x0,
137 FP_ROUND_MINUS = 0x1,
138 FP_ROUND_NORMAL = 0x2,
139 FP_ROUND_DYNAMIC = 0x3,
140};
141
142/* Internal processor registers */
143/* XXX: TOFIX: most of those registers are implementation dependant */
144enum {
145 /* Ebox IPRs */
146 IPR_CC = 0xC0,
147 IPR_CC_CTL = 0xC1,
148 IPR_VA = 0xC2,
149 IPR_VA_CTL = 0xC4,
150 IPR_VA_FORM = 0xC3,
151 /* Ibox IPRs */
152 IPR_ITB_TAG = 0x00,
153 IPR_ITB_PTE = 0x01,
154 IPT_ITB_IAP = 0x02,
155 IPT_ITB_IA = 0x03,
156 IPT_ITB_IS = 0x04,
157 IPR_PMPC = 0x05,
158 IPR_EXC_ADDR = 0x06,
159 IPR_IVA_FORM = 0x07,
160 IPR_CM = 0x09,
161 IPR_IER = 0x0A,
162 IPR_SIRR = 0x0C,
163 IPR_ISUM = 0x0D,
164 IPR_HW_INT_CLR = 0x0E,
165 IPR_EXC_SUM = 0x0F,
166 IPR_PAL_BASE = 0x10,
167 IPR_I_CTL = 0x11,
168 IPR_I_STAT = 0x16,
169 IPR_IC_FLUSH = 0x13,
170 IPR_IC_FLUSH_ASM = 0x12,
171 IPR_CLR_MAP = 0x15,
172 IPR_SLEEP = 0x17,
173 IPR_PCTX = 0x40,
174 IPR_PCTR_CTL = 0x14,
175 /* Mbox IPRs */
176 IPR_DTB_TAG0 = 0x20,
177 IPR_DTB_TAG1 = 0xA0,
178 IPR_DTB_PTE0 = 0x21,
179 IPR_DTB_PTE1 = 0xA1,
180 IPR_DTB_ALTMODE = 0xA6,
181 IPR_DTB_IAP = 0xA2,
182 IPR_DTB_IA = 0xA3,
183 IPR_DTB_IS0 = 0x24,
184 IPR_DTB_IS1 = 0xA4,
185 IPR_DTB_ASN0 = 0x25,
186 IPR_DTB_ASN1 = 0xA5,
187 IPR_MM_STAT = 0x27,
188 IPR_M_CTL = 0x28,
189 IPR_DC_CTL = 0x29,
190 IPR_DC_STAT = 0x2A,
191 /* Cbox IPRs */
192 IPR_C_DATA = 0x2B,
193 IPR_C_SHIFT = 0x2C,
194
195 IPR_ASN,
196 IPR_ASTEN,
197 IPR_ASTSR,
198 IPR_DATFX,
199 IPR_ESP,
200 IPR_FEN,
201 IPR_IPIR,
202 IPR_IPL,
203 IPR_KSP,
204 IPR_MCES,
205 IPR_PERFMON,
206 IPR_PCBB,
207 IPR_PRBR,
208 IPR_PTBR,
209 IPR_SCBB,
210 IPR_SISR,
211 IPR_SSP,
212 IPR_SYSPTBR,
213 IPR_TBCHK,
214 IPR_TBIA,
215 IPR_TBIAP,
216 IPR_TBIS,
217 IPR_TBISD,
218 IPR_TBISI,
219 IPR_USP,
220 IPR_VIRBND,
221 IPR_VPTB,
222 IPR_WHAMI,
223 IPR_ALT_MODE,
224 IPR_LAST,
225};
226
227typedef struct CPUAlphaState CPUAlphaState;
228
229typedef struct pal_handler_t pal_handler_t;
230struct pal_handler_t {
231 /* Reset */
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);
239 /* Data fault */
240 void (*dfault)(CPUAlphaState *env);
241 /* DTB miss pal */
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);
247 /* ITB miss */
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);
257};
258
259struct CPUAlphaState {
260 uint64_t ir[31];
261 float64 fir[31];
262 float_status fp_status;
263 uint64_t fpcr;
264 uint64_t pc;
265 uint64_t lock;
266 uint32_t pcc[2];
267 uint64_t ipr[IPR_LAST];
268 uint64_t ps;
269 uint64_t unique;
270 int saved_mode; /* Used for HW_LD / HW_ST */
271
bf9525e9
JM
272#if TARGET_LONG_BITS > HOST_LONG_BITS
273 /* temporary fixed-point registers
274 * used to emulate 64 bits target on 32 bits hosts
5fafdf24 275 */
bf9525e9
JM
276 target_ulong t0, t1, t2;
277#endif
4c9649a9
JM
278 /* */
279 double ft0, ft1, ft2;
280
281 /* Those resources are used only in Qemu core */
282 CPU_COMMON
283
284 jmp_buf jmp_env;
285 int user_mode_only; /* user mode only simulation */
286 uint32_t hflags;
287 int halted;
288
289 int exception_index;
290 int error_code;
291 int interrupt_request;
292
293 uint32_t features;
294 uint32_t amask;
295 int implver;
296 pal_handler_t *pal_handler;
297};
298
9467d44c
TS
299#define CPUState CPUAlphaState
300#define cpu_init cpu_alpha_init
301#define cpu_exec cpu_alpha_exec
302#define cpu_gen_code cpu_alpha_gen_code
303#define cpu_signal_handler cpu_alpha_signal_handler
304
4c9649a9
JM
305#include "cpu-all.h"
306
307enum {
308 FEATURE_ASN = 0x00000001,
309 FEATURE_SPS = 0x00000002,
310 FEATURE_VIRBND = 0x00000004,
311 FEATURE_TBCHK = 0x00000008,
312};
313
314enum {
315 EXCP_RESET = 0x0000,
316 EXCP_MCHK = 0x0020,
317 EXCP_ARITH = 0x0060,
318 EXCP_HW_INTERRUPT = 0x00E0,
319 EXCP_DFAULT = 0x01E0,
320 EXCP_DTB_MISS_PAL = 0x09E0,
321 EXCP_ITB_MISS = 0x03E0,
322 EXCP_ITB_ACV = 0x07E0,
323 EXCP_DTB_MISS_NATIVE = 0x08E0,
324 EXCP_UNALIGN = 0x11E0,
325 EXCP_OPCDEC = 0x13E0,
326 EXCP_FEN = 0x17E0,
327 EXCP_CALL_PAL = 0x2000,
328 EXCP_CALL_PALP = 0x3000,
329 EXCP_CALL_PALE = 0x4000,
330 /* Pseudo exception for console */
331 EXCP_CONSOLE_DISPATCH = 0x4001,
332 EXCP_CONSOLE_FIXUP = 0x4002,
333};
334
335/* Arithmetic exception */
336enum {
337 EXCP_ARITH_OVERFLOW,
338};
339
340enum {
341 PALCODE_CALL = 0x00000000,
342 PALCODE_LD = 0x01000000,
343 PALCODE_ST = 0x02000000,
344 PALCODE_MFPR = 0x03000000,
345 PALCODE_MTPR = 0x04000000,
346 PALCODE_REI = 0x05000000,
347 PALCODE_INIT = 0xF0000000,
348};
349
350enum {
351 IR_V0 = 0,
352 IR_T0 = 1,
353 IR_T1 = 2,
354 IR_T2 = 3,
355 IR_T3 = 4,
356 IR_T4 = 5,
357 IR_T5 = 6,
358 IR_T6 = 7,
359 IR_T7 = 8,
360 IR_S0 = 9,
361 IR_S1 = 10,
362 IR_S2 = 11,
363 IR_S3 = 12,
364 IR_S4 = 13,
365 IR_S5 = 14,
366 IR_S6 = 15,
367#define IR_FP IR_S6
368 IR_A0 = 16,
369 IR_A1 = 17,
370 IR_A2 = 18,
371 IR_A3 = 19,
372 IR_A4 = 20,
373 IR_A5 = 21,
374 IR_T8 = 22,
375 IR_T9 = 23,
376 IR_T10 = 24,
377 IR_T11 = 25,
378 IR_RA = 26,
379 IR_T12 = 27,
380#define IR_PV IR_T12
381 IR_AT = 28,
382 IR_GP = 29,
383 IR_SP = 30,
384 IR_ZERO = 31,
385};
386
e96efcfc
JM
387CPUAlphaState * cpu_alpha_init (void);
388int cpu_alpha_exec(CPUAlphaState *s);
389/* you can call this signal handler from your SIGBUS and SIGSEGV
390 signal handlers to inform the virtual CPU of exceptions. non zero
391 is returned if the signal was handled by the virtual CPU. */
5fafdf24 392int cpu_alpha_signal_handler(int host_signum, void *pinfo,
e96efcfc 393 void *puc);
4c9649a9
JM
394int cpu_alpha_mfpr (CPUState *env, int iprn, uint64_t *valp);
395int cpu_alpha_mtpr (CPUState *env, int iprn, uint64_t val, uint64_t *oldvalp);
396void cpu_loop_exit (void);
397void pal_init (CPUState *env);
398void call_pal (CPUState *env, int palcode);
399
400#endif /* !defined (__CPU_ALPHA_H__) */