OLD | NEW |
1 /* | 1 /* |
2 * This file is part of SIS. | 2 * This file is part of SIS. |
3 * | 3 * |
4 * SIS, SPARC instruction simulator. Copyright (C) 1995 Jiri Gaisler, European | 4 * SIS, SPARC instruction simulator. Copyright (C) 1995 Jiri Gaisler, European |
5 * Space Agency | 5 * Space Agency |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify it under | 7 * This program is free software; you can redistribute it and/or modify it under |
8 * the terms of the GNU General Public License as published by the Free | 8 * the terms of the GNU General Public License as published by the Free |
9 * Software Foundation; either version 2 of the License, or (at your option) | 9 * Software Foundation; either version 3 of the License, or (at your option) |
10 * any later version. | 10 * any later version. |
11 * | 11 * |
12 * This program is distributed in the hope that it will be useful, but WITHOUT | 12 * This program is distributed in the hope that it will be useful, but WITHOUT |
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
15 * more details. | 15 * more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU General Public License along with | 17 * You should have received a copy of the GNU General Public License along with |
18 * this program; if not, write to the Free Software Foundation, Inc., 675 | 18 * this program; if not, see <http://www.gnu.org/licenses/>. |
19 * Mass Ave, Cambridge, MA 02139, USA. | |
20 * | 19 * |
21 * | 20 * |
22 * This file implements the interface between the host and the simulated | 21 * This file implements the interface between the host and the simulated |
23 * FPU. IEEE trap handling is done as follows: | 22 * FPU. IEEE trap handling is done as follows: |
24 * 1. In the host, all IEEE traps are masked | 23 * 1. In the host, all IEEE traps are masked |
25 * 2. After each simulated FPU instruction, check if any exception occured | 24 * 2. After each simulated FPU instruction, check if any exception occured |
26 * by reading the exception bits from the host FPU status register | 25 * by reading the exception bits from the host FPU status register |
27 * (get_accex()). | 26 * (get_accex()). |
28 * 3. Propagate any exceptions to the simulated FSR. | 27 * 3. Propagate any exceptions to the simulated FSR. |
29 * 4. Clear host exception bits | 28 * 4. Clear host exception bits |
30 * | 29 * |
31 * | 30 * |
32 * This can also be done using ieee_flags() library routine on sun. | 31 * This can also be done using ieee_flags() library routine on sun. |
33 */ | 32 */ |
34 | 33 |
| 34 #include "config.h" |
35 #include "sis.h" | 35 #include "sis.h" |
36 | 36 |
37 /* Forward declarations */ | 37 /* Forward declarations */ |
38 | 38 |
39 extern uint32 _get_sw PARAMS ((void)); | 39 extern uint32 _get_sw PARAMS ((void)); |
40 extern uint32 _get_cw PARAMS ((void)); | 40 extern uint32 _get_cw PARAMS ((void)); |
41 static void __setfpucw PARAMS ((unsigned short fpu_control)); | 41 static void __setfpucw PARAMS ((unsigned short fpu_control)); |
42 | 42 |
43 /* This host dependent routine should return the accrued exceptions */ | 43 /* This host dependent routine should return the accrued exceptions */ |
44 int | 44 int |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 { | 84 { |
85 #ifdef sparc | 85 #ifdef sparc |
86 _set_fsr_raw(fsr & ~0x0f800000); | 86 _set_fsr_raw(fsr & ~0x0f800000); |
87 #elif i386 | 87 #elif i386 |
88 void __setfpucw(unsigned short fpu_control); | 88 void __setfpucw(unsigned short fpu_control); |
89 uint32 rawfsr; | 89 uint32 rawfsr; |
90 | 90 |
91 fsr >>= 30; | 91 fsr >>= 30; |
92 switch (fsr) { | 92 switch (fsr) { |
93 case 0: | 93 case 0: |
94 » case 2: break; | 94 » case 2: |
95 » case 1: fsr = 3; | 95 » break; |
96 » case 3: fsr = 1; | 96 |
| 97 » case 1: |
| 98 » fsr = 3; |
| 99 » break; |
| 100 |
| 101 » case 3: |
| 102 » fsr = 1; |
| 103 » break; |
97 } | 104 } |
98 rawfsr = _get_cw(); | 105 rawfsr = _get_cw(); |
99 rawfsr |= (fsr << 10) | 0x3ff; | 106 rawfsr |= (fsr << 10) | 0x3ff; |
100 __setfpucw(rawfsr); | 107 __setfpucw(rawfsr); |
101 #else | 108 #else |
102 #warning no fpu trap support for this target | 109 #warning no fpu trap support for this target |
103 #endif | 110 #endif |
104 } | 111 } |
105 | 112 |
106 | 113 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 210 |
204 /* mask in */ | 211 /* mask in */ |
205 cw &= _FPU_RESERVED; | 212 cw &= _FPU_RESERVED; |
206 cw = cw | (fpu_control & ~_FPU_RESERVED); | 213 cw = cw | (fpu_control & ~_FPU_RESERVED); |
207 | 214 |
208 /* set cw */ | 215 /* set cw */ |
209 __asm__ volatile ("fldcw %0" :: "m" (cw)); | 216 __asm__ volatile ("fldcw %0" :: "m" (cw)); |
210 } | 217 } |
211 /* #endif */ | 218 /* #endif */ |
212 #endif | 219 #endif |
OLD | NEW |