real2.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*
  2. *
  3. * This file is subject to the terms and conditions of the GNU General Public
  4. * License. See the file "COPYING" in the main directory of this archive
  5. * for more details.
  6. *
  7. * Copyright (C) 2000 Hewlett Packard (Paul Bame [email protected])
  8. *
  9. */
  10. #include <asm/pdc.h>
  11. #include <asm/psw.h>
  12. #include <asm/assembly.h>
  13. #include <asm/asm-offsets.h>
  14. #include <linux/linkage.h>
  15. .section .bss
  16. .export pdc_result
  17. .export pdc_result2
  18. .align 8
  19. pdc_result:
  20. .block ASM_PDC_RESULT_SIZE
  21. pdc_result2:
  22. .block ASM_PDC_RESULT_SIZE
  23. .export real_stack
  24. .export real32_stack
  25. .export real64_stack
  26. .align 64
  27. real_stack:
  28. real32_stack:
  29. real64_stack:
  30. .block 8192
  31. #define N_SAVED_REGS 9
  32. save_cr_space:
  33. .block REG_SZ * N_SAVED_REGS
  34. save_cr_end:
  35. /************************ 32-bit real-mode calls ***********************/
  36. /* This can be called in both narrow and wide kernels */
  37. .text
  38. /* unsigned long real32_call_asm(unsigned int *sp,
  39. * unsigned int *arg0p,
  40. * unsigned int iodc_fn)
  41. * sp is value of stack pointer to adopt before calling PDC (virt)
  42. * arg0p points to where saved arg values may be found
  43. * iodc_fn is the IODC function to call
  44. */
  45. ENTRY_CFI(real32_call_asm)
  46. STREG %rp, -RP_OFFSET(%sp) /* save RP */
  47. #ifdef CONFIG_64BIT
  48. callee_save
  49. ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */
  50. STREG %r27, -1*REG_SZ(%sp)
  51. STREG %r29, -2*REG_SZ(%sp)
  52. #endif
  53. STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */
  54. copy %arg0, %sp /* adopt the real-mode SP */
  55. /* save iodc_fn */
  56. copy %arg2, %r31
  57. /* load up the arg registers from the saved arg area */
  58. /* 32-bit calling convention passes first 4 args in registers */
  59. ldw 0(%arg1), %arg0 /* note overwriting arg0 */
  60. ldw -8(%arg1), %arg2
  61. ldw -12(%arg1), %arg3
  62. ldw -4(%arg1), %arg1 /* obviously must do this one last! */
  63. tophys_r1 %sp
  64. b,l rfi_virt2real,%r2
  65. nop
  66. b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
  67. nop
  68. #ifdef CONFIG_64BIT
  69. rsm PSW_SM_W, %r0 /* go narrow */
  70. #endif
  71. load32 PA(ric_ret), %r2
  72. bv 0(%r31)
  73. nop
  74. ric_ret:
  75. #ifdef CONFIG_64BIT
  76. ssm PSW_SM_W, %r0 /* go wide */
  77. #endif
  78. /* restore CRs before going virtual in case we page fault */
  79. b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
  80. nop
  81. b,l rfi_real2virt,%r2
  82. nop
  83. tovirt_r1 %sp
  84. LDREG -REG_SZ(%sp), %sp /* restore SP */
  85. #ifdef CONFIG_64BIT
  86. LDREG -1*REG_SZ(%sp), %r27
  87. LDREG -2*REG_SZ(%sp), %r29
  88. ldo -2*REG_SZ(%sp), %sp
  89. callee_rest
  90. #endif
  91. LDREG -RP_OFFSET(%sp), %rp /* restore RP */
  92. bv 0(%rp)
  93. nop
  94. ENDPROC_CFI(real32_call_asm)
  95. # define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where)
  96. # define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r
  97. .text
  98. ENTRY_CFI(save_control_regs)
  99. load32 PA(save_cr_space), %r28
  100. PUSH_CR(%cr24, %r28)
  101. PUSH_CR(%cr25, %r28)
  102. PUSH_CR(%cr26, %r28)
  103. PUSH_CR(%cr27, %r28)
  104. PUSH_CR(%cr28, %r28)
  105. PUSH_CR(%cr29, %r28)
  106. PUSH_CR(%cr30, %r28)
  107. PUSH_CR(%cr31, %r28)
  108. PUSH_CR(%cr15, %r28)
  109. bv 0(%r2)
  110. nop
  111. ENDPROC_CFI(save_control_regs)
  112. ENTRY_CFI(restore_control_regs)
  113. load32 PA(save_cr_end), %r26
  114. POP_CR(%cr15, %r26)
  115. POP_CR(%cr31, %r26)
  116. POP_CR(%cr30, %r26)
  117. POP_CR(%cr29, %r26)
  118. POP_CR(%cr28, %r26)
  119. POP_CR(%cr27, %r26)
  120. POP_CR(%cr26, %r26)
  121. POP_CR(%cr25, %r26)
  122. POP_CR(%cr24, %r26)
  123. bv 0(%r2)
  124. nop
  125. ENDPROC_CFI(restore_control_regs)
  126. /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
  127. * more general-purpose use by the several places which need RFIs
  128. */
  129. .text
  130. .align 128
  131. ENTRY_CFI(rfi_virt2real)
  132. #if !defined(BOOTLOADER)
  133. /* switch to real mode... */
  134. rsm PSW_SM_I,%r0
  135. load32 PA(rfi_v2r_1), %r1
  136. nop
  137. nop
  138. nop
  139. nop
  140. nop
  141. rsm PSW_SM_Q,%r0 /* disable Q & I bits to load iia queue */
  142. mtctl %r0, %cr17 /* Clear IIASQ tail */
  143. mtctl %r0, %cr17 /* Clear IIASQ head */
  144. mtctl %r1, %cr18 /* IIAOQ head */
  145. ldo 4(%r1), %r1
  146. mtctl %r1, %cr18 /* IIAOQ tail */
  147. load32 REAL_MODE_PSW, %r1
  148. mtctl %r1, %cr22
  149. rfi
  150. nop
  151. nop
  152. nop
  153. nop
  154. nop
  155. nop
  156. nop
  157. nop
  158. rfi_v2r_1:
  159. tophys_r1 %r2
  160. #endif /* defined(BOOTLOADER) */
  161. bv 0(%r2)
  162. nop
  163. ENDPROC_CFI(rfi_virt2real)
  164. .text
  165. .align 128
  166. ENTRY_CFI(rfi_real2virt)
  167. #if !defined(BOOTLOADER)
  168. rsm PSW_SM_I,%r0
  169. load32 (rfi_r2v_1), %r1
  170. nop
  171. nop
  172. nop
  173. nop
  174. nop
  175. rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */
  176. mtctl %r0, %cr17 /* Clear IIASQ tail */
  177. mtctl %r0, %cr17 /* Clear IIASQ head */
  178. mtctl %r1, %cr18 /* IIAOQ head */
  179. ldo 4(%r1), %r1
  180. mtctl %r1, %cr18 /* IIAOQ tail */
  181. load32 KERNEL_PSW, %r1
  182. mtctl %r1, %cr22
  183. rfi
  184. nop
  185. nop
  186. nop
  187. nop
  188. nop
  189. nop
  190. nop
  191. nop
  192. rfi_r2v_1:
  193. tovirt_r1 %r2
  194. #endif /* defined(BOOTLOADER) */
  195. bv 0(%r2)
  196. nop
  197. ENDPROC_CFI(rfi_real2virt)
  198. #ifdef CONFIG_64BIT
  199. /************************ 64-bit real-mode calls ***********************/
  200. /* This is only usable in wide kernels right now and will probably stay so */
  201. .text
  202. /* unsigned long real64_call_asm(unsigned long *sp,
  203. * unsigned long *arg0p,
  204. * unsigned long fn)
  205. * sp is value of stack pointer to adopt before calling PDC (virt)
  206. * arg0p points to where saved arg values may be found
  207. * iodc_fn is the IODC function to call
  208. */
  209. ENTRY_CFI(real64_call_asm)
  210. std %rp, -0x10(%sp) /* save RP */
  211. std %sp, -8(%arg0) /* save SP on real-mode stack */
  212. copy %arg0, %sp /* adopt the real-mode SP */
  213. /* save fn */
  214. copy %arg2, %r31
  215. /* load up the arg registers from the saved arg area */
  216. /* 32-bit calling convention passes first 4 args in registers */
  217. ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
  218. ldd 2*REG_SZ(%arg1), %arg2
  219. ldd 3*REG_SZ(%arg1), %arg3
  220. ldd 4*REG_SZ(%arg1), %r22
  221. ldd 5*REG_SZ(%arg1), %r21
  222. ldd 6*REG_SZ(%arg1), %r20
  223. ldd 7*REG_SZ(%arg1), %r19
  224. ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */
  225. /* set up real-mode stack and real-mode ap */
  226. tophys_r1 %sp
  227. ldo -16(%sp), %r29 /* Reference param save area */
  228. b,l rfi_virt2real,%r2
  229. nop
  230. b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
  231. nop
  232. load32 PA(r64_ret), %r2
  233. bv 0(%r31)
  234. nop
  235. r64_ret:
  236. /* restore CRs before going virtual in case we page fault */
  237. b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
  238. nop
  239. b,l rfi_real2virt,%r2
  240. nop
  241. tovirt_r1 %sp
  242. ldd -8(%sp), %sp /* restore SP */
  243. ldd -0x10(%sp), %rp /* restore RP */
  244. bv 0(%rp)
  245. nop
  246. ENDPROC_CFI(real64_call_asm)
  247. #endif
  248. .text
  249. /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html
  250. ** GCC 3.3 and later has a new function in libgcc.a for
  251. ** comparing function pointers.
  252. */
  253. ENTRY_CFI(__canonicalize_funcptr_for_compare)
  254. #ifdef CONFIG_64BIT
  255. bve (%r2)
  256. #else
  257. bv %r0(%r2)
  258. #endif
  259. copy %r26,%r28
  260. ENDPROC_CFI(__canonicalize_funcptr_for_compare)