switch_mips_unix.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. __attribute__((nomips16))
  16. static int
  17. slp_switch(void)
  18. {
  19. int err;
  20. int *stackref, stsizediff;
  21. #ifdef __mips64
  22. uint64_t gpsave;
  23. #endif
  24. __asm__ __volatile__ ("" : : : REGS_TO_SAVE);
  25. #ifdef __mips64
  26. __asm__ __volatile__ ("sd $28,%0" : "=m" (gpsave) : : );
  27. #endif
  28. __asm__ ("move %0, $29" : "=r" (stackref) : );
  29. {
  30. SLP_SAVE_STATE(stackref, stsizediff);
  31. __asm__ __volatile__ (
  32. #ifdef __mips64
  33. "daddu $29, $29, %0\n"
  34. #else
  35. "addu $29, $29, %0\n"
  36. #endif
  37. : /* no outputs */
  38. : "r" (stsizediff)
  39. );
  40. SLP_RESTORE_STATE();
  41. }
  42. #ifdef __mips64
  43. __asm__ __volatile__ ("ld $28,%0" : : "m" (gpsave) : );
  44. #endif
  45. __asm__ __volatile__ ("" : : : REGS_TO_SAVE);
  46. __asm__ __volatile__ ("move %0, $0" : "=r" (err));
  47. return err;
  48. }
  49. #endif
  50. /*
  51. * further self-processing support
  52. */
  53. /*
  54. * if you want to add self-inspection tools, place them
  55. * here. See the x86_msvc for the necessary defines.
  56. * These features are highly experimental und not
  57. * essential yet.
  58. */