switch_mips_unix.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * this is the internal transfer function.
  3. *
  4. * HISTORY
  5. * 20-Sep-14 Matt Madison <madison@bliss-m.org>
  6. * Re-code the saving of the gp register for MIPS64.
  7. * 05-Jan-08 Thiemo Seufer <ths@debian.org>
  8. * Ported from ppc.
  9. */
  10. #define STACK_REFPLUS 1
  11. #ifdef SLP_EVAL
  12. #define STACK_MAGIC 0
  13. #define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \
  14. "$23", "$30"
  15. static int
  16. slp_switch(void)
  17. {
  18. register int err;
  19. register int *stackref, stsizediff;
  20. #ifdef __mips64
  21. uint64_t gpsave;
  22. #endif
  23. __asm__ __volatile__ ("" : : : REGS_TO_SAVE);
  24. #ifdef __mips64
  25. __asm__ __volatile__ ("sd $28,%0" : "=m" (gpsave) : : );
  26. #endif
  27. __asm__ ("move %0, $29" : "=r" (stackref) : );
  28. {
  29. SLP_SAVE_STATE(stackref, stsizediff);
  30. __asm__ __volatile__ (
  31. #ifdef __mips64
  32. "daddu $29, %0\n"
  33. #else
  34. "addu $29, %0\n"
  35. #endif
  36. : /* no outputs */
  37. : "r" (stsizediff)
  38. );
  39. SLP_RESTORE_STATE();
  40. }
  41. #ifdef __mips64
  42. __asm__ __volatile__ ("ld $28,%0" : : "m" (gpsave) : );
  43. #endif
  44. __asm__ __volatile__ ("" : : : REGS_TO_SAVE);
  45. __asm__ __volatile__ ("move %0, $0" : "=r" (err));
  46. return err;
  47. }
  48. #endif
  49. /*
  50. * further self-processing support
  51. */
  52. /*
  53. * if you want to add self-inspection tools, place them
  54. * here. See the x86_msvc for the necessary defines.
  55. * These features are highly experimental und not
  56. * essential yet.
  57. */