fpu_emulator.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * This program is free software; you can distribute it and/or modify it
  3. * under the terms of the GNU General Public License (Version 2) as
  4. * published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  8. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  9. * for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License along
  12. * with this program; if not, write to the Free Software Foundation, Inc.,
  13. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  14. *
  15. * Further private data for which no space exists in mips_fpu_struct.
  16. * This should be subsumed into the mips_fpu_struct structure as
  17. * defined in processor.h as soon as the absurd wired absolute assembler
  18. * offsets become dynamic at compile time.
  19. *
  20. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  21. * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  22. */
  23. #ifndef _ASM_FPU_EMULATOR_H
  24. #define _ASM_FPU_EMULATOR_H
  25. #include <linux/sched.h>
  26. #include <asm/dsemul.h>
  27. #include <asm/thread_info.h>
  28. #include <asm/inst.h>
  29. #include <asm/local.h>
  30. #include <asm/processor.h>
  31. #ifdef CONFIG_DEBUG_FS
  32. struct mips_fpu_emulator_stats {
  33. unsigned long emulated;
  34. unsigned long loads;
  35. unsigned long stores;
  36. unsigned long cp1ops;
  37. unsigned long cp1xops;
  38. unsigned long errors;
  39. unsigned long ieee754_inexact;
  40. unsigned long ieee754_underflow;
  41. unsigned long ieee754_overflow;
  42. unsigned long ieee754_zerodiv;
  43. unsigned long ieee754_invalidop;
  44. unsigned long ds_emul;
  45. };
  46. DECLARE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
  47. #define MIPS_FPU_EMU_INC_STATS(M) \
  48. do { \
  49. preempt_disable(); \
  50. __this_cpu_inc(fpuemustats.M); \
  51. preempt_enable(); \
  52. } while (0)
  53. #else
  54. #define MIPS_FPU_EMU_INC_STATS(M) do { } while (0)
  55. #endif /* CONFIG_DEBUG_FS */
  56. extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
  57. struct mips_fpu_struct *ctx, int has_fpu,
  58. void *__user *fault_addr);
  59. void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr,
  60. struct task_struct *tsk);
  61. int process_fpemu_return(int sig, void __user *fault_addr,
  62. unsigned long fcr31);
  63. int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
  64. unsigned long *contpc);
  65. int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
  66. unsigned long *contpc);
  67. #define SIGNALLING_NAN 0x7ff800007ff80000LL
  68. static inline void fpu_emulator_init_fpu(void)
  69. {
  70. struct task_struct *t = current;
  71. int i;
  72. for (i = 0; i < 32; i++)
  73. set_fpr64(&t->thread.fpu.fpr[i], 0, SIGNALLING_NAN);
  74. }
  75. /*
  76. * Mask the FCSR Cause bits according to the Enable bits, observing
  77. * that Unimplemented is always enabled.
  78. */
  79. static inline unsigned long mask_fcr31_x(unsigned long fcr31)
  80. {
  81. return fcr31 & (FPU_CSR_UNI_X |
  82. ((fcr31 & FPU_CSR_ALL_E) <<
  83. (ffs(FPU_CSR_ALL_X) - ffs(FPU_CSR_ALL_E))));
  84. }
  85. #endif /* _ASM_FPU_EMULATOR_H */