switch_m68k_gcc.h 928 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * this is the internal transfer function.
  3. *
  4. * HISTORY
  5. * 2014-01-06 Andreas Schwab <schwab@linux-m68k.org>
  6. * File created.
  7. */
  8. #ifdef SLP_EVAL
  9. #define STACK_MAGIC 0
  10. #define REGS_TO_SAVE "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
  11. "%a2", "%a3", "%a4"
  12. static int
  13. slp_switch(void)
  14. {
  15. int err;
  16. int *stackref, stsizediff;
  17. void *fp, *a5;
  18. __asm__ volatile ("" : : : REGS_TO_SAVE);
  19. __asm__ volatile ("move.l %%fp, %0" : "=m"(fp));
  20. __asm__ volatile ("move.l %%a5, %0" : "=m"(a5));
  21. __asm__ ("move.l %%sp, %0" : "=r"(stackref));
  22. {
  23. SLP_SAVE_STATE(stackref, stsizediff);
  24. __asm__ volatile ("add.l %0, %%sp; add.l %0, %%fp" : : "r"(stsizediff));
  25. SLP_RESTORE_STATE();
  26. __asm__ volatile ("clr.l %0" : "=g" (err));
  27. }
  28. __asm__ volatile ("move.l %0, %%a5" : : "m"(a5));
  29. __asm__ volatile ("move.l %0, %%fp" : : "m"(fp));
  30. __asm__ volatile ("" : : : REGS_TO_SAVE);
  31. return err;
  32. }
  33. #endif