cif.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /* cif.S: PROM entry/exit assembler trampolines.
  2. *
  3. * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  4. * Copyright (C) 2005 David S. Miller <davem@davemloft.net>
  5. */
  6. #include <asm/pstate.h>
  7. .text
  8. .globl prom_cif_interface
  9. prom_cif_interface:
  10. sethi %hi(p1275buf), %o0
  11. or %o0, %lo(p1275buf), %o0
  12. ldx [%o0 + 0x010], %o1 ! prom_cif_stack
  13. save %o1, -0x190, %sp
  14. ldx [%i0 + 0x008], %l2 ! prom_cif_handler
  15. rdpr %pstate, %l4
  16. wrpr %g0, 0x15, %pstate ! save alternate globals
  17. stx %g1, [%sp + 2047 + 0x0b0]
  18. stx %g2, [%sp + 2047 + 0x0b8]
  19. stx %g3, [%sp + 2047 + 0x0c0]
  20. stx %g4, [%sp + 2047 + 0x0c8]
  21. stx %g5, [%sp + 2047 + 0x0d0]
  22. stx %g6, [%sp + 2047 + 0x0d8]
  23. stx %g7, [%sp + 2047 + 0x0e0]
  24. wrpr %g0, 0x814, %pstate ! save interrupt globals
  25. stx %g1, [%sp + 2047 + 0x0e8]
  26. stx %g2, [%sp + 2047 + 0x0f0]
  27. stx %g3, [%sp + 2047 + 0x0f8]
  28. stx %g4, [%sp + 2047 + 0x100]
  29. stx %g5, [%sp + 2047 + 0x108]
  30. stx %g6, [%sp + 2047 + 0x110]
  31. stx %g7, [%sp + 2047 + 0x118]
  32. wrpr %g0, 0x14, %pstate ! save normal globals
  33. stx %g1, [%sp + 2047 + 0x120]
  34. stx %g2, [%sp + 2047 + 0x128]
  35. stx %g3, [%sp + 2047 + 0x130]
  36. stx %g4, [%sp + 2047 + 0x138]
  37. stx %g5, [%sp + 2047 + 0x140]
  38. stx %g6, [%sp + 2047 + 0x148]
  39. stx %g7, [%sp + 2047 + 0x150]
  40. wrpr %g0, 0x414, %pstate ! save mmu globals
  41. stx %g1, [%sp + 2047 + 0x158]
  42. stx %g2, [%sp + 2047 + 0x160]
  43. stx %g3, [%sp + 2047 + 0x168]
  44. stx %g4, [%sp + 2047 + 0x170]
  45. stx %g5, [%sp + 2047 + 0x178]
  46. stx %g6, [%sp + 2047 + 0x180]
  47. stx %g7, [%sp + 2047 + 0x188]
  48. mov %g1, %l0 ! also save to locals, so we can handle
  49. mov %g2, %l1 ! tlb faults later on, when accessing
  50. mov %g3, %l3 ! the stack.
  51. mov %g7, %l5
  52. wrpr %l4, PSTATE_IE, %pstate ! turn off interrupts
  53. call %l2
  54. add %i0, 0x018, %o0 ! prom_args
  55. wrpr %g0, 0x414, %pstate ! restore mmu globals
  56. mov %l0, %g1
  57. mov %l1, %g2
  58. mov %l3, %g3
  59. mov %l5, %g7
  60. wrpr %g0, 0x14, %pstate ! restore normal globals
  61. ldx [%sp + 2047 + 0x120], %g1
  62. ldx [%sp + 2047 + 0x128], %g2
  63. ldx [%sp + 2047 + 0x130], %g3
  64. ldx [%sp + 2047 + 0x138], %g4
  65. ldx [%sp + 2047 + 0x140], %g5
  66. ldx [%sp + 2047 + 0x148], %g6
  67. ldx [%sp + 2047 + 0x150], %g7
  68. wrpr %g0, 0x814, %pstate ! restore interrupt globals
  69. ldx [%sp + 2047 + 0x0e8], %g1
  70. ldx [%sp + 2047 + 0x0f0], %g2
  71. ldx [%sp + 2047 + 0x0f8], %g3
  72. ldx [%sp + 2047 + 0x100], %g4
  73. ldx [%sp + 2047 + 0x108], %g5
  74. ldx [%sp + 2047 + 0x110], %g6
  75. ldx [%sp + 2047 + 0x118], %g7
  76. wrpr %g0, 0x15, %pstate ! restore alternate globals
  77. ldx [%sp + 2047 + 0x0b0], %g1
  78. ldx [%sp + 2047 + 0x0b8], %g2
  79. ldx [%sp + 2047 + 0x0c0], %g3
  80. ldx [%sp + 2047 + 0x0c8], %g4
  81. ldx [%sp + 2047 + 0x0d0], %g5
  82. ldx [%sp + 2047 + 0x0d8], %g6
  83. ldx [%sp + 2047 + 0x0e0], %g7
  84. wrpr %l4, 0, %pstate ! restore original pstate
  85. ret
  86. restore
  87. .globl prom_cif_callback
  88. prom_cif_callback:
  89. sethi %hi(p1275buf), %o1
  90. or %o1, %lo(p1275buf), %o1
  91. save %sp, -0x270, %sp
  92. rdpr %pstate, %l4
  93. wrpr %g0, 0x15, %pstate ! save PROM alternate globals
  94. stx %g1, [%sp + 2047 + 0x0b0]
  95. stx %g2, [%sp + 2047 + 0x0b8]
  96. stx %g3, [%sp + 2047 + 0x0c0]
  97. stx %g4, [%sp + 2047 + 0x0c8]
  98. stx %g5, [%sp + 2047 + 0x0d0]
  99. stx %g6, [%sp + 2047 + 0x0d8]
  100. stx %g7, [%sp + 2047 + 0x0e0]
  101. ! restore Linux alternate globals
  102. ldx [%sp + 2047 + 0x190], %g1
  103. ldx [%sp + 2047 + 0x198], %g2
  104. ldx [%sp + 2047 + 0x1a0], %g3
  105. ldx [%sp + 2047 + 0x1a8], %g4
  106. ldx [%sp + 2047 + 0x1b0], %g5
  107. ldx [%sp + 2047 + 0x1b8], %g6
  108. ldx [%sp + 2047 + 0x1c0], %g7
  109. wrpr %g0, 0x814, %pstate ! save PROM interrupt globals
  110. stx %g1, [%sp + 2047 + 0x0e8]
  111. stx %g2, [%sp + 2047 + 0x0f0]
  112. stx %g3, [%sp + 2047 + 0x0f8]
  113. stx %g4, [%sp + 2047 + 0x100]
  114. stx %g5, [%sp + 2047 + 0x108]
  115. stx %g6, [%sp + 2047 + 0x110]
  116. stx %g7, [%sp + 2047 + 0x118]
  117. ! restore Linux interrupt globals
  118. ldx [%sp + 2047 + 0x1c8], %g1
  119. ldx [%sp + 2047 + 0x1d0], %g2
  120. ldx [%sp + 2047 + 0x1d8], %g3
  121. ldx [%sp + 2047 + 0x1e0], %g4
  122. ldx [%sp + 2047 + 0x1e8], %g5
  123. ldx [%sp + 2047 + 0x1f0], %g6
  124. ldx [%sp + 2047 + 0x1f8], %g7
  125. wrpr %g0, 0x14, %pstate ! save PROM normal globals
  126. stx %g1, [%sp + 2047 + 0x120]
  127. stx %g2, [%sp + 2047 + 0x128]
  128. stx %g3, [%sp + 2047 + 0x130]
  129. stx %g4, [%sp + 2047 + 0x138]
  130. stx %g5, [%sp + 2047 + 0x140]
  131. stx %g6, [%sp + 2047 + 0x148]
  132. stx %g7, [%sp + 2047 + 0x150]
  133. ! restore Linux normal globals
  134. ldx [%sp + 2047 + 0x200], %g1
  135. ldx [%sp + 2047 + 0x208], %g2
  136. ldx [%sp + 2047 + 0x210], %g3
  137. ldx [%sp + 2047 + 0x218], %g4
  138. ldx [%sp + 2047 + 0x220], %g5
  139. ldx [%sp + 2047 + 0x228], %g6
  140. ldx [%sp + 2047 + 0x230], %g7
  141. wrpr %g0, 0x414, %pstate ! save PROM mmu globals
  142. stx %g1, [%sp + 2047 + 0x158]
  143. stx %g2, [%sp + 2047 + 0x160]
  144. stx %g3, [%sp + 2047 + 0x168]
  145. stx %g4, [%sp + 2047 + 0x170]
  146. stx %g5, [%sp + 2047 + 0x178]
  147. stx %g6, [%sp + 2047 + 0x180]
  148. stx %g7, [%sp + 2047 + 0x188]
  149. ! restore Linux mmu globals
  150. ldx [%sp + 2047 + 0x238], %o0
  151. ldx [%sp + 2047 + 0x240], %o1
  152. ldx [%sp + 2047 + 0x248], %l2
  153. ldx [%sp + 2047 + 0x250], %l3
  154. ldx [%sp + 2047 + 0x258], %l5
  155. ldx [%sp + 2047 + 0x260], %l6
  156. ldx [%sp + 2047 + 0x268], %l7
  157. ! switch to Linux tba
  158. sethi %hi(sparc64_ttable_tl0), %l1
  159. rdpr %tba, %l0 ! save PROM tba
  160. mov %o0, %g1
  161. mov %o1, %g2
  162. mov %l2, %g3
  163. mov %l3, %g4
  164. mov %l5, %g5
  165. mov %l6, %g6
  166. mov %l7, %g7
  167. wrpr %l1, %tba ! install Linux tba
  168. wrpr %l4, 0, %pstate ! restore PSTATE
  169. call prom_world
  170. mov %g0, %o0
  171. ldx [%i1 + 0x000], %l2
  172. call %l2
  173. mov %i0, %o0
  174. mov %o0, %l1
  175. call prom_world
  176. or %g0, 1, %o0
  177. wrpr %g0, 0x14, %pstate ! interrupts off
  178. ! restore PROM mmu globals
  179. ldx [%sp + 2047 + 0x158], %o0
  180. ldx [%sp + 2047 + 0x160], %o1
  181. ldx [%sp + 2047 + 0x168], %l2
  182. ldx [%sp + 2047 + 0x170], %l3
  183. ldx [%sp + 2047 + 0x178], %l5
  184. ldx [%sp + 2047 + 0x180], %l6
  185. ldx [%sp + 2047 + 0x188], %l7
  186. wrpr %g0, 0x414, %pstate ! restore PROM mmu globals
  187. mov %o0, %g1
  188. mov %o1, %g2
  189. mov %l2, %g3
  190. mov %l3, %g4
  191. mov %l5, %g5
  192. mov %l6, %g6
  193. mov %l7, %g7
  194. wrpr %l0, %tba ! restore PROM tba
  195. wrpr %g0, 0x14, %pstate ! restore PROM normal globals
  196. ldx [%sp + 2047 + 0x120], %g1
  197. ldx [%sp + 2047 + 0x128], %g2
  198. ldx [%sp + 2047 + 0x130], %g3
  199. ldx [%sp + 2047 + 0x138], %g4
  200. ldx [%sp + 2047 + 0x140], %g5
  201. ldx [%sp + 2047 + 0x148], %g6
  202. ldx [%sp + 2047 + 0x150], %g7
  203. wrpr %g0, 0x814, %pstate ! restore PROM interrupt globals
  204. ldx [%sp + 2047 + 0x0e8], %g1
  205. ldx [%sp + 2047 + 0x0f0], %g2
  206. ldx [%sp + 2047 + 0x0f8], %g3
  207. ldx [%sp + 2047 + 0x100], %g4
  208. ldx [%sp + 2047 + 0x108], %g5
  209. ldx [%sp + 2047 + 0x110], %g6
  210. ldx [%sp + 2047 + 0x118], %g7
  211. wrpr %g0, 0x15, %pstate ! restore PROM alternate globals
  212. ldx [%sp + 2047 + 0x0b0], %g1
  213. ldx [%sp + 2047 + 0x0b8], %g2
  214. ldx [%sp + 2047 + 0x0c0], %g3
  215. ldx [%sp + 2047 + 0x0c8], %g4
  216. ldx [%sp + 2047 + 0x0d0], %g5
  217. ldx [%sp + 2047 + 0x0d8], %g6
  218. ldx [%sp + 2047 + 0x0e0], %g7
  219. wrpr %l4, 0, %pstate
  220. ret
  221. restore %l1, 0, %o0