switch_ppc_linux.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. * 04-Oct-02 Gustavo Niemeyer <niemeyer@conectiva.com>
  20. * Ported from MacOS version.
  21. * 17-Sep-02 Christian Tismer <tismer@tismer.com>
  22. * after virtualizing stack save/restore, the
  23. * stack size shrunk a bit. Needed to introduce
  24. * an adjustment STACK_MAGIC per platform.
  25. * 15-Sep-02 Gerd Woetzel <gerd.woetzel@GMD.DE>
  26. * slightly changed framework for sparc
  27. * 29-Jun-02 Christian Tismer <tismer@tismer.com>
  28. * Added register 13-29, 31 saves. The same way as
  29. * Armin Rigo did for the x86_unix version.
  30. * This seems to be now fully functional!
  31. * 04-Mar-02 Hye-Shik Chang <perky@fallin.lv>
  32. * Ported from i386.
  33. * 31-Jul-12 Trevor Bowen <trevorbowen@gmail.com>
  34. * Changed memory constraints to register only.
  35. */
  36. #define STACK_REFPLUS 1
  37. #ifdef SLP_EVAL
  38. #define STACK_MAGIC 3
  39. /* !!!!WARNING!!!! need to add "r31" in the next line if this header file
  40. * is meant to be compiled non-dynamically!
  41. */
  42. #define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", \
  43. "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", \
  44. "cr2", "cr3", "cr4"
  45. static int
  46. slp_switch(void)
  47. {
  48. register int err;
  49. register int *stackref, stsizediff;
  50. __asm__ volatile ("" : : : REGS_TO_SAVE);
  51. __asm__ ("mr %0, 1" : "=r" (stackref) : );
  52. {
  53. SLP_SAVE_STATE(stackref, stsizediff);
  54. __asm__ volatile (
  55. "mr 11, %0\n"
  56. "add 1, 1, 11\n"
  57. "add 30, 30, 11\n"
  58. : /* no outputs */
  59. : "r" (stsizediff)
  60. : "11"
  61. );
  62. SLP_RESTORE_STATE();
  63. }
  64. __asm__ volatile ("" : : : REGS_TO_SAVE);
  65. __asm__ volatile ("li %0, 0" : "=r" (err));
  66. return err;
  67. }
  68. #endif
  69. /*
  70. * further self-processing support
  71. */
  72. /*
  73. * if you want to add self-inspection tools, place them
  74. * here. See the x86_msvc for the necessary defines.
  75. * These features are highly experimental und not
  76. * essential yet.
  77. */