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
23 /* We have a slight terminology confusion here. On the ARM, the register
24 * we're interested in is actually the FPU status word - the FPU control
25 * word is something different (which is implementation-defined and only
26 * accessible from supervisor mode.)
28 * The FPSR looks like this:
30 * 31-24 23-16 15-8 7-0
31 * | system ID | trap enable | system control | exception flags |
33 * We ignore the system ID bits; for interest's sake they are:
40 * The trap enable and exception flags are both structured like this:
43 * | reserved | INX | UFL | OFL | DVZ | IVO |
45 * where a `1' bit in the enable byte means that the trap can occur, and
46 * a `1' bit in the flags byte means the exception has occurred.
50 * IVO - invalid operation
51 * DVZ - divide by zero
54 * INX - inexact (do not use; implementations differ)
56 * The system control byte looks like this:
59 * | reserved | AC | EP | SO | NE | ND |
63 * ND - no denormalised numbers (force them all to zero)
64 * NE - enable NaN exceptions
65 * SO - synchronous operation
66 * EP - use expanded packed-decimal format
67 * AC - use alternate definition for C flag on compare operations
70 /* masking of interrupts */
71 #define _FPU_MASK_IM 0x00010000 /* invalid operation */
72 #define _FPU_MASK_ZM 0x00020000 /* divide by zero */
73 #define _FPU_MASK_OM 0x00040000 /* overflow */
74 #define _FPU_MASK_UM 0x00080000 /* underflow */
75 #define _FPU_MASK_PM 0x00100000 /* inexact */
76 #define _FPU_MASK_DM 0x00000000 /* denormalized operation */
78 /* The system id bytes cannot be changed.
79 Only the bottom 5 bits in the trap enable byte can be changed.
80 Only the bottom 5 bits in the system control byte can be changed.
81 Only the bottom 5 bits in the exception flags are used.
82 The exception flags are set by the fpu, but can be zeroed by the user. */
83 #define _FPU_RESERVED 0xffe0e0e0 /* These bits are reserved. */
85 /* The fdlibm code requires strict IEEE double precision arithmetic,
86 no interrupts for exceptions, rounding to nearest. Changing the
87 rounding mode will break long double I/O. Turn on the AC bit,
88 the compiler generates code that assumes it is on. */
89 #define _FPU_DEFAULT 0x00001000 /* Default value. */
90 #define _FPU_IEEE 0x001f1000 /* Default + exceptions enabled. */
92 /* Type of the control word. */
93 typedef unsigned int fpu_control_t
;
95 /* Macros for accessing the hardware control word. */
96 #define _FPU_GETCW(cw) __asm__ ("rfs %0" : "=r" (cw))
97 #define _FPU_SETCW(cw) __asm__ ("wfs %0" : : "r" (cw))
99 /* Default control word set at startup. */
100 extern fpu_control_t __fpu_control
;
102 #endif /* _FPU_CONTROL_H */