fpu.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __ASM_ALPHA_FPU_H
  2. #define __ASM_ALPHA_FPU_H
  3. #include <asm/special_insns.h>
  4. #include <uapi/asm/fpu.h>
  5. /* The following two functions don't need trapb/excb instructions
  6. around the mf_fpcr/mt_fpcr instructions because (a) the kernel
  7. never generates arithmetic faults and (b) call_pal instructions
  8. are implied trap barriers. */
  9. static inline unsigned long
  10. rdfpcr(void)
  11. {
  12. unsigned long tmp, ret;
  13. #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
  14. __asm__ __volatile__ (
  15. "ftoit $f0,%0\n\t"
  16. "mf_fpcr $f0\n\t"
  17. "ftoit $f0,%1\n\t"
  18. "itoft %0,$f0"
  19. : "=r"(tmp), "=r"(ret));
  20. #else
  21. __asm__ __volatile__ (
  22. "stt $f0,%0\n\t"
  23. "mf_fpcr $f0\n\t"
  24. "stt $f0,%1\n\t"
  25. "ldt $f0,%0"
  26. : "=m"(tmp), "=m"(ret));
  27. #endif
  28. return ret;
  29. }
  30. static inline void
  31. wrfpcr(unsigned long val)
  32. {
  33. unsigned long tmp;
  34. #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
  35. __asm__ __volatile__ (
  36. "ftoit $f0,%0\n\t"
  37. "itoft %1,$f0\n\t"
  38. "mt_fpcr $f0\n\t"
  39. "itoft %0,$f0"
  40. : "=&r"(tmp) : "r"(val));
  41. #else
  42. __asm__ __volatile__ (
  43. "stt $f0,%0\n\t"
  44. "ldt $f0,%1\n\t"
  45. "mt_fpcr $f0\n\t"
  46. "ldt $f0,%0"
  47. : "=m"(tmp) : "m"(val));
  48. #endif
  49. }
  50. static inline unsigned long
  51. swcr_update_status(unsigned long swcr, unsigned long fpcr)
  52. {
  53. /* EV6 implements most of the bits in hardware. Collect
  54. the acrued exception bits from the real fpcr. */
  55. if (implver() == IMPLVER_EV6) {
  56. swcr &= ~IEEE_STATUS_MASK;
  57. swcr |= (fpcr >> 35) & IEEE_STATUS_MASK;
  58. }
  59. return swcr;
  60. }
  61. extern unsigned long alpha_read_fp_reg (unsigned long reg);
  62. extern void alpha_write_fp_reg (unsigned long reg, unsigned long val);
  63. extern unsigned long alpha_read_fp_reg_s (unsigned long reg);
  64. extern void alpha_write_fp_reg_s (unsigned long reg, unsigned long val);
  65. #endif /* __ASM_ALPHA_FPU_H */