bsdsetjmp.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* setjmp for the Blackfin project
  2. *
  3. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  4. * Copyright (C) 2003 Metrowerks
  5. * Based on code from Analog Devices.
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <setjmp.h>
  10. #undef setjmp
  11. int setjmp(jmp_buf env)
  12. {
  13. __asm__ __volatile__(
  14. "[--SP] = p0;\n\t"
  15. "p0 = r0;\n\t"
  16. "r0 = [SP++];\n\t"
  17. "[p0++] = r0;\n\t" /* GP address registers */
  18. "[p0++] = p1;\n\t"
  19. "[p0++] = p2;\n\t"
  20. "[p0++] = p3;\n\t"
  21. "[p0++] = p4;\n\t"
  22. "[p0++] = p5;\n\t"
  23. "[p0++] = FP;\n\t" /* frame pointer */
  24. "[p0++] = SP;\n\t" /* stack pointer */
  25. "[p0++] = p0;\n\t" /* data regs */
  26. "[p0++] = r1;\n\t"
  27. "[p0++] = r2;\n\t"
  28. "[p0++] = r3;\n\t"
  29. "[p0++] = r4;\n\t"
  30. "[p0++] = r5;\n\t"
  31. "[p0++] = r6;\n\t"
  32. "[p0++] = r7;\n\t"
  33. "r0 = ASTAT;\n\t"
  34. "[p0++] = r0;\n\t"
  35. "r0 = LC0;\n\t" /* loop counters */
  36. "[p0++] = r0;\n\t"
  37. "r0 = LC1;\n\t"
  38. "[p0++] = r0;\n\t"
  39. "r0 = A0.w;\n\t"
  40. "[p0++] = r0;\n\t"
  41. "r0.l = A0.x;\n\t"
  42. "[p0++] = r0;\n\t"
  43. "r0 = A1.w;\n\t"
  44. "[p0++] = r0;\n\t"
  45. "r0.l = A1.x;\n\t"
  46. "[p0++] = r0;\n\t"
  47. /* Dag regs */
  48. "r0 = i0;\n\t" /* index registers */
  49. "[p0++] = r0;\n\t"
  50. "r0 = i1;\n\t"
  51. "[p0++] = r0;\n\t"
  52. "r0 = i2;\n\t"
  53. "[p0++] = r0;\n\t"
  54. "r0 = i3;\n\t"
  55. "[p0++] = r0;\n\t"
  56. "r0 = m0;\n\t" /* modifier registers */
  57. "[p0++] = r0;\n\t"
  58. "r0 = m1;\n\t"
  59. "[p0++] = r0;\n\t"
  60. "r0 = m2;\n\t"
  61. "[p0++] = r0;\n\t"
  62. "r0 = m3;\n\t"
  63. "[p0++] = r0;\n\t"
  64. "r0 = l0;\n\t" /* length registers */
  65. "[p0++] = r0;\n\t"
  66. "r0 = l1;\n\t"
  67. "[p0++] = r0;\n\t"
  68. "r0 = l2;\n\t"
  69. "[p0++] = r0;\n\t"
  70. "r0 = l3;\n\t"
  71. "[p0++] = r0;\n\t"
  72. "r0 = b0;\n\t" /* base registers */
  73. "[p0++] = r0;\n\t"
  74. "r0 = b1;\n\t"
  75. "[p0++] = r0;\n\t"
  76. "r0 = b2;\n\t"
  77. "[p0++] = r0;\n\t"
  78. "r0 = b3;\n\t"
  79. "[p0++] = r0;\n\t"
  80. "r0 = RETS;\n\t" /* store return address */
  81. "[p0++] = r0;\n\t"
  82. "r0 = 0;\n\t"
  83. :
  84. :
  85. );
  86. return 0;
  87. }