fpu_control.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _FPU_CONTROL_H
  17. #define _FPU_CONTROL_H
  18. /* We have a slight terminology confusion here. On the ARM, the register
  19. * we're interested in is actually the FPU status word - the FPU control
  20. * word is something different (which is implementation-defined and only
  21. * accessible from supervisor mode.)
  22. *
  23. * The FPSR looks like this:
  24. *
  25. * 31-24 23-16 15-8 7-0
  26. * | system ID | trap enable | system control | exception flags |
  27. *
  28. * We ignore the system ID bits; for interest's sake they are:
  29. *
  30. * 0000 "old" FPE
  31. * 1000 FPPC hardware
  32. * 0001 FPE 400
  33. * 1001 FPA hardware
  34. *
  35. * The trap enable and exception flags are both structured like this:
  36. *
  37. * 7 - 5 4 3 2 1 0
  38. * | reserved | INX | UFL | OFL | DVZ | IVO |
  39. *
  40. * where a `1' bit in the enable byte means that the trap can occur, and
  41. * a `1' bit in the flags byte means the exception has occurred.
  42. *
  43. * The exceptions are:
  44. *
  45. * IVO - invalid operation
  46. * DVZ - divide by zero
  47. * OFL - overflow
  48. * UFL - underflow
  49. * INX - inexact (do not use; implementations differ)
  50. *
  51. * The system control byte looks like this:
  52. *
  53. * 7-5 4 3 2 1 0
  54. * | reserved | AC | EP | SO | NE | ND |
  55. *
  56. * where the bits mean
  57. *
  58. * ND - no denormalised numbers (force them all to zero)
  59. * NE - enable NaN exceptions
  60. * SO - synchronous operation
  61. * EP - use expanded packed-decimal format
  62. * AC - use alternate definition for C flag on compare operations
  63. */
  64. /* masking of interrupts */
  65. #define _FPU_MASK_IM 0x00010000 /* invalid operation */
  66. #define _FPU_MASK_ZM 0x00020000 /* divide by zero */
  67. #define _FPU_MASK_OM 0x00040000 /* overflow */
  68. #define _FPU_MASK_UM 0x00080000 /* underflow */
  69. #define _FPU_MASK_PM 0x00100000 /* inexact */
  70. #define _FPU_MASK_DM 0x00000000 /* denormalized operation */
  71. /* The system id bytes cannot be changed.
  72. Only the bottom 5 bits in the trap enable byte can be changed.
  73. Only the bottom 5 bits in the system control byte can be changed.
  74. Only the bottom 5 bits in the exception flags are used.
  75. The exception flags are set by the fpu, but can be zeroed by the user. */
  76. #define _FPU_RESERVED 0xffe0e0e0 /* These bits are reserved. */
  77. /* The fdlibm code requires strict IEEE double precision arithmetic,
  78. no interrupts for exceptions, rounding to nearest. Changing the
  79. rounding mode will break long double I/O. Turn on the AC bit,
  80. the compiler generates code that assumes it is on. */
  81. #define _FPU_DEFAULT 0x00001000 /* Default value. */
  82. #define _FPU_IEEE 0x001f1000 /* Default + exceptions enabled. */
  83. /* Type of the control word. */
  84. typedef unsigned int fpu_control_t;
  85. /* Macros for accessing the hardware control word. */
  86. #define _FPU_GETCW(cw) __asm__ ("rfs %0" : "=r" (cw))
  87. #define _FPU_SETCW(cw) __asm__ ("wfs %0" : : "r" (cw))
  88. /* Default control word set at startup. */
  89. extern fpu_control_t __fpu_control;
  90. #endif /* _FPU_CONTROL_H */