This source file includes following definitions.
- parisc_linux_get_fpu_type
- fpudispatch
- emfpudispatch
- decode_0c
- decode_0e
- decode_06
- decode_26
- decode_2e
- update_status_cbit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 #define FPUDEBUG 0
38
39 #include "float.h"
40 #include <linux/bug.h>
41 #include <linux/kernel.h>
42 #include <asm/processor.h>
43
44
45
46 #define COPR_INST 0x30000000
47
48
49
50
51
52 #define extru(r,pos,len) (((r) >> (31-(pos))) & (( 1 << (len)) - 1))
53
54 #define fpmajorpos 5
55 #define fpr1pos 10
56 #define fpr2pos 15
57 #define fptpos 31
58 #define fpsubpos 18
59 #define fpclass1subpos 16
60 #define fpclasspos 22
61 #define fpfmtpos 20
62 #define fpdfpos 18
63 #define fpnulpos 26
64
65
66
67 #define fpxr1pos 24
68 #define fpxr2pos 19
69 #define fpxtpos 25
70 #define fpxpos 23
71 #define fp0efmtpos 20
72
73
74
75 #define fprm1pos 10
76 #define fprm2pos 15
77 #define fptmpos 31
78 #define fprapos 25
79 #define fptapos 20
80 #define fpmultifmt 26
81
82
83
84
85
86 #define fpraupos 18
87 #define fpxrm2pos 19
88
89 #define fpralpos 23
90 #define fpxrm1pos 24
91
92 #define fpfusedsubop 26
93
94
95
96
97
98 #define fpzeroreg (32*sizeof(double)/sizeof(u_int))
99
100
101
102
103 #define get_major(op) extru(op,fpmajorpos,6)
104
105
106
107
108 #define get_class(op) extru(op,fpclasspos,2)
109
110
111
112
113 #define get_subop(op) extru(op,fpsubpos,3)
114
115
116
117
118 #define get_subop1_PA1_1(op) extru(op,fpclass1subpos,2)
119 #define get_subop1_PA2_0(op) extru(op,fpclass1subpos,3)
120
121
122 #define MAJOR_0C_EXCP 0x09
123 #define MAJOR_0E_EXCP 0x0b
124 #define MAJOR_06_EXCP 0x03
125 #define MAJOR_26_EXCP 0x23
126 #define MAJOR_2E_EXCP 0x2b
127 #define PA83_UNIMP_EXCP 0x01
128
129
130
131
132
133 #define FPU_TYPE_FLAG_POS (EM_FPU_TYPE_OFFSET>>2)
134 #define TIMEX_ROLEX_FPU_MASK (TIMEX_EXTEN_FLAG|ROLEX_EXTEN_FLAG)
135
136
137
138
139 #define _PROTOTYPES
140 #if defined(_PROTOTYPES) || defined(_lint)
141 static u_int decode_0c(u_int, u_int, u_int, u_int *);
142 static u_int decode_0e(u_int, u_int, u_int, u_int *);
143 static u_int decode_06(u_int, u_int *);
144 static u_int decode_26(u_int, u_int *);
145 static u_int decode_2e(u_int, u_int *);
146 static void update_status_cbit(u_int *, u_int, u_int, u_int);
147 #else
148 static u_int decode_0c();
149 static u_int decode_0e();
150 static u_int decode_06();
151 static u_int decode_26();
152 static u_int decode_2e();
153 static void update_status_cbit();
154 #endif
155
156 #define VASSERT(x)
157
158 static void parisc_linux_get_fpu_type(u_int fpregs[])
159 {
160
161
162
163 if (boot_cpu_data.cpu_type == pcxs)
164 fpregs[FPU_TYPE_FLAG_POS] = TIMEX_EXTEN_FLAG;
165 else if (boot_cpu_data.cpu_type == pcxt ||
166 boot_cpu_data.cpu_type == pcxt_)
167 fpregs[FPU_TYPE_FLAG_POS] = ROLEX_EXTEN_FLAG;
168 else if (boot_cpu_data.cpu_type >= pcxu)
169 fpregs[FPU_TYPE_FLAG_POS] = PA2_0_FPU_FLAG;
170 }
171
172
173
174
175
176
177
178
179
180
181 u_int
182 fpudispatch(u_int ir, u_int excp_code, u_int holder, u_int fpregs[])
183 {
184 u_int class, subop;
185 u_int fpu_type_flags;
186
187
188 VASSERT(sizeof(int) == 4);
189
190 parisc_linux_get_fpu_type(fpregs);
191
192 fpu_type_flags=fpregs[FPU_TYPE_FLAG_POS];
193
194 class = get_class(ir);
195 if (class == 1) {
196 if (fpu_type_flags & PA2_0_FPU_FLAG)
197 subop = get_subop1_PA2_0(ir);
198 else
199 subop = get_subop1_PA1_1(ir);
200 }
201 else
202 subop = get_subop(ir);
203
204 if (FPUDEBUG) printk("class %d subop %d\n", class, subop);
205
206 switch (excp_code) {
207 case MAJOR_0C_EXCP:
208 case PA83_UNIMP_EXCP:
209 return(decode_0c(ir,class,subop,fpregs));
210 case MAJOR_0E_EXCP:
211 return(decode_0e(ir,class,subop,fpregs));
212 case MAJOR_06_EXCP:
213 return(decode_06(ir,fpregs));
214 case MAJOR_26_EXCP:
215 return(decode_26(ir,fpregs));
216 case MAJOR_2E_EXCP:
217 return(decode_2e(ir,fpregs));
218 default:
219
220
221
222
223
224
225
226
227
228 return(UNIMPLEMENTEDEXCEPTION);
229 }
230 }
231
232
233
234
235
236 u_int
237 emfpudispatch(u_int ir, u_int dummy1, u_int dummy2, u_int fpregs[])
238 {
239 u_int class, subop, major;
240 u_int fpu_type_flags;
241
242
243 VASSERT(sizeof(int) == 4);
244
245 fpu_type_flags=fpregs[FPU_TYPE_FLAG_POS];
246
247 major = get_major(ir);
248 class = get_class(ir);
249 if (class == 1) {
250 if (fpu_type_flags & PA2_0_FPU_FLAG)
251 subop = get_subop1_PA2_0(ir);
252 else
253 subop = get_subop1_PA1_1(ir);
254 }
255 else
256 subop = get_subop(ir);
257 switch (major) {
258 case 0x0C:
259 return(decode_0c(ir,class,subop,fpregs));
260 case 0x0E:
261 return(decode_0e(ir,class,subop,fpregs));
262 case 0x06:
263 return(decode_06(ir,fpregs));
264 case 0x26:
265 return(decode_26(ir,fpregs));
266 case 0x2E:
267 return(decode_2e(ir,fpregs));
268 default:
269 return(PA83_UNIMP_EXCP);
270 }
271 }
272
273
274 static u_int
275 decode_0c(u_int ir, u_int class, u_int subop, u_int fpregs[])
276 {
277 u_int r1,r2,t;
278 u_int fmt;
279 u_int df;
280 u_int *status;
281 u_int retval, local_status;
282 u_int fpu_type_flags;
283
284 if (ir == COPR_INST) {
285 fpregs[0] = EMULATION_VERSION << 11;
286 return(NOEXCEPTION);
287 }
288 status = &fpregs[0];
289 local_status = fpregs[0];
290 r1 = extru(ir,fpr1pos,5) * sizeof(double)/sizeof(u_int);
291 if (r1 == 0)
292 r1 = fpzeroreg;
293 t = extru(ir,fptpos,5) * sizeof(double)/sizeof(u_int);
294 if (t == 0 && class != 2)
295 return(MAJOR_0C_EXCP);
296 fmt = extru(ir,fpfmtpos,2);
297
298 switch (class) {
299 case 0:
300 switch (subop) {
301 case 0:
302 case 1:
303 return(MAJOR_0C_EXCP);
304 case 2:
305 switch (fmt) {
306 case 2:
307 return(MAJOR_0C_EXCP);
308 case 3:
309 t &= ~3;
310 r1 &= ~3;
311 fpregs[t+3] = fpregs[r1+3];
312 fpregs[t+2] = fpregs[r1+2];
313 case 1:
314 fpregs[t+1] = fpregs[r1+1];
315 case 0:
316 fpregs[t] = fpregs[r1];
317 return(NOEXCEPTION);
318 }
319 case 3:
320 switch (fmt) {
321 case 2:
322 return(MAJOR_0C_EXCP);
323 case 3:
324 t &= ~3;
325 r1 &= ~3;
326 fpregs[t+3] = fpregs[r1+3];
327 fpregs[t+2] = fpregs[r1+2];
328 case 1:
329 fpregs[t+1] = fpregs[r1+1];
330 case 0:
331
332 fpregs[t] = fpregs[r1] & 0x7fffffff;
333 return(NOEXCEPTION);
334 }
335 case 6:
336 switch (fmt) {
337 case 2:
338 return(MAJOR_0C_EXCP);
339 case 3:
340 t &= ~3;
341 r1 &= ~3;
342 fpregs[t+3] = fpregs[r1+3];
343 fpregs[t+2] = fpregs[r1+2];
344 case 1:
345 fpregs[t+1] = fpregs[r1+1];
346 case 0:
347
348 fpregs[t] = fpregs[r1] ^ 0x80000000;
349 return(NOEXCEPTION);
350 }
351 case 7:
352 switch (fmt) {
353 case 2:
354 return(MAJOR_0C_EXCP);
355 case 3:
356 t &= ~3;
357 r1 &= ~3;
358 fpregs[t+3] = fpregs[r1+3];
359 fpregs[t+2] = fpregs[r1+2];
360 case 1:
361 fpregs[t+1] = fpregs[r1+1];
362 case 0:
363
364 fpregs[t] = fpregs[r1] | 0x80000000;
365 return(NOEXCEPTION);
366 }
367 case 4:
368 switch (fmt) {
369 case 0:
370 return(sgl_fsqrt(&fpregs[r1],0,
371 &fpregs[t],status));
372 case 1:
373 return(dbl_fsqrt(&fpregs[r1],0,
374 &fpregs[t],status));
375 case 2:
376 case 3:
377 return(MAJOR_0C_EXCP);
378 }
379 case 5:
380 switch (fmt) {
381 case 0:
382 return(sgl_frnd(&fpregs[r1],0,
383 &fpregs[t],status));
384 case 1:
385 return(dbl_frnd(&fpregs[r1],0,
386 &fpregs[t],status));
387 case 2:
388 case 3:
389 return(MAJOR_0C_EXCP);
390 }
391 }
392
393 case 1:
394 df = extru(ir,fpdfpos,2);
395 if ((df & 2) || (fmt & 2)) {
396
397
398
399
400 return(MAJOR_0C_EXCP);
401 }
402
403
404
405
406
407 fmt = (fmt << 1) | df;
408 switch (subop) {
409 case 0:
410 switch(fmt) {
411 case 0:
412 return(MAJOR_0C_EXCP);
413 case 1:
414 return(sgl_to_dbl_fcnvff(&fpregs[r1],0,
415 &fpregs[t],status));
416 case 2:
417 return(dbl_to_sgl_fcnvff(&fpregs[r1],0,
418 &fpregs[t],status));
419 case 3:
420 return(MAJOR_0C_EXCP);
421 }
422 case 1:
423 switch(fmt) {
424 case 0:
425 return(sgl_to_sgl_fcnvxf(&fpregs[r1],0,
426 &fpregs[t],status));
427 case 1:
428 return(sgl_to_dbl_fcnvxf(&fpregs[r1],0,
429 &fpregs[t],status));
430 case 2:
431 return(dbl_to_sgl_fcnvxf(&fpregs[r1],0,
432 &fpregs[t],status));
433 case 3:
434 return(dbl_to_dbl_fcnvxf(&fpregs[r1],0,
435 &fpregs[t],status));
436 }
437 case 2:
438 switch(fmt) {
439 case 0:
440 return(sgl_to_sgl_fcnvfx(&fpregs[r1],0,
441 &fpregs[t],status));
442 case 1:
443 return(sgl_to_dbl_fcnvfx(&fpregs[r1],0,
444 &fpregs[t],status));
445 case 2:
446 return(dbl_to_sgl_fcnvfx(&fpregs[r1],0,
447 &fpregs[t],status));
448 case 3:
449 return(dbl_to_dbl_fcnvfx(&fpregs[r1],0,
450 &fpregs[t],status));
451 }
452 case 3:
453 switch(fmt) {
454 case 0:
455 return(sgl_to_sgl_fcnvfxt(&fpregs[r1],0,
456 &fpregs[t],status));
457 case 1:
458 return(sgl_to_dbl_fcnvfxt(&fpregs[r1],0,
459 &fpregs[t],status));
460 case 2:
461 return(dbl_to_sgl_fcnvfxt(&fpregs[r1],0,
462 &fpregs[t],status));
463 case 3:
464 return(dbl_to_dbl_fcnvfxt(&fpregs[r1],0,
465 &fpregs[t],status));
466 }
467 case 5:
468 switch(fmt) {
469 case 0:
470 return(sgl_to_sgl_fcnvuf(&fpregs[r1],0,
471 &fpregs[t],status));
472 case 1:
473 return(sgl_to_dbl_fcnvuf(&fpregs[r1],0,
474 &fpregs[t],status));
475 case 2:
476 return(dbl_to_sgl_fcnvuf(&fpregs[r1],0,
477 &fpregs[t],status));
478 case 3:
479 return(dbl_to_dbl_fcnvuf(&fpregs[r1],0,
480 &fpregs[t],status));
481 }
482 case 6:
483 switch(fmt) {
484 case 0:
485 return(sgl_to_sgl_fcnvfu(&fpregs[r1],0,
486 &fpregs[t],status));
487 case 1:
488 return(sgl_to_dbl_fcnvfu(&fpregs[r1],0,
489 &fpregs[t],status));
490 case 2:
491 return(dbl_to_sgl_fcnvfu(&fpregs[r1],0,
492 &fpregs[t],status));
493 case 3:
494 return(dbl_to_dbl_fcnvfu(&fpregs[r1],0,
495 &fpregs[t],status));
496 }
497 case 7:
498 switch(fmt) {
499 case 0:
500 return(sgl_to_sgl_fcnvfut(&fpregs[r1],0,
501 &fpregs[t],status));
502 case 1:
503 return(sgl_to_dbl_fcnvfut(&fpregs[r1],0,
504 &fpregs[t],status));
505 case 2:
506 return(dbl_to_sgl_fcnvfut(&fpregs[r1],0,
507 &fpregs[t],status));
508 case 3:
509 return(dbl_to_dbl_fcnvfut(&fpregs[r1],0,
510 &fpregs[t],status));
511 }
512 case 4:
513 return(MAJOR_0C_EXCP);
514 }
515
516 case 2:
517 fpu_type_flags=fpregs[FPU_TYPE_FLAG_POS];
518 r2 = extru(ir, fpr2pos, 5) * sizeof(double)/sizeof(u_int);
519 if (r2 == 0)
520 r2 = fpzeroreg;
521 if (fpu_type_flags & PA2_0_FPU_FLAG) {
522
523 if (extru(ir, fpnulpos, 1)) {
524 switch (fmt) {
525 case 0:
526
527
528
529
530
531
532 BUG();
533
534
535
536
537 case 1:
538 case 2:
539 case 3:
540 return(MAJOR_0C_EXCP);
541 }
542 } else {
543 switch (fmt) {
544 case 0:
545 retval = sgl_fcmp(&fpregs[r1],
546 &fpregs[r2],extru(ir,fptpos,5),
547 &local_status);
548 update_status_cbit(status,local_status,
549 fpu_type_flags, subop);
550 return(retval);
551 case 1:
552 retval = dbl_fcmp(&fpregs[r1],
553 &fpregs[r2],extru(ir,fptpos,5),
554 &local_status);
555 update_status_cbit(status,local_status,
556 fpu_type_flags, subop);
557 return(retval);
558 case 2:
559 case 3:
560 return(MAJOR_0C_EXCP);
561 }
562 }
563 }
564 else {
565 switch (subop) {
566 case 2:
567 case 3:
568 case 4:
569 case 5:
570 case 6:
571 case 7:
572 return(MAJOR_0C_EXCP);
573 case 0:
574 switch (fmt) {
575 case 0:
576 retval = sgl_fcmp(&fpregs[r1],
577 &fpregs[r2],extru(ir,fptpos,5),
578 &local_status);
579 update_status_cbit(status,local_status,
580 fpu_type_flags, subop);
581 return(retval);
582 case 1:
583 retval = dbl_fcmp(&fpregs[r1],
584 &fpregs[r2],extru(ir,fptpos,5),
585 &local_status);
586 update_status_cbit(status,local_status,
587 fpu_type_flags, subop);
588 return(retval);
589 case 2:
590 case 3:
591 return(MAJOR_0C_EXCP);
592 }
593 case 1:
594 switch (fmt) {
595 case 0:
596
597
598
599
600
601
602 BUG();
603
604
605
606
607 case 1:
608 case 2:
609 case 3:
610 return(MAJOR_0C_EXCP);
611 }
612 }
613 }
614 case 3:
615 r2 = extru(ir,fpr2pos,5) * sizeof(double)/sizeof(u_int);
616 if (r2 == 0)
617 r2 = fpzeroreg;
618 switch (subop) {
619 case 5:
620 case 6:
621 case 7:
622 return(MAJOR_0C_EXCP);
623
624 case 0:
625 switch (fmt) {
626 case 0:
627 return(sgl_fadd(&fpregs[r1],&fpregs[r2],
628 &fpregs[t],status));
629 case 1:
630 return(dbl_fadd(&fpregs[r1],&fpregs[r2],
631 &fpregs[t],status));
632 case 2:
633 case 3:
634 return(MAJOR_0C_EXCP);
635 }
636 case 1:
637 switch (fmt) {
638 case 0:
639 return(sgl_fsub(&fpregs[r1],&fpregs[r2],
640 &fpregs[t],status));
641 case 1:
642 return(dbl_fsub(&fpregs[r1],&fpregs[r2],
643 &fpregs[t],status));
644 case 2:
645 case 3:
646 return(MAJOR_0C_EXCP);
647 }
648 case 2:
649 switch (fmt) {
650 case 0:
651 return(sgl_fmpy(&fpregs[r1],&fpregs[r2],
652 &fpregs[t],status));
653 case 1:
654 return(dbl_fmpy(&fpregs[r1],&fpregs[r2],
655 &fpregs[t],status));
656 case 2:
657 case 3:
658 return(MAJOR_0C_EXCP);
659 }
660 case 3:
661 switch (fmt) {
662 case 0:
663 return(sgl_fdiv(&fpregs[r1],&fpregs[r2],
664 &fpregs[t],status));
665 case 1:
666 return(dbl_fdiv(&fpregs[r1],&fpregs[r2],
667 &fpregs[t],status));
668 case 2:
669 case 3:
670 return(MAJOR_0C_EXCP);
671 }
672 case 4:
673 switch (fmt) {
674 case 0:
675 return(sgl_frem(&fpregs[r1],&fpregs[r2],
676 &fpregs[t],status));
677 case 1:
678 return(dbl_frem(&fpregs[r1],&fpregs[r2],
679 &fpregs[t],status));
680 case 2:
681 case 3:
682 return(MAJOR_0C_EXCP);
683 }
684 }
685 }
686
687
688 return(MAJOR_0C_EXCP);
689 }
690
691 static u_int
692 decode_0e(ir,class,subop,fpregs)
693 u_int ir,class,subop;
694 u_int fpregs[];
695 {
696 u_int r1,r2,t;
697 u_int fmt;
698 u_int df;
699 u_int *status;
700 u_int retval, local_status;
701 u_int fpu_type_flags;
702
703 status = &fpregs[0];
704 local_status = fpregs[0];
705 r1 = ((extru(ir,fpr1pos,5)<<1)|(extru(ir,fpxr1pos,1)));
706 if (r1 == 0)
707 r1 = fpzeroreg;
708 t = ((extru(ir,fptpos,5)<<1)|(extru(ir,fpxtpos,1)));
709 if (t == 0 && class != 2)
710 return(MAJOR_0E_EXCP);
711 if (class < 2)
712 fmt = extru(ir,fpfmtpos,2);
713 else
714 fmt = extru(ir,fp0efmtpos,1);
715
716
717
718
719
720 if (fmt == DBL) {
721 r1 &= ~1;
722 if (class != 1)
723 t &= ~1;
724 }
725
726 switch (class) {
727 case 0:
728 switch (subop) {
729 case 0:
730 case 1:
731 return(MAJOR_0E_EXCP);
732 case 2:
733 switch (fmt) {
734 case 2:
735 case 3:
736 return(MAJOR_0E_EXCP);
737 case 1:
738 fpregs[t+1] = fpregs[r1+1];
739 case 0:
740 fpregs[t] = fpregs[r1];
741 return(NOEXCEPTION);
742 }
743 case 3:
744 switch (fmt) {
745 case 2:
746 case 3:
747 return(MAJOR_0E_EXCP);
748 case 1:
749 fpregs[t+1] = fpregs[r1+1];
750 case 0:
751 fpregs[t] = fpregs[r1] & 0x7fffffff;
752 return(NOEXCEPTION);
753 }
754 case 6:
755 switch (fmt) {
756 case 2:
757 case 3:
758 return(MAJOR_0E_EXCP);
759 case 1:
760 fpregs[t+1] = fpregs[r1+1];
761 case 0:
762 fpregs[t] = fpregs[r1] ^ 0x80000000;
763 return(NOEXCEPTION);
764 }
765 case 7:
766 switch (fmt) {
767 case 2:
768 case 3:
769 return(MAJOR_0E_EXCP);
770 case 1:
771 fpregs[t+1] = fpregs[r1+1];
772 case 0:
773 fpregs[t] = fpregs[r1] | 0x80000000;
774 return(NOEXCEPTION);
775 }
776 case 4:
777 switch (fmt) {
778 case 0:
779 return(sgl_fsqrt(&fpregs[r1],0,
780 &fpregs[t], status));
781 case 1:
782 return(dbl_fsqrt(&fpregs[r1],0,
783 &fpregs[t], status));
784 case 2:
785 case 3:
786 return(MAJOR_0E_EXCP);
787 }
788 case 5:
789 switch (fmt) {
790 case 0:
791 return(sgl_frnd(&fpregs[r1],0,
792 &fpregs[t], status));
793 case 1:
794 return(dbl_frnd(&fpregs[r1],0,
795 &fpregs[t], status));
796 case 2:
797 case 3:
798 return(MAJOR_0E_EXCP);
799 }
800 }
801
802 case 1:
803 df = extru(ir,fpdfpos,2);
804
805
806
807
808 if (df == DBL) {
809 t &= ~1;
810 }
811 if ((df & 2) || (fmt & 2))
812 return(MAJOR_0E_EXCP);
813
814 fmt = (fmt << 1) | df;
815 switch (subop) {
816 case 0:
817 switch(fmt) {
818 case 0:
819 return(MAJOR_0E_EXCP);
820 case 1:
821 return(sgl_to_dbl_fcnvff(&fpregs[r1],0,
822 &fpregs[t],status));
823 case 2:
824 return(dbl_to_sgl_fcnvff(&fpregs[r1],0,
825 &fpregs[t],status));
826 case 3:
827 return(MAJOR_0E_EXCP);
828 }
829 case 1:
830 switch(fmt) {
831 case 0:
832 return(sgl_to_sgl_fcnvxf(&fpregs[r1],0,
833 &fpregs[t],status));
834 case 1:
835 return(sgl_to_dbl_fcnvxf(&fpregs[r1],0,
836 &fpregs[t],status));
837 case 2:
838 return(dbl_to_sgl_fcnvxf(&fpregs[r1],0,
839 &fpregs[t],status));
840 case 3:
841 return(dbl_to_dbl_fcnvxf(&fpregs[r1],0,
842 &fpregs[t],status));
843 }
844 case 2:
845 switch(fmt) {
846 case 0:
847 return(sgl_to_sgl_fcnvfx(&fpregs[r1],0,
848 &fpregs[t],status));
849 case 1:
850 return(sgl_to_dbl_fcnvfx(&fpregs[r1],0,
851 &fpregs[t],status));
852 case 2:
853 return(dbl_to_sgl_fcnvfx(&fpregs[r1],0,
854 &fpregs[t],status));
855 case 3:
856 return(dbl_to_dbl_fcnvfx(&fpregs[r1],0,
857 &fpregs[t],status));
858 }
859 case 3:
860 switch(fmt) {
861 case 0:
862 return(sgl_to_sgl_fcnvfxt(&fpregs[r1],0,
863 &fpregs[t],status));
864 case 1:
865 return(sgl_to_dbl_fcnvfxt(&fpregs[r1],0,
866 &fpregs[t],status));
867 case 2:
868 return(dbl_to_sgl_fcnvfxt(&fpregs[r1],0,
869 &fpregs[t],status));
870 case 3:
871 return(dbl_to_dbl_fcnvfxt(&fpregs[r1],0,
872 &fpregs[t],status));
873 }
874 case 5:
875 switch(fmt) {
876 case 0:
877 return(sgl_to_sgl_fcnvuf(&fpregs[r1],0,
878 &fpregs[t],status));
879 case 1:
880 return(sgl_to_dbl_fcnvuf(&fpregs[r1],0,
881 &fpregs[t],status));
882 case 2:
883 return(dbl_to_sgl_fcnvuf(&fpregs[r1],0,
884 &fpregs[t],status));
885 case 3:
886 return(dbl_to_dbl_fcnvuf(&fpregs[r1],0,
887 &fpregs[t],status));
888 }
889 case 6:
890 switch(fmt) {
891 case 0:
892 return(sgl_to_sgl_fcnvfu(&fpregs[r1],0,
893 &fpregs[t],status));
894 case 1:
895 return(sgl_to_dbl_fcnvfu(&fpregs[r1],0,
896 &fpregs[t],status));
897 case 2:
898 return(dbl_to_sgl_fcnvfu(&fpregs[r1],0,
899 &fpregs[t],status));
900 case 3:
901 return(dbl_to_dbl_fcnvfu(&fpregs[r1],0,
902 &fpregs[t],status));
903 }
904 case 7:
905 switch(fmt) {
906 case 0:
907 return(sgl_to_sgl_fcnvfut(&fpregs[r1],0,
908 &fpregs[t],status));
909 case 1:
910 return(sgl_to_dbl_fcnvfut(&fpregs[r1],0,
911 &fpregs[t],status));
912 case 2:
913 return(dbl_to_sgl_fcnvfut(&fpregs[r1],0,
914 &fpregs[t],status));
915 case 3:
916 return(dbl_to_dbl_fcnvfut(&fpregs[r1],0,
917 &fpregs[t],status));
918 }
919 case 4:
920 return(MAJOR_0C_EXCP);
921 }
922 case 2:
923
924
925
926
927
928
929
930
931 if (fmt == DBL)
932 r2 = (extru(ir,fpr2pos,5)<<1);
933 else
934 r2 = ((extru(ir,fpr2pos,5)<<1)|(extru(ir,fpxr2pos,1)));
935 fpu_type_flags=fpregs[FPU_TYPE_FLAG_POS];
936 if (r2 == 0)
937 r2 = fpzeroreg;
938 if (fpu_type_flags & PA2_0_FPU_FLAG) {
939
940 if (extru(ir, fpnulpos, 1)) {
941
942 return(MAJOR_0E_EXCP);
943 } else {
944 switch (fmt) {
945
946
947
948 case 0:
949 retval = sgl_fcmp(&fpregs[r1],
950 &fpregs[r2],extru(ir,fptpos,5),
951 &local_status);
952 update_status_cbit(status,local_status,
953 fpu_type_flags, subop);
954 return(retval);
955 case 1:
956 retval = dbl_fcmp(&fpregs[r1],
957 &fpregs[r2],extru(ir,fptpos,5),
958 &local_status);
959 update_status_cbit(status,local_status,
960 fpu_type_flags, subop);
961 return(retval);
962 }
963 }
964 }
965 else {
966 switch (subop) {
967 case 1:
968 case 2:
969 case 3:
970 case 4:
971 case 5:
972 case 6:
973 case 7:
974 return(MAJOR_0E_EXCP);
975 case 0:
976 switch (fmt) {
977
978
979
980 case 0:
981 retval = sgl_fcmp(&fpregs[r1],
982 &fpregs[r2],extru(ir,fptpos,5),
983 &local_status);
984 update_status_cbit(status,local_status,
985 fpu_type_flags, subop);
986 return(retval);
987 case 1:
988 retval = dbl_fcmp(&fpregs[r1],
989 &fpregs[r2],extru(ir,fptpos,5),
990 &local_status);
991 update_status_cbit(status,local_status,
992 fpu_type_flags, subop);
993 return(retval);
994 }
995 }
996 }
997 case 3:
998
999
1000
1001
1002
1003
1004
1005
1006 if (fmt == DBL)
1007 r2 = (extru(ir,fpr2pos,5)<<1);
1008 else
1009 r2 = ((extru(ir,fpr2pos,5)<<1)|(extru(ir,fpxr2pos,1)));
1010 if (r2 == 0)
1011 r2 = fpzeroreg;
1012 switch (subop) {
1013 case 5:
1014 case 6:
1015 case 7:
1016 return(MAJOR_0E_EXCP);
1017
1018
1019
1020 case 0:
1021 switch (fmt) {
1022 case 0:
1023 return(sgl_fadd(&fpregs[r1],&fpregs[r2],
1024 &fpregs[t],status));
1025 case 1:
1026 return(dbl_fadd(&fpregs[r1],&fpregs[r2],
1027 &fpregs[t],status));
1028 }
1029 case 1:
1030 switch (fmt) {
1031 case 0:
1032 return(sgl_fsub(&fpregs[r1],&fpregs[r2],
1033 &fpregs[t],status));
1034 case 1:
1035 return(dbl_fsub(&fpregs[r1],&fpregs[r2],
1036 &fpregs[t],status));
1037 }
1038 case 2:
1039
1040
1041
1042 if (extru(ir,fpxpos,1)) {
1043
1044
1045
1046 switch (fmt) {
1047 case 0:
1048
1049
1050
1051
1052 if (t & 1)
1053 return(MAJOR_0E_EXCP);
1054 BUG();
1055
1056
1057
1058
1059 return(NOEXCEPTION);
1060 case 1:
1061 return(MAJOR_0E_EXCP);
1062 }
1063 }
1064 else {
1065 switch (fmt) {
1066 case 0:
1067 return(sgl_fmpy(&fpregs[r1],
1068 &fpregs[r2],&fpregs[t],status));
1069 case 1:
1070 return(dbl_fmpy(&fpregs[r1],
1071 &fpregs[r2],&fpregs[t],status));
1072 }
1073 }
1074 case 3:
1075 switch (fmt) {
1076 case 0:
1077 return(sgl_fdiv(&fpregs[r1],&fpregs[r2],
1078 &fpregs[t],status));
1079 case 1:
1080 return(dbl_fdiv(&fpregs[r1],&fpregs[r2],
1081 &fpregs[t],status));
1082 }
1083 case 4:
1084 switch (fmt) {
1085 case 0:
1086 return(sgl_frem(&fpregs[r1],&fpregs[r2],
1087 &fpregs[t],status));
1088 case 1:
1089 return(dbl_frem(&fpregs[r1],&fpregs[r2],
1090 &fpregs[t],status));
1091 }
1092 }
1093 }
1094
1095
1096 return(MAJOR_0E_EXCP);
1097 }
1098
1099
1100
1101
1102
1103 static u_int
1104 decode_06(ir,fpregs)
1105 u_int ir;
1106 u_int fpregs[];
1107 {
1108 u_int rm1, rm2, tm, ra, ta;
1109 u_int fmt;
1110 u_int error = 0;
1111 u_int status;
1112 u_int fpu_type_flags;
1113 union {
1114 double dbl;
1115 float flt;
1116 struct { u_int i1; u_int i2; } ints;
1117 } mtmp, atmp;
1118
1119
1120 status = fpregs[0];
1121 fpu_type_flags=fpregs[FPU_TYPE_FLAG_POS];
1122 fmt = extru(ir, fpmultifmt, 1);
1123 if (fmt == 0) {
1124 rm1 = extru(ir, fprm1pos, 5) * sizeof(double)/sizeof(u_int);
1125 if (rm1 == 0)
1126 rm1 = fpzeroreg;
1127 rm2 = extru(ir, fprm2pos, 5) * sizeof(double)/sizeof(u_int);
1128 if (rm2 == 0)
1129 rm2 = fpzeroreg;
1130 tm = extru(ir, fptmpos, 5) * sizeof(double)/sizeof(u_int);
1131 if (tm == 0)
1132 return(MAJOR_06_EXCP);
1133 ra = extru(ir, fprapos, 5) * sizeof(double)/sizeof(u_int);
1134 ta = extru(ir, fptapos, 5) * sizeof(double)/sizeof(u_int);
1135 if (ta == 0)
1136 return(MAJOR_06_EXCP);
1137
1138 if (fpu_type_flags & TIMEX_ROLEX_FPU_MASK) {
1139
1140 if (ra == 0) {
1141
1142 if (dbl_fmpy(&fpregs[rm1],&fpregs[rm2],
1143 &mtmp.ints.i1,&status))
1144 error = 1;
1145 if (dbl_to_sgl_fcnvfxt(&fpregs[ta],
1146 &atmp.ints.i1,&atmp.ints.i1,&status))
1147 error = 1;
1148 }
1149 else {
1150
1151 if (dbl_fmpy(&fpregs[rm1],&fpregs[rm2],&mtmp.ints.i1,
1152 &status))
1153 error = 1;
1154 if (dbl_fadd(&fpregs[ta], &fpregs[ra], &atmp.ints.i1,
1155 &status))
1156 error = 1;
1157 }
1158 }
1159
1160 else
1161
1162 {
1163 if (ra == 0)
1164 ra = fpzeroreg;
1165
1166 if (dbl_fmpy(&fpregs[rm1],&fpregs[rm2],&mtmp.ints.i1,
1167 &status))
1168 error = 1;
1169 if (dbl_fadd(&fpregs[ta], &fpregs[ra], &atmp.ints.i1,
1170 &status))
1171 error = 1;
1172
1173 }
1174
1175 if (error)
1176 return(MAJOR_06_EXCP);
1177 else {
1178
1179 fpregs[tm] = mtmp.ints.i1;
1180 fpregs[tm+1] = mtmp.ints.i2;
1181 fpregs[ta] = atmp.ints.i1;
1182 fpregs[ta+1] = atmp.ints.i2;
1183 fpregs[0] = status;
1184 return(NOEXCEPTION);
1185 }
1186 }
1187 else {
1188
1189
1190
1191
1192 rm1 = (extru(ir,fprm1pos,4) | 0x10 ) << 1;
1193 rm1 |= extru(ir,fprm1pos-4,1);
1194
1195 rm2 = (extru(ir,fprm2pos,4) | 0x10 ) << 1;
1196 rm2 |= extru(ir,fprm2pos-4,1);
1197
1198 tm = (extru(ir,fptmpos,4) | 0x10 ) << 1;
1199 tm |= extru(ir,fptmpos-4,1);
1200
1201 ra = (extru(ir,fprapos,4) | 0x10 ) << 1;
1202 ra |= extru(ir,fprapos-4,1);
1203
1204 ta = (extru(ir,fptapos,4) | 0x10 ) << 1;
1205 ta |= extru(ir,fptapos-4,1);
1206
1207 if (ra == 0x20 &&(fpu_type_flags & TIMEX_ROLEX_FPU_MASK)) {
1208
1209
1210
1211
1212
1213 if (sgl_fmpy(&fpregs[rm1],&fpregs[rm2],&mtmp.ints.i1,
1214 &status))
1215 error = 1;
1216 if (sgl_to_sgl_fcnvfxt(&fpregs[ta],&atmp.ints.i1,
1217 &atmp.ints.i1,&status))
1218 error = 1;
1219 }
1220 else {
1221 if (sgl_fmpy(&fpregs[rm1],&fpregs[rm2],&mtmp.ints.i1,
1222 &status))
1223 error = 1;
1224 if (sgl_fadd(&fpregs[ta], &fpregs[ra], &atmp.ints.i1,
1225 &status))
1226 error = 1;
1227 }
1228 if (error)
1229 return(MAJOR_06_EXCP);
1230 else {
1231
1232 fpregs[tm] = mtmp.ints.i1;
1233 fpregs[ta] = atmp.ints.i1;
1234 fpregs[0] = status;
1235 return(NOEXCEPTION);
1236 }
1237 }
1238 }
1239
1240
1241
1242
1243 static u_int
1244 decode_26(ir,fpregs)
1245 u_int ir;
1246 u_int fpregs[];
1247 {
1248 u_int rm1, rm2, tm, ra, ta;
1249 u_int fmt;
1250 u_int error = 0;
1251 u_int status;
1252 union {
1253 double dbl;
1254 float flt;
1255 struct { u_int i1; u_int i2; } ints;
1256 } mtmp, atmp;
1257
1258
1259 status = fpregs[0];
1260 fmt = extru(ir, fpmultifmt, 1);
1261 if (fmt == 0) {
1262 rm1 = extru(ir, fprm1pos, 5) * sizeof(double)/sizeof(u_int);
1263 if (rm1 == 0)
1264 rm1 = fpzeroreg;
1265 rm2 = extru(ir, fprm2pos, 5) * sizeof(double)/sizeof(u_int);
1266 if (rm2 == 0)
1267 rm2 = fpzeroreg;
1268 tm = extru(ir, fptmpos, 5) * sizeof(double)/sizeof(u_int);
1269 if (tm == 0)
1270 return(MAJOR_26_EXCP);
1271 ra = extru(ir, fprapos, 5) * sizeof(double)/sizeof(u_int);
1272 if (ra == 0)
1273 return(MAJOR_26_EXCP);
1274 ta = extru(ir, fptapos, 5) * sizeof(double)/sizeof(u_int);
1275 if (ta == 0)
1276 return(MAJOR_26_EXCP);
1277
1278 if (dbl_fmpy(&fpregs[rm1],&fpregs[rm2],&mtmp.ints.i1,&status))
1279 error = 1;
1280 if (dbl_fsub(&fpregs[ta], &fpregs[ra], &atmp.ints.i1,&status))
1281 error = 1;
1282 if (error)
1283 return(MAJOR_26_EXCP);
1284 else {
1285
1286 fpregs[tm] = mtmp.ints.i1;
1287 fpregs[tm+1] = mtmp.ints.i2;
1288 fpregs[ta] = atmp.ints.i1;
1289 fpregs[ta+1] = atmp.ints.i2;
1290 fpregs[0] = status;
1291 return(NOEXCEPTION);
1292 }
1293 }
1294 else {
1295
1296
1297
1298
1299 rm1 = (extru(ir,fprm1pos,4) | 0x10 ) << 1;
1300 rm1 |= extru(ir,fprm1pos-4,1);
1301
1302 rm2 = (extru(ir,fprm2pos,4) | 0x10 ) << 1;
1303 rm2 |= extru(ir,fprm2pos-4,1);
1304
1305 tm = (extru(ir,fptmpos,4) | 0x10 ) << 1;
1306 tm |= extru(ir,fptmpos-4,1);
1307
1308 ra = (extru(ir,fprapos,4) | 0x10 ) << 1;
1309 ra |= extru(ir,fprapos-4,1);
1310
1311 ta = (extru(ir,fptapos,4) | 0x10 ) << 1;
1312 ta |= extru(ir,fptapos-4,1);
1313
1314 if (sgl_fmpy(&fpregs[rm1],&fpregs[rm2],&mtmp.ints.i1,&status))
1315 error = 1;
1316 if (sgl_fsub(&fpregs[ta], &fpregs[ra], &atmp.ints.i1,&status))
1317 error = 1;
1318 if (error)
1319 return(MAJOR_26_EXCP);
1320 else {
1321
1322 fpregs[tm] = mtmp.ints.i1;
1323 fpregs[ta] = atmp.ints.i1;
1324 fpregs[0] = status;
1325 return(NOEXCEPTION);
1326 }
1327 }
1328
1329 }
1330
1331
1332
1333
1334 static u_int
1335 decode_2e(ir,fpregs)
1336 u_int ir;
1337 u_int fpregs[];
1338 {
1339 u_int rm1, rm2, ra, t;
1340 u_int fmt;
1341
1342 fmt = extru(ir,fpfmtpos,1);
1343 if (fmt == DBL) {
1344 rm1 = extru(ir,fprm1pos,5) * sizeof(double)/sizeof(u_int);
1345 if (rm1 == 0)
1346 rm1 = fpzeroreg;
1347 rm2 = extru(ir,fprm2pos,5) * sizeof(double)/sizeof(u_int);
1348 if (rm2 == 0)
1349 rm2 = fpzeroreg;
1350 ra = ((extru(ir,fpraupos,3)<<2)|(extru(ir,fpralpos,3)>>1)) *
1351 sizeof(double)/sizeof(u_int);
1352 if (ra == 0)
1353 ra = fpzeroreg;
1354 t = extru(ir,fptpos,5) * sizeof(double)/sizeof(u_int);
1355 if (t == 0)
1356 return(MAJOR_2E_EXCP);
1357
1358 if (extru(ir,fpfusedsubop,1)) {
1359 return(dbl_fmpynfadd(&fpregs[rm1], &fpregs[rm2],
1360 &fpregs[ra], &fpregs[0], &fpregs[t]));
1361 } else {
1362 return(dbl_fmpyfadd(&fpregs[rm1], &fpregs[rm2],
1363 &fpregs[ra], &fpregs[0], &fpregs[t]));
1364 }
1365 }
1366 else {
1367 rm1 = (extru(ir,fprm1pos,5)<<1)|(extru(ir,fpxrm1pos,1));
1368 if (rm1 == 0)
1369 rm1 = fpzeroreg;
1370 rm2 = (extru(ir,fprm2pos,5)<<1)|(extru(ir,fpxrm2pos,1));
1371 if (rm2 == 0)
1372 rm2 = fpzeroreg;
1373 ra = (extru(ir,fpraupos,3)<<3)|extru(ir,fpralpos,3);
1374 if (ra == 0)
1375 ra = fpzeroreg;
1376 t = ((extru(ir,fptpos,5)<<1)|(extru(ir,fpxtpos,1)));
1377 if (t == 0)
1378 return(MAJOR_2E_EXCP);
1379
1380 if (extru(ir,fpfusedsubop,1)) {
1381 return(sgl_fmpynfadd(&fpregs[rm1], &fpregs[rm2],
1382 &fpregs[ra], &fpregs[0], &fpregs[t]));
1383 } else {
1384 return(sgl_fmpyfadd(&fpregs[rm1], &fpregs[rm2],
1385 &fpregs[ra], &fpregs[0], &fpregs[t]));
1386 }
1387 }
1388 }
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400 static void
1401 update_status_cbit(status, new_status, fpu_type, y_field)
1402 u_int *status, new_status;
1403 u_int fpu_type;
1404 u_int y_field;
1405 {
1406
1407
1408
1409
1410
1411
1412 if ((fpu_type & TIMEX_EXTEN_FLAG) ||
1413 (fpu_type & ROLEX_EXTEN_FLAG) ||
1414 (fpu_type & PA2_0_FPU_FLAG)) {
1415 if (y_field == 0) {
1416 *status = ((*status & 0x04000000) >> 5) |
1417 ((*status & 0x003ff000) >> 1) |
1418 (new_status & 0xffc007ff);
1419 } else {
1420 *status = (*status & 0x04000000) |
1421 ((new_status & 0x04000000) >> (y_field+4)) |
1422 (new_status & ~0x04000000 &
1423 ~(0x04000000 >> (y_field+4)));
1424 }
1425 }
1426
1427 else {
1428 *status = new_status;
1429 }
1430 }