setjmp.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* Copyright (C) 1999, 2000, 2001, 2002, 2008 Free Software Foundation, Inc.
  2. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA.
  15. The layout of the jmp_buf is as follows. This is subject to change
  16. and user-code should never depend on the particular layout of
  17. jmp_buf!
  18. offset: description:
  19. ------- ------------
  20. 0x000 stack pointer (r12) ; unchangeable (see _JMPBUF_UNWINDS)
  21. 0x008 r1 (gp)
  22. 0x010 caller's unat
  23. 0x018 fpsr
  24. 0x020 r4
  25. 0x028 r5
  26. 0x030 r6
  27. 0x038 r7
  28. 0x040 rp (b0)
  29. 0x048 b1
  30. 0x050 b2
  31. 0x058 b3
  32. 0x060 b4
  33. 0x068 b5
  34. 0x070 ar.pfs
  35. 0x078 ar.lc
  36. 0x080 pr
  37. 0x088 ar.bsp ; unchangeable (see __longjmp.S)
  38. 0x090 ar.unat
  39. 0x098 &__jmp_buf ; address of the jmpbuf (needed to locate NaT bits in unat)
  40. 0x0a0 f2
  41. 0x0b0 f3
  42. 0x0c0 f4
  43. 0x0d0 f5
  44. 0x0e0 f16
  45. 0x0f0 f17
  46. 0x100 f18
  47. 0x110 f19
  48. 0x120 f20
  49. 0x130 f21
  50. 0x130 f22
  51. 0x140 f23
  52. 0x150 f24
  53. 0x160 f25
  54. 0x170 f26
  55. 0x180 f27
  56. 0x190 f28
  57. 0x1a0 f29
  58. 0x1b0 f30
  59. 0x1c0 f31 */
  60. #include <grub/symbol.h>
  61. #include <grub/dl.h>
  62. .file "setjmp.S"
  63. GRUB_MOD_LICENSE "GPLv2+"
  64. /* The following two entry points are the traditional entry points: */
  65. .text
  66. .proc EXT_C(grub_setjmp)
  67. FUNCTION(grub_setjmp)
  68. alloc r8=ar.pfs,2,0,0,0
  69. mov in1=1
  70. br.cond.sptk.many __sigsetjmp
  71. .endp EXT_C(grub_setjmp)
  72. /* __sigsetjmp(__jmp_buf buf, int savemask) */
  73. .proc __sigsetjmp
  74. __sigsetjmp:
  75. //.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
  76. alloc loc1=ar.pfs,2,2,2,0
  77. mov r16=ar.unat
  78. ;;
  79. mov r17=ar.fpsr
  80. mov r2=in0
  81. add r3=8,in0
  82. ;;
  83. st8.spill.nta [r2]=sp,16 // r12 (sp)
  84. st8.spill.nta [r3]=gp,16 // r1 (gp)
  85. ;;
  86. st8.nta [r2]=r16,16 // save caller's unat
  87. st8.nta [r3]=r17,16 // save fpsr
  88. add r8=0xa0,in0
  89. ;;
  90. st8.spill.nta [r2]=r4,16 // r4
  91. st8.spill.nta [r3]=r5,16 // r5
  92. add r9=0xb0,in0
  93. ;;
  94. stf.spill.nta [r8]=f2,32
  95. stf.spill.nta [r9]=f3,32
  96. mov loc0=rp
  97. .body
  98. ;;
  99. stf.spill.nta [r8]=f4,32
  100. stf.spill.nta [r9]=f5,32
  101. mov r17=b1
  102. ;;
  103. stf.spill.nta [r8]=f16,32
  104. stf.spill.nta [r9]=f17,32
  105. mov r18=b2
  106. ;;
  107. stf.spill.nta [r8]=f18,32
  108. stf.spill.nta [r9]=f19,32
  109. mov r19=b3
  110. ;;
  111. stf.spill.nta [r8]=f20,32
  112. stf.spill.nta [r9]=f21,32
  113. mov r20=b4
  114. ;;
  115. stf.spill.nta [r8]=f22,32
  116. stf.spill.nta [r9]=f23,32
  117. mov r21=b5
  118. ;;
  119. stf.spill.nta [r8]=f24,32
  120. stf.spill.nta [r9]=f25,32
  121. mov r22=ar.lc
  122. ;;
  123. stf.spill.nta [r8]=f26,32
  124. stf.spill.nta [r9]=f27,32
  125. mov r24=pr
  126. ;;
  127. stf.spill.nta [r8]=f28,32
  128. stf.spill.nta [r9]=f29,32
  129. ;;
  130. stf.spill.nta [r8]=f30
  131. stf.spill.nta [r9]=f31
  132. st8.spill.nta [r2]=r6,16 // r6
  133. st8.spill.nta [r3]=r7,16 // r7
  134. ;;
  135. mov r23=ar.bsp
  136. mov r25=ar.unat
  137. mov out0=in0
  138. st8.nta [r2]=loc0,16 // b0
  139. st8.nta [r3]=r17,16 // b1
  140. mov out1=in1
  141. ;;
  142. st8.nta [r2]=r18,16 // b2
  143. st8.nta [r3]=r19,16 // b3
  144. ;;
  145. st8.nta [r2]=r20,16 // b4
  146. st8.nta [r3]=r21,16 // b5
  147. ;;
  148. st8.nta [r2]=loc1,16 // ar.pfs
  149. st8.nta [r3]=r22,16 // ar.lc
  150. ;;
  151. st8.nta [r2]=r24,16 // pr
  152. st8.nta [r3]=r23,16 // ar.bsp
  153. ;;
  154. st8.nta [r2]=r25 // ar.unat
  155. st8.nta [r3]=in0 // &__jmp_buf
  156. mov r8=0
  157. mov rp=loc0
  158. mov ar.pfs=loc1
  159. br.ret.sptk.many rp
  160. .endp __sigsetjmp