fpu_emulator.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/break.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. local_t emulated;
  34. local_t loads;
  35. local_t stores;
  36. local_t cp1ops;
  37. local_t cp1xops;
  38. local_t errors;
  39. local_t ieee754_inexact;
  40. local_t ieee754_underflow;
  41. local_t ieee754_overflow;
  42. local_t ieee754_zerodiv;
  43. local_t ieee754_invalidop;
  44. };
  45. DECLARE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
  46. #define MIPS_FPU_EMU_INC_STATS(M) \
  47. do { \
  48. preempt_disable(); \
  49. __local_inc(&__get_cpu_var(fpuemustats).M); \
  50. preempt_enable(); \
  51. } while (0)
  52. #else
  53. #define MIPS_FPU_EMU_INC_STATS(M) do { } while (0)
  54. #endif /* CONFIG_DEBUG_FS */
  55. extern int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
  56. unsigned long cpc);
  57. extern int do_dsemulret(struct pt_regs *xcp);
  58. extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
  59. struct mips_fpu_struct *ctx, int has_fpu,
  60. void *__user *fault_addr);
  61. int process_fpemu_return(int sig, void __user *fault_addr);
  62. int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
  63. unsigned long *contpc);
  64. /*
  65. * Instruction inserted following the badinst to further tag the sequence
  66. */
  67. #define BD_COOKIE 0x0000bd36 /* tne $0, $0 with baggage */
  68. /*
  69. * Break instruction with special math emu break code set
  70. */
  71. #define BREAK_MATH (0x0000000d | (BRK_MEMU << 16))
  72. #define SIGNALLING_NAN 0x7ff800007ff80000LL
  73. static inline void fpu_emulator_init_fpu(void)
  74. {
  75. struct task_struct *t = current;
  76. int i;
  77. t->thread.fpu.fcr31 = 0;
  78. for (i = 0; i < 32; i++)
  79. set_fpr64(&t->thread.fpu.fpr[i], 0, SIGNALLING_NAN);
  80. }
  81. #endif /* _ASM_FPU_EMULATOR_H */