visasm.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _SPARC64_VISASM_H
  2. #define _SPARC64_VISASM_H
  3. /* visasm.h: FPU saving macros for VIS routines
  4. *
  5. * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
  6. */
  7. #include <asm/pstate.h>
  8. #include <asm/ptrace.h>
  9. /* Clobbers %o5, %g1, %g2, %g3, %g7, %icc, %xcc */
  10. #define VISEntry \
  11. rd %fprs, %o5; \
  12. andcc %o5, (FPRS_FEF|FPRS_DU), %g0; \
  13. be,pt %icc, 297f; \
  14. sethi %hi(297f), %g7; \
  15. sethi %hi(VISenter), %g1; \
  16. jmpl %g1 + %lo(VISenter), %g0; \
  17. or %g7, %lo(297f), %g7; \
  18. 297: wr %g0, FPRS_FEF, %fprs; \
  19. #define VISExit \
  20. wr %g0, 0, %fprs;
  21. /* Clobbers %o5, %g1, %g2, %g3, %g7, %icc, %xcc.
  22. * Must preserve %o5 between VISEntryHalf and VISExitHalf */
  23. #define VISEntryHalf \
  24. VISEntry
  25. #define VISExitHalf \
  26. VISExit
  27. #define VISEntryHalfFast(fail_label) \
  28. rd %fprs, %o5; \
  29. andcc %o5, FPRS_FEF, %g0; \
  30. be,pt %icc, 297f; \
  31. nop; \
  32. ba,a,pt %xcc, fail_label; \
  33. 297: wr %o5, FPRS_FEF, %fprs;
  34. #define VISExitHalfFast \
  35. wr %o5, 0, %fprs;
  36. #ifndef __ASSEMBLY__
  37. static inline void save_and_clear_fpu(void) {
  38. __asm__ __volatile__ (
  39. " rd %%fprs, %%o5\n"
  40. " andcc %%o5, %0, %%g0\n"
  41. " be,pt %%icc, 299f\n"
  42. " sethi %%hi(298f), %%g7\n"
  43. " sethi %%hi(VISenter), %%g1\n"
  44. " jmpl %%g1 + %%lo(VISenter), %%g0\n"
  45. " or %%g7, %%lo(298f), %%g7\n"
  46. " 298: wr %%g0, 0, %%fprs\n"
  47. " 299:\n"
  48. " " : : "i" (FPRS_FEF|FPRS_DU) :
  49. "o5", "g1", "g2", "g3", "g7", "cc");
  50. }
  51. int vis_emul(struct pt_regs *, unsigned int);
  52. #endif
  53. #endif /* _SPARC64_ASI_H */