]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/fpu_control.h
Inital import
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / arm / fpu_control.h
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.
4
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.
9
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.
14
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
18    02111-1307 USA.  */
19
20 #ifndef _FPU_CONTROL_H
21 #define _FPU_CONTROL_H
22
23 #ifdef __VFP_FP__
24
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 */
31
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)
38
39 /* Type of the control word.  */
40 typedef unsigned int fpu_control_t;
41
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))
49
50 #elif defined __MAVERICK__
51
52 /* DSPSC register: (from EP9312 User's Guide)
53  *
54  * bits 31..29  - DAID
55  * bits 28..26  - HVID
56  * bits 25..24  - RSVD
57  * bit  23      - ISAT
58  * bit  22      - UI
59  * bit  21      - INT
60  * bit  20      - AEXC
61  * bits 19..18  - SAT
62  * bits 17..16  - FCC
63  * bit  15      - V
64  * bit  14      - FWDEN
65  * bit  13      - Invalid
66  * bit  12      - Denorm
67  * bits 11..10  - RM
68  * bits 9..5    - IXE, UFE, OFE, RSVD, IOE
69  * bits 4..0    - IX, UF, OF, RSVD, IO
70  */
71
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 */
79
80 #define _FPU_RESERVED   0xfffff000      /* These bits are reserved.  */
81
82 #define _FPU_DEFAULT    0x00b00000      /* Default value.  */
83 #define _FPU_IEEE       0x00b003a0      /* Default + exceptions enabled. */
84
85 /* Type of the control word.  */
86 typedef unsigned int fpu_control_t;
87
88 /* Macros for accessing the hardware control word.  */
89 #define _FPU_GETCW(cw) ({                       \
90         register int __t1, __t2;                \
91                                                 \
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)   \
100         );                                      \
101 })
102
103 #define _FPU_SETCW(cw) ({                       \
104         register int __t0, __t1, __t2;          \
105                                                 \
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) \
114         : "0" (cw)                              \
115         );                                      \
116 })
117
118 #else /* !__MAVERICK__ */
119
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.)
124  *
125  * The FPSR looks like this:
126  *
127  *     31-24        23-16          15-8              7-0
128  * | system ID | trap enable | system control | exception flags |
129  *
130  * We ignore the system ID bits; for interest's sake they are:
131  *
132  *  0000        "old" FPE
133  *  1000        FPPC hardware
134  *  0001        FPE 400
135  *  1001        FPA hardware
136  *
137  * The trap enable and exception flags are both structured like this:
138  *
139  *     7 - 5     4     3     2     1     0
140  * | reserved | INX | UFL | OFL | DVZ | IVO |
141  *
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.
144  *
145  * The exceptions are:
146  *
147  *  IVO - invalid operation
148  *  DVZ - divide by zero
149  *  OFL - overflow
150  *  UFL - underflow
151  *  INX - inexact (do not use; implementations differ)
152  *
153  * The system control byte looks like this:
154  *
155  *     7-5      4    3    2    1    0
156  * | reserved | AC | EP | SO | NE | ND |
157  *
158  * where the bits mean
159  *
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
165  */
166
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 */
174
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.  */
181
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. */
188
189 /* Type of the control word.  */
190 typedef unsigned int fpu_control_t;
191
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))
195
196 #endif /* __MAVERICK__ */
197
198 #if 0
199 /* Default control word set at startup.  */
200 extern fpu_control_t __fpu_control;
201 #endif
202
203 #endif /* _FPU_CONTROL_H */