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.

88 lines
2.9KB

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