fp_entry.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. /*
  2. * fp_emu.S
  3. *
  4. * Copyright Roman Zippel, 1997. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, and the entire permission notice in its entirety,
  11. * including the disclaimer of warranties.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. The name of the author may not be used to endorse or promote
  16. * products derived from this software without specific prior
  17. * written permission.
  18. *
  19. * ALTERNATIVELY, this product may be distributed under the terms of
  20. * the GNU General Public License, in which case the provisions of the GPL are
  21. * required INSTEAD OF the above restrictions. (This clause is
  22. * necessary due to a potential bad interaction between the GPL and
  23. * the restrictions contained in a BSD-style copyright.)
  24. *
  25. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  26. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  29. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  33. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  35. * OF THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #include <linux/linkage.h>
  38. #include <asm/entry.h>
  39. #include "fp_emu.h"
  40. .globl fpu_emu
  41. .globl fp_debugprint
  42. .globl fp_err_ua1,fp_err_ua2
  43. .text
  44. fpu_emu:
  45. SAVE_ALL_INT
  46. GET_CURRENT(%d0)
  47. #if defined(CPU_M68020_OR_M68030) && defined(CPU_M68040_OR_M68060)
  48. tst.l m68k_is040or060
  49. jeq 1f
  50. #endif
  51. #if defined(CPU_M68040_OR_M68060)
  52. move.l (FPS_PC2,%sp),(FPS_PC,%sp)
  53. #endif
  54. 1:
  55. | emulate the instruction
  56. jsr fp_scan
  57. #if defined(CONFIG_M68060)
  58. #if !defined(CPU_M68060_ONLY)
  59. btst #3,m68k_cputype+3
  60. jeq 1f
  61. #endif
  62. btst #7,(FPS_SR,%sp)
  63. jne fp_sendtrace060
  64. #endif
  65. 1:
  66. | emulation successful?
  67. tst.l %d0
  68. jeq ret_from_exception
  69. | send some signal to program here
  70. jra ret_from_exception
  71. | we jump here after an access error while trying to access
  72. | user space, we correct stackpointer and send a SIGSEGV to
  73. | the user process
  74. fp_err_ua2:
  75. addq.l #4,%sp
  76. fp_err_ua1:
  77. addq.l #4,%sp
  78. move.l %a0,-(%sp)
  79. pea LSEGV_MAPERR
  80. pea LSIGSEGV
  81. jsr fpemu_signal
  82. add.w #12,%sp
  83. jra ret_from_exception
  84. #if defined(CONFIG_M68060)
  85. | send a trace signal if we are debugged
  86. | it does not really belong here, but...
  87. fp_sendtrace060:
  88. move.l (FPS_PC,%sp),-(%sp)
  89. pea LTRAP_TRACE
  90. pea LSIGTRAP
  91. jsr fpemu_signal
  92. add.w #12,%sp
  93. jra ret_from_exception
  94. #endif
  95. .globl fp_get_data_reg, fp_put_data_reg
  96. .globl fp_get_addr_reg, fp_put_addr_reg
  97. | Entry points to get/put a register. Some of them can be get/put
  98. | directly, others are on the stack, as we read/write the stack
  99. | directly here, these function may only be called from within
  100. | instruction decoding, otherwise the stack pointer is incorrect
  101. | and the stack gets corrupted.
  102. fp_get_data_reg:
  103. jmp ([0f:w,%pc,%d0.w*4])
  104. .align 4
  105. 0:
  106. .long fp_get_d0, fp_get_d1
  107. .long fp_get_d2, fp_get_d3
  108. .long fp_get_d4, fp_get_d5
  109. .long fp_get_d6, fp_get_d7
  110. fp_get_d0:
  111. move.l (PT_OFF_D0+8,%sp),%d0
  112. printf PREGISTER,"{d0->%08x}",1,%d0
  113. rts
  114. fp_get_d1:
  115. move.l (PT_OFF_D1+8,%sp),%d0
  116. printf PREGISTER,"{d1->%08x}",1,%d0
  117. rts
  118. fp_get_d2:
  119. move.l (PT_OFF_D2+8,%sp),%d0
  120. printf PREGISTER,"{d2->%08x}",1,%d0
  121. rts
  122. fp_get_d3:
  123. move.l %d3,%d0
  124. printf PREGISTER,"{d3->%08x}",1,%d0
  125. rts
  126. fp_get_d4:
  127. move.l %d4,%d0
  128. printf PREGISTER,"{d4->%08x}",1,%d0
  129. rts
  130. fp_get_d5:
  131. move.l %d5,%d0
  132. printf PREGISTER,"{d5->%08x}",1,%d0
  133. rts
  134. fp_get_d6:
  135. move.l %d6,%d0
  136. printf PREGISTER,"{d6->%08x}",1,%d0
  137. rts
  138. fp_get_d7:
  139. move.l %d7,%d0
  140. printf PREGISTER,"{d7->%08x}",1,%d0
  141. rts
  142. fp_put_data_reg:
  143. jmp ([0f:w,%pc,%d1.w*4])
  144. .align 4
  145. 0:
  146. .long fp_put_d0, fp_put_d1
  147. .long fp_put_d2, fp_put_d3
  148. .long fp_put_d4, fp_put_d5
  149. .long fp_put_d6, fp_put_d7
  150. fp_put_d0:
  151. printf PREGISTER,"{d0<-%08x}",1,%d0
  152. move.l %d0,(PT_OFF_D0+8,%sp)
  153. rts
  154. fp_put_d1:
  155. printf PREGISTER,"{d1<-%08x}",1,%d0
  156. move.l %d0,(PT_OFF_D1+8,%sp)
  157. rts
  158. fp_put_d2:
  159. printf PREGISTER,"{d2<-%08x}",1,%d0
  160. move.l %d0,(PT_OFF_D2+8,%sp)
  161. rts
  162. fp_put_d3:
  163. printf PREGISTER,"{d3<-%08x}",1,%d0
  164. | move.l %d0,%d3
  165. move.l %d0,(PT_OFF_D3+8,%sp)
  166. rts
  167. fp_put_d4:
  168. printf PREGISTER,"{d4<-%08x}",1,%d0
  169. | move.l %d0,%d4
  170. move.l %d0,(PT_OFF_D4+8,%sp)
  171. rts
  172. fp_put_d5:
  173. printf PREGISTER,"{d5<-%08x}",1,%d0
  174. | move.l %d0,%d5
  175. move.l %d0,(PT_OFF_D5+8,%sp)
  176. rts
  177. fp_put_d6:
  178. printf PREGISTER,"{d6<-%08x}",1,%d0
  179. move.l %d0,%d6
  180. rts
  181. fp_put_d7:
  182. printf PREGISTER,"{d7<-%08x}",1,%d0
  183. move.l %d0,%d7
  184. rts
  185. fp_get_addr_reg:
  186. jmp ([0f:w,%pc,%d0.w*4])
  187. .align 4
  188. 0:
  189. .long fp_get_a0, fp_get_a1
  190. .long fp_get_a2, fp_get_a3
  191. .long fp_get_a4, fp_get_a5
  192. .long fp_get_a6, fp_get_a7
  193. fp_get_a0:
  194. move.l (PT_OFF_A0+8,%sp),%a0
  195. printf PREGISTER,"{a0->%08x}",1,%a0
  196. rts
  197. fp_get_a1:
  198. move.l (PT_OFF_A1+8,%sp),%a0
  199. printf PREGISTER,"{a1->%08x}",1,%a0
  200. rts
  201. fp_get_a2:
  202. move.l (PT_OFF_A2+8,%sp),%a0
  203. printf PREGISTER,"{a2->%08x}",1,%a0
  204. rts
  205. fp_get_a3:
  206. move.l %a3,%a0
  207. printf PREGISTER,"{a3->%08x}",1,%a0
  208. rts
  209. fp_get_a4:
  210. move.l %a4,%a0
  211. printf PREGISTER,"{a4->%08x}",1,%a0
  212. rts
  213. fp_get_a5:
  214. move.l %a5,%a0
  215. printf PREGISTER,"{a5->%08x}",1,%a0
  216. rts
  217. fp_get_a6:
  218. move.l %a6,%a0
  219. printf PREGISTER,"{a6->%08x}",1,%a0
  220. rts
  221. fp_get_a7:
  222. move.l %usp,%a0
  223. printf PREGISTER,"{a7->%08x}",1,%a0
  224. rts
  225. fp_put_addr_reg:
  226. jmp ([0f:w,%pc,%d0.w*4])
  227. .align 4
  228. 0:
  229. .long fp_put_a0, fp_put_a1
  230. .long fp_put_a2, fp_put_a3
  231. .long fp_put_a4, fp_put_a5
  232. .long fp_put_a6, fp_put_a7
  233. fp_put_a0:
  234. printf PREGISTER,"{a0<-%08x}",1,%a0
  235. move.l %a0,(PT_OFF_A0+8,%sp)
  236. rts
  237. fp_put_a1:
  238. printf PREGISTER,"{a1<-%08x}",1,%a0
  239. move.l %a0,(PT_OFF_A1+8,%sp)
  240. rts
  241. fp_put_a2:
  242. printf PREGISTER,"{a2<-%08x}",1,%a0
  243. move.l %a0,(PT_OFF_A2+8,%sp)
  244. rts
  245. fp_put_a3:
  246. printf PREGISTER,"{a3<-%08x}",1,%a0
  247. move.l %a0,%a3
  248. rts
  249. fp_put_a4:
  250. printf PREGISTER,"{a4<-%08x}",1,%a0
  251. move.l %a0,%a4
  252. rts
  253. fp_put_a5:
  254. printf PREGISTER,"{a5<-%08x}",1,%a0
  255. move.l %a0,%a5
  256. rts
  257. fp_put_a6:
  258. printf PREGISTER,"{a6<-%08x}",1,%a0
  259. move.l %a0,%a6
  260. rts
  261. fp_put_a7:
  262. printf PREGISTER,"{a7<-%08x}",1,%a0
  263. move.l %a0,%usp
  264. rts
  265. .data
  266. .align 4
  267. fp_debugprint:
  268. | .long PMDECODE
  269. .long PMINSTR+PMDECODE+PMCONV+PMNORM
  270. | .long PMCONV+PMNORM+PMINSTR
  271. | .long 0