Optional "precise" VGA retrace support
[qemu/mini2440.git] / target-alpha / op.c
blob2896c1d4a296c61cf211d369bd1f8d01bb594885
1 /*
2 * Alpha emulation cpu micro-operations 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 #define DEBUG_OP
23 #include "config.h"
24 #include "exec.h"
25 #include "host-utils.h"
27 #include "op_helper.h"
29 #define REG 0
30 #include "op_template.h"
32 #define REG 1
33 #include "op_template.h"
35 #define REG 2
36 #include "op_template.h"
38 #define REG 3
39 #include "op_template.h"
41 #define REG 4
42 #include "op_template.h"
44 #define REG 5
45 #include "op_template.h"
47 #define REG 6
48 #include "op_template.h"
50 #define REG 7
51 #include "op_template.h"
53 #define REG 8
54 #include "op_template.h"
56 #define REG 9
57 #include "op_template.h"
59 #define REG 10
60 #include "op_template.h"
62 #define REG 11
63 #include "op_template.h"
65 #define REG 12
66 #include "op_template.h"
68 #define REG 13
69 #include "op_template.h"
71 #define REG 14
72 #include "op_template.h"
74 #define REG 15
75 #include "op_template.h"
77 #define REG 16
78 #include "op_template.h"
80 #define REG 17
81 #include "op_template.h"
83 #define REG 18
84 #include "op_template.h"
86 #define REG 19
87 #include "op_template.h"
89 #define REG 20
90 #include "op_template.h"
92 #define REG 21
93 #include "op_template.h"
95 #define REG 22
96 #include "op_template.h"
98 #define REG 23
99 #include "op_template.h"
101 #define REG 24
102 #include "op_template.h"
104 #define REG 25
105 #include "op_template.h"
107 #define REG 26
108 #include "op_template.h"
110 #define REG 27
111 #include "op_template.h"
113 #define REG 28
114 #include "op_template.h"
116 #define REG 29
117 #include "op_template.h"
119 #define REG 30
120 #include "op_template.h"
122 #define REG 31
123 #include "op_template.h"
125 /* Debug stuff */
126 void OPPROTO op_no_op (void)
128 #if !defined (DEBUG_OP)
129 __asm__ __volatile__("nop" : : : "memory");
130 #endif
131 RETURN();
134 /* Load and stores */
135 #define MEMSUFFIX _raw
136 #include "op_mem.h"
137 #if !defined(CONFIG_USER_ONLY)
138 #define MEMSUFFIX _kernel
139 #include "op_mem.h"
140 #define MEMSUFFIX _executive
141 #include "op_mem.h"
142 #define MEMSUFFIX _supervisor
143 #include "op_mem.h"
144 #define MEMSUFFIX _user
145 #include "op_mem.h"
146 /* This is used for pal modes */
147 #define MEMSUFFIX _data
148 #include "op_mem.h"
149 #endif
151 /* Misc */
152 void OPPROTO op_load_fpcr (void)
154 helper_load_fpcr();
155 RETURN();
158 void OPPROTO op_store_fpcr (void)
160 helper_store_fpcr();
161 RETURN();
164 /* Tests */
165 #if 0 // Qemu does not know how to do this...
166 void OPPROTO op_bcond (void)
168 if (T0)
169 env->pc = T1 & ~3;
170 else
171 env->pc = PARAM(1);
172 RETURN();
174 #else
175 void OPPROTO op_bcond (void)
177 if (T0)
178 env->pc = T1 & ~3;
179 else
180 env->pc = ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
181 RETURN();
183 #endif
185 /* IEEE floating point arithmetic */
186 /* S floating (single) */
187 void OPPROTO op_adds (void)
189 FT0 = float32_add(FT0, FT1, &FP_STATUS);
190 RETURN();
193 void OPPROTO op_subs (void)
195 FT0 = float32_sub(FT0, FT1, &FP_STATUS);
196 RETURN();
199 void OPPROTO op_muls (void)
201 FT0 = float32_mul(FT0, FT1, &FP_STATUS);
202 RETURN();
205 void OPPROTO op_divs (void)
207 FT0 = float32_div(FT0, FT1, &FP_STATUS);
208 RETURN();
211 void OPPROTO op_sqrts (void)
213 helper_sqrts();
214 RETURN();
217 void OPPROTO op_cpys (void)
219 helper_cpys();
220 RETURN();
223 void OPPROTO op_cpysn (void)
225 helper_cpysn();
226 RETURN();
229 void OPPROTO op_cpyse (void)
231 helper_cpyse();
232 RETURN();
235 void OPPROTO op_itofs (void)
237 helper_itofs();
238 RETURN();
241 void OPPROTO op_ftois (void)
243 helper_ftois();
244 RETURN();
247 /* T floating (double) */
248 void OPPROTO op_addt (void)
250 FT0 = float64_add(FT0, FT1, &FP_STATUS);
251 RETURN();
254 void OPPROTO op_subt (void)
256 FT0 = float64_sub(FT0, FT1, &FP_STATUS);
257 RETURN();
260 void OPPROTO op_mult (void)
262 FT0 = float64_mul(FT0, FT1, &FP_STATUS);
263 RETURN();
266 void OPPROTO op_divt (void)
268 FT0 = float64_div(FT0, FT1, &FP_STATUS);
269 RETURN();
272 void OPPROTO op_sqrtt (void)
274 helper_sqrtt();
275 RETURN();
278 void OPPROTO op_cmptun (void)
280 helper_cmptun();
281 RETURN();
284 void OPPROTO op_cmpteq (void)
286 helper_cmpteq();
287 RETURN();
290 void OPPROTO op_cmptle (void)
292 helper_cmptle();
293 RETURN();
296 void OPPROTO op_cmptlt (void)
298 helper_cmptlt();
299 RETURN();
302 void OPPROTO op_itoft (void)
304 helper_itoft();
305 RETURN();
308 void OPPROTO op_ftoit (void)
310 helper_ftoit();
311 RETURN();
314 /* VAX floating point arithmetic */
315 /* F floating */
316 void OPPROTO op_addf (void)
318 helper_addf();
319 RETURN();
322 void OPPROTO op_subf (void)
324 helper_subf();
325 RETURN();
328 void OPPROTO op_mulf (void)
330 helper_mulf();
331 RETURN();
334 void OPPROTO op_divf (void)
336 helper_divf();
337 RETURN();
340 void OPPROTO op_sqrtf (void)
342 helper_sqrtf();
343 RETURN();
346 void OPPROTO op_cmpfeq (void)
348 helper_cmpfeq();
349 RETURN();
352 void OPPROTO op_cmpfne (void)
354 helper_cmpfne();
355 RETURN();
358 void OPPROTO op_cmpflt (void)
360 helper_cmpflt();
361 RETURN();
364 void OPPROTO op_cmpfle (void)
366 helper_cmpfle();
367 RETURN();
370 void OPPROTO op_cmpfgt (void)
372 helper_cmpfgt();
373 RETURN();
376 void OPPROTO op_cmpfge (void)
378 helper_cmpfge();
379 RETURN();
382 void OPPROTO op_itoff (void)
384 helper_itoff();
385 RETURN();
388 /* G floating */
389 void OPPROTO op_addg (void)
391 helper_addg();
392 RETURN();
395 void OPPROTO op_subg (void)
397 helper_subg();
398 RETURN();
401 void OPPROTO op_mulg (void)
403 helper_mulg();
404 RETURN();
407 void OPPROTO op_divg (void)
409 helper_divg();
410 RETURN();
413 void OPPROTO op_sqrtg (void)
415 helper_sqrtg();
416 RETURN();
419 void OPPROTO op_cmpgeq (void)
421 helper_cmpgeq();
422 RETURN();
425 void OPPROTO op_cmpglt (void)
427 helper_cmpglt();
428 RETURN();
431 void OPPROTO op_cmpgle (void)
433 helper_cmpgle();
434 RETURN();
437 /* Floating point format conversion */
438 void OPPROTO op_cvtst (void)
440 FT0 = (float)FT0;
441 RETURN();
444 void OPPROTO op_cvtqs (void)
446 helper_cvtqs();
447 RETURN();
450 void OPPROTO op_cvtts (void)
452 FT0 = (float)FT0;
453 RETURN();
456 void OPPROTO op_cvttq (void)
458 helper_cvttq();
459 RETURN();
462 void OPPROTO op_cvtqt (void)
464 helper_cvtqt();
465 RETURN();
468 void OPPROTO op_cvtqf (void)
470 helper_cvtqf();
471 RETURN();
474 void OPPROTO op_cvtgf (void)
476 helper_cvtgf();
477 RETURN();
480 void OPPROTO op_cvtgd (void)
482 helper_cvtgd();
483 RETURN();
486 void OPPROTO op_cvtgq (void)
488 helper_cvtgq();
489 RETURN();
492 void OPPROTO op_cvtqg (void)
494 helper_cvtqg();
495 RETURN();
498 void OPPROTO op_cvtdg (void)
500 helper_cvtdg();
501 RETURN();
504 void OPPROTO op_cvtlq (void)
506 helper_cvtlq();
507 RETURN();
510 void OPPROTO op_cvtql (void)
512 helper_cvtql();
513 RETURN();
516 void OPPROTO op_cvtqlv (void)
518 helper_cvtqlv();
519 RETURN();
522 void OPPROTO op_cvtqlsv (void)
524 helper_cvtqlsv();
525 RETURN();
528 /* PALcode support special instructions */
529 #if !defined (CONFIG_USER_ONLY)
530 void OPPROTO op_hw_rei (void)
532 env->pc = env->ipr[IPR_EXC_ADDR] & ~3;
533 env->ipr[IPR_EXC_ADDR] = env->ipr[IPR_EXC_ADDR] & 1;
534 /* XXX: re-enable interrupts and memory mapping */
535 RETURN();
538 void OPPROTO op_hw_ret (void)
540 env->pc = T0 & ~3;
541 env->ipr[IPR_EXC_ADDR] = T0 & 1;
542 /* XXX: re-enable interrupts and memory mapping */
543 RETURN();
546 void OPPROTO op_mfpr (void)
548 helper_mfpr(PARAM(1));
549 RETURN();
552 void OPPROTO op_mtpr (void)
554 helper_mtpr(PARAM(1));
555 RETURN();
558 void OPPROTO op_set_alt_mode (void)
560 env->saved_mode = env->ps & 0xC;
561 env->ps = (env->ps & ~0xC) | (env->ipr[IPR_ALT_MODE] & 0xC);
562 RETURN();
565 void OPPROTO op_restore_mode (void)
567 env->ps = (env->ps & ~0xC) | env->saved_mode;
568 RETURN();
571 void OPPROTO op_ld_phys_to_virt (void)
573 helper_ld_phys_to_virt();
574 RETURN();
577 void OPPROTO op_st_phys_to_virt (void)
579 helper_st_phys_to_virt();
580 RETURN();
582 #endif /* !defined (CONFIG_USER_ONLY) */