Advertisement
Guest User

Untitled

a guest
Dec 7th, 2011
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. /*
  2. * this is the internal transfer function.
  3. *
  4. * HISTORY
  5. * 14-Aug-06 File creation. Ported from Arm Thumb. Sylvain Baro
  6. * 3-Sep-06 Commented out saving of r1-r3 (r4 already commented out) as I
  7. * read that these do not need to be saved. Also added notes and
  8. * errors related to the frame pointer. Richard Tew.
  9. *
  10. * NOTES
  11. *
  12. * It is not possible to detect if fp is used or not, so the supplied
  13. * switch function needs to support it, so that you can remove it if
  14. * it does not apply to you.
  15. *
  16. * POSSIBLE ERRORS
  17. *
  18. * "fp cannot be used in asm here"
  19. *
  20. * - Try commenting out "fp" in REGS_TO_SAVE.
  21. *
  22. */
  23.  
  24. #define STACK_REFPLUS 1
  25.  
  26. #ifdef SLP_EVAL
  27. #define STACK_MAGIC 0
  28. #define REGS_TO_SAVE "r5", "r6", "fp", "ip", "lr"
  29. //#define REGS_TO_SAVE /*"r1", "r2", "r3", "r4",*/ "r5", "r6", "fp", "ip", "lr"
  30.  
  31. static int
  32. slp_switch(void)
  33. {
  34. register int *stackref, stsizediff;
  35. __asm__ volatile ("" : : : REGS_TO_SAVE);
  36. __asm__ ("mov %0,sp" : "=g" (stackref));
  37. {
  38. SLP_SAVE_STATE(stackref, stsizediff);
  39. __asm__ volatile (
  40. "add sp,sp,%0\n"
  41. "add fp,fp,%0\n"
  42. :
  43. : "r" (stsizediff)
  44. );
  45. SLP_RESTORE_STATE();
  46. return 0;
  47. }
  48. __asm__ volatile ("" : : : REGS_TO_SAVE);
  49. }
  50.  
  51. #endif
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement