1 /* FPU control word definitions. ARM version.
2 Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #ifndef _FPU_CONTROL_H
21 #define _FPU_CONTROL_H
25 /* masking of interrupts */
26 #define _FPU_MASK_IM 0x00000100 /* invalid operation */
27 #define _FPU_MASK_ZM 0x00000200 /* divide by zero */
28 #define _FPU_MASK_OM 0x00000400 /* overflow */
29 #define _FPU_MASK_UM 0x00000800 /* underflow */
30 #define _FPU_MASK_PM 0x00001000 /* inexact */
32 /* Some bits in the FPSCR are not yet defined. They must be preserved when
33 modifying the contents. */
34 #define _FPU_RESERVED 0x0e08e0e0
35 #define _FPU_DEFAULT 0x00000000
36 /* Default + exceptions enabled. */
37 #define _FPU_IEEE (_FPU_DEFAULT | 0x00001f00)
39 /* Type of the control word. */
40 typedef unsigned int fpu_control_t;
42 /* Macros for accessing the hardware control word. */
43 /* This is fmrx %0, fpscr. */
44 #define _FPU_GETCW(cw) \
45 __asm__ __volatile__ ("mrc p10, 7, %0, cr1, cr0, 0" : "=r" (cw))
46 /* This is fmxr fpscr, %0. */
47 #define _FPU_SETCW(cw) \
48 __asm__ __volatile__ ("mcr p10, 7, %0, cr1, cr0, 0" : : "r" (cw))
50 #elif defined __MAVERICK__
52 /* DSPSC register: (from EP9312 User's Guide)
68 * bits 9..5 - IXE, UFE, OFE, RSVD, IOE
69 * bits 4..0 - IX, UF, OF, RSVD, IO
72 /* masking of interrupts */
73 #define _FPU_MASK_IM (1 << 5) /* invalid operation */
74 #define _FPU_MASK_ZM 0 /* divide by zero */
75 #define _FPU_MASK_OM (1 << 7) /* overflow */
76 #define _FPU_MASK_UM (1 << 8) /* underflow */
77 #define _FPU_MASK_PM (1 << 9) /* inexact */
78 #define _FPU_MASK_DM 0 /* denormalized operation */
80 #define _FPU_RESERVED 0xfffff000 /* These bits are reserved. */
82 #define _FPU_DEFAULT 0x00b00000 /* Default value. */
83 #define _FPU_IEEE 0x00b003a0 /* Default + exceptions enabled. */
85 /* Type of the control word. */
86 typedef unsigned int fpu_control_t;
88 /* Macros for accessing the hardware control word. */
89 #define _FPU_GETCW(cw) ({ \
90 register int __t1, __t2; \
92 __asm__ __volatile__ ( \
93 "cfmvr64l %1, mvdx0\n\t" \
94 "cfmvr64h %2, mvdx0\n\t" \
95 "cfmv32sc mvdx0, dspsc\n\t" \
96 "cfmvr64l %0, mvdx0\n\t" \
97 "cfmv64lr mvdx0, %1\n\t" \
98 "cfmv64hr mvdx0, %2" \
99 : "=r" (cw), "=r" (__t1), "=r" (__t2) \
103 #define _FPU_SETCW(cw) ({ \
104 register int __t0, __t1, __t2; \
106 __asm__ __volatile__ ( \
107 "cfmvr64l %1, mvdx0\n\t" \
108 "cfmvr64h %2, mvdx0\n\t" \
109 "cfmv64lr mvdx0, %0\n\t" \
110 "cfmvsc32 dspsc, mvdx0\n\t" \
111 "cfmv64lr mvdx0, %1\n\t" \
112 "cfmv64hr mvdx0, %2" \
113 : "=r" (__t0), "=r" (__t1), "=r" (__t2) \
118 #else /* !__MAVERICK__ */
120 /* We have a slight terminology confusion here. On the ARM, the register
121 * we're interested in is actually the FPU status word - the FPU control
122 * word is something different (which is implementation-defined and only
123 * accessible from supervisor mode.)
125 * The FPSR looks like this:
127 * 31-24 23-16 15-8 7-0
128 * | system ID | trap enable | system control | exception flags |
130 * We ignore the system ID bits; for interest's sake they are:
137 * The trap enable and exception flags are both structured like this:
140 * | reserved | INX | UFL | OFL | DVZ | IVO |
142 * where a `1' bit in the enable byte means that the trap can occur, and
143 * a `1' bit in the flags byte means the exception has occurred.
145 * The exceptions are:
147 * IVO - invalid operation
148 * DVZ - divide by zero
151 * INX - inexact (do not use; implementations differ)
153 * The system control byte looks like this:
156 * | reserved | AC | EP | SO | NE | ND |
158 * where the bits mean
160 * ND - no denormalised numbers (force them all to zero)
161 * NE - enable NaN exceptions
162 * SO - synchronous operation
163 * EP - use expanded packed-decimal format
164 * AC - use alternate definition for C flag on compare operations
167 /* masking of interrupts */
168 #define _FPU_MASK_IM 0x00010000 /* invalid operation */
169 #define _FPU_MASK_ZM 0x00020000 /* divide by zero */
170 #define _FPU_MASK_OM 0x00040000 /* overflow */
171 #define _FPU_MASK_UM 0x00080000 /* underflow */
172 #define _FPU_MASK_PM 0x00100000 /* inexact */
173 #define _FPU_MASK_DM 0x00000000 /* denormalized operation */
175 /* The system id bytes cannot be changed.
176 Only the bottom 5 bits in the trap enable byte can be changed.
177 Only the bottom 5 bits in the system control byte can be changed.
178 Only the bottom 5 bits in the exception flags are used.
179 The exception flags are set by the fpu, but can be zeroed by the user. */
180 #define _FPU_RESERVED 0xffe0e0e0 /* These bits are reserved. */
182 /* The fdlibm code requires strict IEEE double precision arithmetic,
183 no interrupts for exceptions, rounding to nearest. Changing the
184 rounding mode will break long double I/O. Turn on the AC bit,
185 the compiler generates code that assumes it is on. */
186 #define _FPU_DEFAULT 0x00001000 /* Default value. */
187 #define _FPU_IEEE 0x001f1000 /* Default + exceptions enabled. */
189 /* Type of the control word. */
190 typedef unsigned int fpu_control_t;
192 /* Macros for accessing the hardware control word. */
193 #define _FPU_GETCW(cw) __asm__ ("rfs %0" : "=r" (cw))
194 #define _FPU_SETCW(cw) __asm__ ("wfs %0" : : "r" (cw))
196 #endif /* __MAVERICK__ */
199 /* Default control word set at startup. */
200 extern fpu_control_t __fpu_control;
203 #endif /* _FPU_CONTROL_H */