ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/fpu/exceptions.h
Revision: 1.6
Committed: 2008-01-01T09:40:36Z (16 years, 10 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +1 -1 lines
Error occurred while calculating annotation data.
Log Message:
Happy New Year!

File Contents

# Content
1 /*
2 * fpu/exceptions.h - system-dependant FPU exceptions management
3 *
4 * Basilisk II (C) 1997-2008 Christian Bauer
5 *
6 * MC68881/68040 fpu emulation
7 *
8 * Original UAE FPU, copyright 1996 Herman ten Brugge
9 * Rewrite for x86, copyright 1999-2000 Lauri Pesonen
10 * New framework, copyright 2000 Gwenole Beauchesne
11 * Adapted for JIT compilation (c) Bernd Meyer, 2000
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27
28 #ifndef FPU_EXCEPTIONS_H
29 #define FPU_EXCEPTIONS_H
30
31 /* NOTE: this file shall be included only from fpu/fpu_*.cpp */
32 #undef PUBLIC
33 #define PUBLIC extern
34
35 #undef PRIVATE
36 #define PRIVATE static
37
38 #undef FFPU
39 #define FFPU /**/
40
41 #undef FPU
42 #define FPU fpu.
43
44 /* Defaults to generic exceptions */
45 #define FPU_USE_GENERIC_EXCEPTIONS
46 #define FPU_USE_GENERIC_ACCRUED_EXCEPTIONS
47
48 /* -------------------------------------------------------------------------- */
49 /* --- Selection of floating-point exceptions handling mode --- */
50 /* -------------------------------------------------------------------------- */
51
52 /* Optimized i386 fpu core must use native exceptions */
53 #if defined(FPU_X86) && defined(USE_X87_ASSEMBLY)
54 # undef FPU_USE_GENERIC_EXCEPTIONS
55 # define FPU_USE_X86_EXCEPTIONS
56 #endif
57
58 /* Optimized i386 fpu core must use native accrued exceptions */
59 #if defined(FPU_X86) && defined(USE_X87_ASSEMBLY)
60 # undef FPU_USE_GENERIC_ACCRUED_EXCEPTIONS
61 # define FPU_USE_X86_ACCRUED_EXCEPTIONS
62 #endif
63
64 /* -------------------------------------------------------------------------- */
65 /* --- Native X86 Exceptions --- */
66 /* -------------------------------------------------------------------------- */
67
68 #ifdef FPU_USE_X86_EXCEPTIONS
69
70 /* Extend the SW_* codes */
71 #define SW_FAKE_BSUN SW_SF
72
73 /* Shorthand */
74 #define SW_EXCEPTION_MASK (SW_ES|SW_SF|SW_PE|SW_UE|SW_OE|SW_ZE|SW_DE|SW_IE)
75 // #define SW_EXCEPTION_MASK (SW_SF|SW_PE|SW_UE|SW_OE|SW_ZE|SW_DE|SW_IE)
76
77 /* Lookup tables */
78 PRIVATE uae_u32 exception_host2mac[ 0x80 ];
79 PRIVATE uae_u32 exception_mac2host[ 0x100 ];
80
81 /* Initialize native exception management */
82 PUBLIC void FFPU fpu_init_native_exceptions(void);
83
84 /* Return m68k floating-point exception status */
85 PRIVATE inline uae_u32 FFPU get_exception_status(void)
86 { return exception_host2mac[FPU fpsr.exception_status & (SW_FAKE_BSUN|SW_PE|SW_UE|SW_OE|SW_ZE|SW_DE|SW_IE)]; }
87
88 /* Set new exception status. Assumes mask against FPSR_EXCEPTION to be already performed */
89 PRIVATE inline void FFPU set_exception_status(uae_u32 new_status)
90 { FPU fpsr.exception_status = exception_mac2host[new_status >> 8]; }
91
92 #endif /* FPU_USE_X86_EXCEPTIONS */
93
94 #ifdef FPU_USE_X86_ACCRUED_EXCEPTIONS
95
96 /* Lookup tables */
97 PRIVATE uae_u32 accrued_exception_host2mac[ 0x40 ];
98 PRIVATE uae_u32 accrued_exception_mac2host[ 0x20 ];
99
100 /* Initialize native accrued exception management */
101 PUBLIC void FFPU fpu_init_native_accrued_exceptions(void);
102
103 /* Return m68k accrued exception byte */
104 PRIVATE inline uae_u32 FFPU get_accrued_exception(void)
105 { return accrued_exception_host2mac[FPU fpsr.accrued_exception & (SW_PE|SW_UE|SW_OE|SW_ZE|SW_DE|SW_IE)]; }
106
107 /* Set new accrued exception byte */
108 PRIVATE inline void FFPU set_accrued_exception(uae_u32 new_status)
109 { FPU fpsr.accrued_exception = accrued_exception_mac2host[(new_status & 0xF8) >> 3]; }
110
111 #endif /* FPU_USE_X86_ACCRUED_EXCEPTIONS */
112
113 /* -------------------------------------------------------------------------- */
114 /* --- Default Exceptions Handling --- */
115 /* -------------------------------------------------------------------------- */
116
117 #ifdef FPU_USE_GENERIC_EXCEPTIONS
118
119 /* Initialize native exception management */
120 static inline void FFPU fpu_init_native_exceptions(void)
121 { }
122
123 /* Return m68k floating-point exception status */
124 PRIVATE inline uae_u32 FFPU get_exception_status(void)
125 { return FPU fpsr.exception_status; }
126
127 /* Set new exception status. Assumes mask against FPSR_EXCEPTION to be already performed */
128 PRIVATE inline void FFPU set_exception_status(uae_u32 new_status)
129 { FPU fpsr.exception_status = new_status; }
130
131 #endif /* FPU_USE_GENERIC_EXCEPTIONS */
132
133 #ifdef FPU_USE_GENERIC_ACCRUED_EXCEPTIONS
134
135 /* Initialize native accrued exception management */
136 PRIVATE inline void FFPU fpu_init_native_accrued_exceptions(void)
137 { }
138
139 /* Return m68k accrued exception byte */
140 PRIVATE inline uae_u32 FFPU get_accrued_exception(void)
141 { return FPU fpsr.accrued_exception; }
142
143 /* Set new accrued exception byte */
144 PRIVATE inline void FFPU set_accrued_exception(uae_u32 new_status)
145 { FPU fpsr.accrued_exception = new_status; }
146
147 #endif /* FPU_USE_GENERIC_ACCRUED_EXCEPTIONS */
148
149 #endif /* FPU_EXCEPTIONS_H */