visasm.h 1.5 KB

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