fpa11.h 3.3 KB

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