mtfsf.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <linux/types.h>
  2. #include <linux/errno.h>
  3. #include <asm/uaccess.h>
  4. #include <asm/sfp-machine.h>
  5. #include <math-emu/soft-fp.h>
  6. int
  7. mtfsf(unsigned int FM, u32 *frB)
  8. {
  9. u32 mask;
  10. u32 fpscr;
  11. if (likely(FM == 1))
  12. mask = 0x0f;
  13. else if (likely(FM == 0xff))
  14. mask = ~0;
  15. else {
  16. mask = ((FM & 1) |
  17. ((FM << 3) & 0x10) |
  18. ((FM << 6) & 0x100) |
  19. ((FM << 9) & 0x1000) |
  20. ((FM << 12) & 0x10000) |
  21. ((FM << 15) & 0x100000) |
  22. ((FM << 18) & 0x1000000) |
  23. ((FM << 21) & 0x10000000)) * 15;
  24. }
  25. fpscr = ((__FPU_FPSCR & ~mask) | (frB[1] & mask)) &
  26. ~(FPSCR_VX | FPSCR_FEX | 0x800);
  27. if (fpscr & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI |
  28. FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC |
  29. FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI))
  30. fpscr |= FPSCR_VX;
  31. /* The bit order of exception enables and exception status
  32. * is the same. Simply shift and mask to check for enabled
  33. * exceptions.
  34. */
  35. if (fpscr & (fpscr >> 22) & 0xf8)
  36. fpscr |= FPSCR_FEX;
  37. __FPU_FPSCR = fpscr;
  38. #ifdef DEBUG
  39. printk("%s: %02x %p: %08lx\n", __func__, FM, frB, __FPU_FPSCR);
  40. #endif
  41. return 0;
  42. }