fpa11.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. NetWinder Floating Point Emulator
  3. (c) Rebel.com, 1998-1999
  4. Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #ifndef __FPA11_H__
  18. #define __FPA11_H__
  19. #define GET_FPA11() ((FPA11 *)(&current_thread_info()->fpstate))
  20. /*
  21. * The processes registers are always at the very top of the 8K
  22. * stack+task struct. Use the same method as 'current' uses to
  23. * reach them.
  24. */
  25. #define GET_USERREG() ((struct pt_regs *)(THREAD_START_SP + (unsigned long)current_thread_info()) - 1)
  26. #include <linux/thread_info.h>
  27. /* includes */
  28. #include "fpsr.h" /* FP control and status register definitions */
  29. #include "milieu.h"
  30. struct roundingData {
  31. int8 mode;
  32. int8 precision;
  33. signed char exception;
  34. };
  35. #include "softfloat.h"
  36. #define typeNone 0x00
  37. #define typeSingle 0x01
  38. #define typeDouble 0x02
  39. #define typeExtended 0x03
  40. /*
  41. * This must be no more and no less than 12 bytes.
  42. */
  43. typedef union tagFPREG {
  44. float32 fSingle;
  45. float64 fDouble;
  46. #ifdef CONFIG_FPE_NWFPE_XP
  47. floatx80 fExtended;
  48. #else
  49. u32 padding[3];
  50. #endif
  51. } __attribute__ ((packed,aligned(4))) FPREG;
  52. /*
  53. * FPA11 device model.
  54. *
  55. * This structure is exported to user space. Do not re-order.
  56. * Only add new stuff to the end, and do not change the size of
  57. * any element. Elements of this structure are used by user
  58. * space, and must match struct user_fp in <asm/user.h>.
  59. * We include the byte offsets below for documentation purposes.
  60. *
  61. * The size of this structure and FPREG are checked by fpmodule.c
  62. * on initialisation. If the rules have been broken, NWFPE will
  63. * not initialise.
  64. */
  65. typedef struct tagFPA11 {
  66. /* 0 */ FPREG fpreg[8]; /* 8 floating point registers */
  67. /* 96 */ FPSR fpsr; /* floating point status register */
  68. /* 100 */ FPCR fpcr; /* floating point control register */
  69. /* 104 */ unsigned char fType[8]; /* type of floating point value held in
  70. floating point registers. One of
  71. none, single, double or extended. */
  72. /* 112 */ int initflag; /* this is special. The kernel guarantees
  73. to set it to 0 when a thread is launched,
  74. so we can use it to detect whether this
  75. instance of the emulator needs to be
  76. initialised. */
  77. } __attribute__ ((packed,aligned(4))) FPA11;
  78. extern int8 SetRoundingMode(const unsigned int);
  79. extern int8 SetRoundingPrecision(const unsigned int);
  80. extern void nwfpe_init_fpa(union fp_state *fp);
  81. extern unsigned int EmulateAll(unsigned int opcode);
  82. extern unsigned int EmulateCPDT(const unsigned int opcode);
  83. extern unsigned int EmulateCPDO(const unsigned int opcode);
  84. extern unsigned int EmulateCPRT(const unsigned int opcode);
  85. /* fpa11_cpdt.c */
  86. extern unsigned int PerformLDF(const unsigned int opcode);
  87. extern unsigned int PerformSTF(const unsigned int opcode);
  88. extern unsigned int PerformLFM(const unsigned int opcode);
  89. extern unsigned int PerformSFM(const unsigned int opcode);
  90. /* single_cpdo.c */
  91. extern unsigned int SingleCPDO(struct roundingData *roundData,
  92. const unsigned int opcode, FPREG * rFd);
  93. /* double_cpdo.c */
  94. extern unsigned int DoubleCPDO(struct roundingData *roundData,
  95. const unsigned int opcode, FPREG * rFd);
  96. /* extneded_cpdo.c */
  97. extern unsigned int ExtendedCPDO(struct roundingData *roundData,
  98. const unsigned int opcode, FPREG * rFd);
  99. #endif