fpu_emulator.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. int process_fpemu_return(int sig, void __user *fault_addr,
  60. unsigned long fcr31);
  61. int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
  62. unsigned long *contpc);
  63. int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
  64. unsigned long *contpc);
  65. #define SIGNALLING_NAN 0x7ff800007ff80000LL
  66. static inline void fpu_emulator_init_fpu(void)
  67. {
  68. struct task_struct *t = current;
  69. int i;
  70. for (i = 0; i < 32; i++)
  71. set_fpr64(&t->thread.fpu.fpr[i], 0, SIGNALLING_NAN);
  72. }
  73. #endif /* _ASM_FPU_EMULATOR_H */