fpu_control.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. #ifdef __MAVERICK__
  19. /* DSPSC register: (from EP9312 User's Guide)
  20. *
  21. * bits 31..29 - DAID
  22. * bits 28..26 - HVID
  23. * bits 25..24 - RSVD
  24. * bit 23 - ISAT
  25. * bit 22 - UI
  26. * bit 21 - INT
  27. * bit 20 - AEXC
  28. * bits 19..18 - SAT
  29. * bits 17..16 - FCC
  30. * bit 15 - V
  31. * bit 14 - FWDEN
  32. * bit 13 - Invalid
  33. * bit 12 - Denorm
  34. * bits 11..10 - RM
  35. * bits 9..5 - IXE, UFE, OFE, RSVD, IOE
  36. * bits 4..0 - IX, UF, OF, RSVD, IO
  37. */
  38. /* masking of interrupts */
  39. #define _FPU_MASK_IM (1 << 5) /* invalid operation */
  40. #define _FPU_MASK_ZM 0 /* divide by zero */
  41. #define _FPU_MASK_OM (1 << 7) /* overflow */
  42. #define _FPU_MASK_UM (1 << 8) /* underflow */
  43. #define _FPU_MASK_PM (1 << 9) /* inexact */
  44. #define _FPU_MASK_DM 0 /* denormalized operation */
  45. #define _FPU_RESERVED 0xfffff000 /* These bits are reserved. */
  46. #define _FPU_DEFAULT 0x00b00000 /* Default value. */
  47. #define _FPU_IEEE 0x00b003a0 /* Default + exceptions enabled. */
  48. /* Type of the control word. */
  49. typedef unsigned int fpu_control_t;
  50. /* Macros for accessing the hardware control word. */
  51. #define _FPU_GETCW(cw) ({ \
  52. register int __t1, __t2; \
  53. \
  54. __asm__ volatile ( \
  55. "cfmvr64l %1, mvdx0\n\t" \
  56. "cfmvr64h %2, mvdx0\n\t" \
  57. "cfmv32sc mvdx0, dspsc\n\t" \
  58. "cfmvr64l %0, mvdx0\n\t" \
  59. "cfmv64lr mvdx0, %1\n\t" \
  60. "cfmv64hr mvdx0, %2" \
  61. : "=r" (cw), "=r" (__t1), "=r" (__t2) \
  62. ); \
  63. })
  64. #define _FPU_SETCW(cw) ({ \
  65. register int __t0, __t1, __t2; \
  66. \
  67. __asm__ volatile ( \
  68. "cfmvr64l %1, mvdx0\n\t" \
  69. "cfmvr64h %2, mvdx0\n\t" \
  70. "cfmv64lr mvdx0, %0\n\t" \
  71. "cfmvsc32 dspsc, mvdx0\n\t" \
  72. "cfmv64lr mvdx0, %1\n\t" \
  73. "cfmv64hr mvdx0, %2" \
  74. : "=r" (__t0), "=r" (__t1), "=r" (__t2) \
  75. : "0" (cw) \
  76. ); \
  77. })
  78. #else /* !__MAVERICK__ */
  79. /* We have a slight terminology confusion here. On the ARM, the register
  80. * we're interested in is actually the FPU status word - the FPU control
  81. * word is something different (which is implementation-defined and only
  82. * accessible from supervisor mode.)
  83. *
  84. * The FPSR looks like this:
  85. *
  86. * 31-24 23-16 15-8 7-0
  87. * | system ID | trap enable | system control | exception flags |
  88. *
  89. * We ignore the system ID bits; for interest's sake they are:
  90. *
  91. * 0000 "old" FPE
  92. * 1000 FPPC hardware
  93. * 0001 FPE 400
  94. * 1001 FPA hardware
  95. *
  96. * The trap enable and exception flags are both structured like this:
  97. *
  98. * 7 - 5 4 3 2 1 0
  99. * | reserved | INX | UFL | OFL | DVZ | IVO |
  100. *
  101. * where a `1' bit in the enable byte means that the trap can occur, and
  102. * a `1' bit in the flags byte means the exception has occurred.
  103. *
  104. * The exceptions are:
  105. *
  106. * IVO - invalid operation
  107. * DVZ - divide by zero
  108. * OFL - overflow
  109. * UFL - underflow
  110. * INX - inexact (do not use; implementations differ)
  111. *
  112. * The system control byte looks like this:
  113. *
  114. * 7-5 4 3 2 1 0
  115. * | reserved | AC | EP | SO | NE | ND |
  116. *
  117. * where the bits mean
  118. *
  119. * ND - no denormalised numbers (force them all to zero)
  120. * NE - enable NaN exceptions
  121. * SO - synchronous operation
  122. * EP - use expanded packed-decimal format
  123. * AC - use alternate definition for C flag on compare operations
  124. */
  125. /* masking of interrupts */
  126. #define _FPU_MASK_IM 0x00010000 /* invalid operation */
  127. #define _FPU_MASK_ZM 0x00020000 /* divide by zero */
  128. #define _FPU_MASK_OM 0x00040000 /* overflow */
  129. #define _FPU_MASK_UM 0x00080000 /* underflow */
  130. #define _FPU_MASK_PM 0x00100000 /* inexact */
  131. #define _FPU_MASK_DM 0x00000000 /* denormalized operation */
  132. /* The system id bytes cannot be changed.
  133. Only the bottom 5 bits in the trap enable byte can be changed.
  134. Only the bottom 5 bits in the system control byte can be changed.
  135. Only the bottom 5 bits in the exception flags are used.
  136. The exception flags are set by the fpu, but can be zeroed by the user. */
  137. #define _FPU_RESERVED 0xffe0e0e0 /* These bits are reserved. */
  138. /* The fdlibm code requires strict IEEE double precision arithmetic,
  139. no interrupts for exceptions, rounding to nearest. Changing the
  140. rounding mode will break long double I/O. Turn on the AC bit,
  141. the compiler generates code that assumes it is on. */
  142. #define _FPU_DEFAULT 0x00001000 /* Default value. */
  143. #define _FPU_IEEE 0x001f1000 /* Default + exceptions enabled. */
  144. /* Type of the control word. */
  145. typedef unsigned int fpu_control_t;
  146. /* Macros for accessing the hardware control word. */
  147. #define _FPU_GETCW(cw) __asm__ ("rfs %0" : "=r" (cw))
  148. #define _FPU_SETCW(cw) __asm__ ("wfs %0" : : "r" (cw))
  149. #endif /* __MAVERICK__ */
  150. /* Default control word set at startup. */
  151. extern fpu_control_t __fpu_control;
  152. #endif /* _FPU_CONTROL_H */