fpu_control.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2016-2017 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. #ifndef _FPU_CONTROL_H
  6. #ifdef __NDS32_ABI_2FP_PLUS__
  7. /*
  8. * Andes Floating-Point Control Status Register
  9. * 31-20 -> Reserved
  10. * 19 -> RIT (RO)
  11. * 18 -> DNIT(RO)
  12. * 17 -> IEXT(RO)
  13. * 16 -> UDFT(RO)
  14. * 15 -> OVFT(RO)
  15. * 14 -> DBZT(RO)
  16. * 13 -> IVOT(RO)
  17. * 12 -> DNZ(RW),Denormalized flush-to-Zero mode.
  18. * 11 -> IEXE(RW),IEEE Ineaxct (IEX) exception trapping enable.
  19. * 10 -> UDFE(RW),IEEE Underflow (UDF) exception trapping enable.
  20. * 9 -> OVFE(RW),IEEE Overflow (OVF) exception trapping enable.
  21. * 8 -> DBZE(RW),IEEE Divide by Zero (DBZ) exception trapping enable.
  22. * 7 -> IVOE(RW),IEEE Invalid Operation (IVO) exception trapping enable.
  23. * 6 -> IEX(RW),IEEE Inexact (IEX) cumulative exception flag.
  24. * 5 -> UDF(RW),IEEE Underflow (UDF) cumulative exception flag.
  25. * 4 -> OVF(RW),IEEE Overflow (OVF) cumulative exception flag.
  26. * 3 -> DBZ(RW),IEEE Divide by Zero (DBZ) cumulative exception flag.
  27. * 2 -> IVO(RW),IEEE Invalid Operation (IVO) cumulative exception flag.
  28. * 1-0 -> Rounding modes.
  29. *
  30. * Rounding modes.
  31. * 00 - rounding to nearest (RN)
  32. * 01 - rounding (up) toward plus infinity (RP)
  33. * 10 - rounding (down)toward minus infinity (RM)
  34. * 11 - rounding toward zero (RZ)
  35. *
  36. */
  37. /* masking of interrupts */
  38. #define _FPU_MASK_IEX 0x0800 /* Invalid operation */
  39. #define _FPU_MASK_UDF 0x0400 /* Underflow */
  40. #define _FPU_MASK_OVF 0x0200 /* Overflow */
  41. #define _FPU_MASK_DBZ 0x0100 /* Division by zero */
  42. #define _FPU_MASK_IVO 0x0080 /* Invalid operation */
  43. /*Reserved and read-only bits*/
  44. #define _FPU_RESERVED 0xffffe000
  45. #define _FPU_DEFAULT 0x00000000
  46. /* Default + exceptions enabled. */
  47. #define _FPU_IEEE (_FPU_DEFAULT | 0x00000f80)
  48. /* Type of the control word. */
  49. typedef unsigned int fpu_control_t;
  50. /* Macros for accessing the hardware control word. */
  51. /* This is fmrx %0, fpscr. */
  52. #define _FPU_GETCW(cw) \
  53. __asm__ __volatile__ ("fmfcsr\t %0\n\t" : "=r" (cw))
  54. /* This is fmxr fpscr, %0. */
  55. #define _FPU_SETCW(cw) \
  56. __asm__ __volatile__ ("fmtcsr\t %0\n\t": : "r" (cw))
  57. /* Default control word set at startup. */
  58. extern fpu_control_t __fpu_control;
  59. #else
  60. #define _FPU_GETCW(cw) (cw) = 0
  61. #define _FPU_SETCW(cw) (void) (cw)
  62. #define _FPU_RESERVED 0xffffffff
  63. #define _FPU_DEFAULT 0x00000000
  64. typedef unsigned int fpu_control_t;
  65. extern fpu_control_t __fpu_control;
  66. #endif //__NDS32_ABI_2FP_PLUS__
  67. #endif //_FPU_CONTROL_H