You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.6KB

  1. /*
  2. * this is the internal transfer function.
  3. *
  4. * HISTORY
  5. * 07-Sep-05 (py-dev mailing list discussion)
  6. * removed 'r31' from the register-saved. !!!! WARNING !!!!
  7. * It means that this file can no longer be compiled statically!
  8. * It is now only suitable as part of a dynamic library!
  9. * 14-Jan-04 Bob Ippolito <bob@redivi.com>
  10. * added cr2-cr4 to the registers to be saved.
  11. * Open questions: Should we save FP registers?
  12. * What about vector registers?
  13. * Differences between darwin and unix?
  14. * 24-Nov-02 Christian Tismer <tismer@tismer.com>
  15. * needed to add another magic constant to insure
  16. * that f in slp_eval_frame(PyFrameObject *f)
  17. * STACK_REFPLUS will probably be 1 in most cases.
  18. * gets included into the saved stack area.
  19. * 17-Sep-02 Christian Tismer <tismer@tismer.com>
  20. * after virtualizing stack save/restore, the
  21. * stack size shrunk a bit. Needed to introduce
  22. * an adjustment STACK_MAGIC per platform.
  23. * 15-Sep-02 Gerd Woetzel <gerd.woetzel@GMD.DE>
  24. * slightly changed framework for sparc
  25. * 29-Jun-02 Christian Tismer <tismer@tismer.com>
  26. * Added register 13-29, 31 saves. The same way as
  27. * Armin Rigo did for the x86_unix version.
  28. * This seems to be now fully functional!
  29. * 04-Mar-02 Hye-Shik Chang <perky@fallin.lv>
  30. * Ported from i386.
  31. */
  32. #define STACK_REFPLUS 1
  33. #ifdef SLP_EVAL
  34. #define STACK_MAGIC 3
  35. /* !!!!WARNING!!!! need to add "r31" in the next line if this header file
  36. * is meant to be compiled non-dynamically!
  37. */
  38. #define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", \
  39. "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", \
  40. "cr2", "cr3", "cr4"
  41. static int
  42. slp_switch(void)
  43. {
  44. register int err;
  45. register int *stackref, stsizediff;
  46. __asm__ volatile ("" : : : REGS_TO_SAVE);
  47. __asm__ ("; asm block 2\n\tmr %0, r1" : "=g" (stackref) : );
  48. {
  49. SLP_SAVE_STATE(stackref, stsizediff);
  50. __asm__ volatile (
  51. "; asm block 3\n"
  52. "\tmr r11, %0\n"
  53. "\tadd r1, r1, r11\n"
  54. "\tadd r30, r30, r11\n"
  55. : /* no outputs */
  56. : "g" (stsizediff)
  57. : "r11"
  58. );
  59. SLP_RESTORE_STATE();
  60. }
  61. __asm__ volatile ("" : : : REGS_TO_SAVE);
  62. __asm__ volatile ("li %0, 0" : "=r" (err));
  63. return err;
  64. }
  65. #endif
  66. /*
  67. * further self-processing support
  68. */
  69. /*
  70. * if you want to add self-inspection tools, place them
  71. * here. See the x86_msvc for the necessary defines.
  72. * These features are highly experimental und not
  73. * essential yet.
  74. */