Statistics
| Branch: | Revision:

root / target-alpha / op.c @ 04acd307

History | View | Annotate | Download (8.4 kB)

1
/*
2
 *  Alpha emulation cpu micro-operations for qemu.
3
 *
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
#define DEBUG_OP
22

    
23
#include "config.h"
24
#include "exec.h"
25
#include "host-utils.h"
26

    
27
#include "op_helper.h"
28

    
29
#define REG 0
30
#include "op_template.h"
31

    
32
#define REG 1
33
#include "op_template.h"
34

    
35
#define REG 2
36
#include "op_template.h"
37

    
38
#define REG 3
39
#include "op_template.h"
40

    
41
#define REG 4
42
#include "op_template.h"
43

    
44
#define REG 5
45
#include "op_template.h"
46

    
47
#define REG 6
48
#include "op_template.h"
49

    
50
#define REG 7
51
#include "op_template.h"
52

    
53
#define REG 8
54
#include "op_template.h"
55

    
56
#define REG 9
57
#include "op_template.h"
58

    
59
#define REG 10
60
#include "op_template.h"
61

    
62
#define REG 11
63
#include "op_template.h"
64

    
65
#define REG 12
66
#include "op_template.h"
67

    
68
#define REG 13
69
#include "op_template.h"
70

    
71
#define REG 14
72
#include "op_template.h"
73

    
74
#define REG 15
75
#include "op_template.h"
76

    
77
#define REG 16
78
#include "op_template.h"
79

    
80
#define REG 17
81
#include "op_template.h"
82

    
83
#define REG 18
84
#include "op_template.h"
85

    
86
#define REG 19
87
#include "op_template.h"
88

    
89
#define REG 20
90
#include "op_template.h"
91

    
92
#define REG 21
93
#include "op_template.h"
94

    
95
#define REG 22
96
#include "op_template.h"
97

    
98
#define REG 23
99
#include "op_template.h"
100

    
101
#define REG 24
102
#include "op_template.h"
103

    
104
#define REG 25
105
#include "op_template.h"
106

    
107
#define REG 26
108
#include "op_template.h"
109

    
110
#define REG 27
111
#include "op_template.h"
112

    
113
#define REG 28
114
#include "op_template.h"
115

    
116
#define REG 29
117
#include "op_template.h"
118

    
119
#define REG 30
120
#include "op_template.h"
121

    
122
#define REG 31
123
#include "op_template.h"
124

    
125
/* Debug stuff */
126
void OPPROTO op_no_op (void)
127
{
128
#if !defined (DEBUG_OP)
129
    __asm__ __volatile__("nop" : : : "memory");
130
#endif
131
    RETURN();
132
}
133

    
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
150

    
151
/* Misc */
152
void OPPROTO op_load_fpcr (void)
153
{
154
    helper_load_fpcr();
155
    RETURN();
156
}
157

    
158
void OPPROTO op_store_fpcr (void)
159
{
160
    helper_store_fpcr();
161
    RETURN();
162
}
163

    
164
/* Tests */
165
#if 0 // Qemu does not know how to do this...
166
void OPPROTO op_bcond (void)
167
{
168
    if (T0)
169
        env->pc = T1 & ~3;
170
    else
171
        env->pc = PARAM(1);
172
    RETURN();
173
}
174
#else
175
void OPPROTO op_bcond (void)
176
{
177
    if (T0)
178
        env->pc = T1 & ~3;
179
    else
180
        env->pc = ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
181
    RETURN();
182
}
183
#endif
184

    
185
/* IEEE floating point arithmetic */
186
/* S floating (single) */
187
void OPPROTO op_adds (void)
188
{
189
    FT0 = float32_add(FT0, FT1, &FP_STATUS);
190
    RETURN();
191
}
192

    
193
void OPPROTO op_subs (void)
194
{
195
    FT0 = float32_sub(FT0, FT1, &FP_STATUS);
196
    RETURN();
197
}
198

    
199
void OPPROTO op_muls (void)
200
{
201
    FT0 = float32_mul(FT0, FT1, &FP_STATUS);
202
    RETURN();
203
}
204

    
205
void OPPROTO op_divs (void)
206
{
207
    FT0 = float32_div(FT0, FT1, &FP_STATUS);
208
    RETURN();
209
}
210

    
211
void OPPROTO op_sqrts (void)
212
{
213
    helper_sqrts();
214
    RETURN();
215
}
216

    
217
void OPPROTO op_cpys (void)
218
{
219
    helper_cpys();
220
    RETURN();
221
}
222

    
223
void OPPROTO op_cpysn (void)
224
{
225
    helper_cpysn();
226
    RETURN();
227
}
228

    
229
void OPPROTO op_cpyse (void)
230
{
231
    helper_cpyse();
232
    RETURN();
233
}
234

    
235
void OPPROTO op_itofs (void)
236
{
237
    helper_itofs();
238
    RETURN();
239
}
240

    
241
void OPPROTO op_ftois (void)
242
{
243
    helper_ftois();
244
    RETURN();
245
}
246

    
247
/* T floating (double) */
248
void OPPROTO op_addt (void)
249
{
250
    FT0 = float64_add(FT0, FT1, &FP_STATUS);
251
    RETURN();
252
}
253

    
254
void OPPROTO op_subt (void)
255
{
256
    FT0 = float64_sub(FT0, FT1, &FP_STATUS);
257
    RETURN();
258
}
259

    
260
void OPPROTO op_mult (void)
261
{
262
    FT0 = float64_mul(FT0, FT1, &FP_STATUS);
263
    RETURN();
264
}
265

    
266
void OPPROTO op_divt (void)
267
{
268
    FT0 = float64_div(FT0, FT1, &FP_STATUS);
269
    RETURN();
270
}
271

    
272
void OPPROTO op_sqrtt (void)
273
{
274
    helper_sqrtt();
275
    RETURN();
276
}
277

    
278
void OPPROTO op_cmptun (void)
279
{
280
    helper_cmptun();
281
    RETURN();
282
}
283

    
284
void OPPROTO op_cmpteq (void)
285
{
286
    helper_cmpteq();
287
    RETURN();
288
}
289

    
290
void OPPROTO op_cmptle (void)
291
{
292
    helper_cmptle();
293
    RETURN();
294
}
295

    
296
void OPPROTO op_cmptlt (void)
297
{
298
    helper_cmptlt();
299
    RETURN();
300
}
301

    
302
void OPPROTO op_itoft (void)
303
{
304
    helper_itoft();
305
    RETURN();
306
}
307

    
308
void OPPROTO op_ftoit (void)
309
{
310
    helper_ftoit();
311
    RETURN();
312
}
313

    
314
/* VAX floating point arithmetic */
315
/* F floating */
316
void OPPROTO op_addf (void)
317
{
318
    helper_addf();
319
    RETURN();
320
}
321

    
322
void OPPROTO op_subf (void)
323
{
324
    helper_subf();
325
    RETURN();
326
}
327

    
328
void OPPROTO op_mulf (void)
329
{
330
    helper_mulf();
331
    RETURN();
332
}
333

    
334
void OPPROTO op_divf (void)
335
{
336
    helper_divf();
337
    RETURN();
338
}
339

    
340
void OPPROTO op_sqrtf (void)
341
{
342
    helper_sqrtf();
343
    RETURN();
344
}
345

    
346
void OPPROTO op_cmpfeq (void)
347
{
348
    helper_cmpfeq();
349
    RETURN();
350
}
351

    
352
void OPPROTO op_cmpfne (void)
353
{
354
    helper_cmpfne();
355
    RETURN();
356
}
357

    
358
void OPPROTO op_cmpflt (void)
359
{
360
    helper_cmpflt();
361
    RETURN();
362
}
363

    
364
void OPPROTO op_cmpfle (void)
365
{
366
    helper_cmpfle();
367
    RETURN();
368
}
369

    
370
void OPPROTO op_cmpfgt (void)
371
{
372
    helper_cmpfgt();
373
    RETURN();
374
}
375

    
376
void OPPROTO op_cmpfge (void)
377
{
378
    helper_cmpfge();
379
    RETURN();
380
}
381

    
382
void OPPROTO op_itoff (void)
383
{
384
    helper_itoff();
385
    RETURN();
386
}
387

    
388
/* G floating */
389
void OPPROTO op_addg (void)
390
{
391
    helper_addg();
392
    RETURN();
393
}
394

    
395
void OPPROTO op_subg (void)
396
{
397
    helper_subg();
398
    RETURN();
399
}
400

    
401
void OPPROTO op_mulg (void)
402
{
403
    helper_mulg();
404
    RETURN();
405
}
406

    
407
void OPPROTO op_divg (void)
408
{
409
    helper_divg();
410
    RETURN();
411
}
412

    
413
void OPPROTO op_sqrtg (void)
414
{
415
    helper_sqrtg();
416
    RETURN();
417
}
418

    
419
void OPPROTO op_cmpgeq (void)
420
{
421
    helper_cmpgeq();
422
    RETURN();
423
}
424

    
425
void OPPROTO op_cmpglt (void)
426
{
427
    helper_cmpglt();
428
    RETURN();
429
}
430

    
431
void OPPROTO op_cmpgle (void)
432
{
433
    helper_cmpgle();
434
    RETURN();
435
}
436

    
437
/* Floating point format conversion */
438
void OPPROTO op_cvtst (void)
439
{
440
    FT0 = (float)FT0;
441
    RETURN();
442
}
443

    
444
void OPPROTO op_cvtqs (void)
445
{
446
    helper_cvtqs();
447
    RETURN();
448
}
449

    
450
void OPPROTO op_cvtts (void)
451
{
452
    FT0 = (float)FT0;
453
    RETURN();
454
}
455

    
456
void OPPROTO op_cvttq (void)
457
{
458
    helper_cvttq();
459
    RETURN();
460
}
461

    
462
void OPPROTO op_cvtqt (void)
463
{
464
    helper_cvtqt();
465
    RETURN();
466
}
467

    
468
void OPPROTO op_cvtqf (void)
469
{
470
    helper_cvtqf();
471
    RETURN();
472
}
473

    
474
void OPPROTO op_cvtgf (void)
475
{
476
    helper_cvtgf();
477
    RETURN();
478
}
479

    
480
void OPPROTO op_cvtgd (void)
481
{
482
    helper_cvtgd();
483
    RETURN();
484
}
485

    
486
void OPPROTO op_cvtgq (void)
487
{
488
    helper_cvtgq();
489
    RETURN();
490
}
491

    
492
void OPPROTO op_cvtqg (void)
493
{
494
    helper_cvtqg();
495
    RETURN();
496
}
497

    
498
void OPPROTO op_cvtdg (void)
499
{
500
    helper_cvtdg();
501
    RETURN();
502
}
503

    
504
void OPPROTO op_cvtlq (void)
505
{
506
    helper_cvtlq();
507
    RETURN();
508
}
509

    
510
void OPPROTO op_cvtql (void)
511
{
512
    helper_cvtql();
513
    RETURN();
514
}
515

    
516
void OPPROTO op_cvtqlv (void)
517
{
518
    helper_cvtqlv();
519
    RETURN();
520
}
521

    
522
void OPPROTO op_cvtqlsv (void)
523
{
524
    helper_cvtqlsv();
525
    RETURN();
526
}
527

    
528
/* PALcode support special instructions */
529
#if !defined (CONFIG_USER_ONLY)
530
void OPPROTO op_hw_rei (void)
531
{
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();
536
}
537

    
538
void OPPROTO op_hw_ret (void)
539
{
540
    env->pc = T0 & ~3;
541
    env->ipr[IPR_EXC_ADDR] = T0 & 1;
542
    /* XXX: re-enable interrupts and memory mapping */
543
    RETURN();
544
}
545

    
546
void OPPROTO op_mfpr (void)
547
{
548
    helper_mfpr(PARAM(1));
549
    RETURN();
550
}
551

    
552
void OPPROTO op_mtpr (void)
553
{
554
    helper_mtpr(PARAM(1));
555
    RETURN();
556
}
557

    
558
void OPPROTO op_set_alt_mode (void)
559
{
560
    env->saved_mode = env->ps & 0xC;
561
    env->ps = (env->ps & ~0xC) | (env->ipr[IPR_ALT_MODE] & 0xC);
562
    RETURN();
563
}
564

    
565
void OPPROTO op_restore_mode (void)
566
{
567
    env->ps = (env->ps & ~0xC) | env->saved_mode;
568
    RETURN();
569
}
570

    
571
void OPPROTO op_ld_phys_to_virt (void)
572
{
573
    helper_ld_phys_to_virt();
574
    RETURN();
575
}
576

    
577
void OPPROTO op_st_phys_to_virt (void)
578
{
579
    helper_st_phys_to_virt();
580
    RETURN();
581
}
582
#endif /* !defined (CONFIG_USER_ONLY) */