fp_entry.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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/config.h>
  38. #include <linux/linkage.h>
  39. #include <asm/entry.h>
  40. #include "fp_emu.h"
  41. .globl fpu_emu
  42. .globl fp_debugprint
  43. .globl fp_err_ua1,fp_err_ua2
  44. .text
  45. fpu_emu:
  46. SAVE_ALL_INT
  47. GET_CURRENT(%d0)
  48. #if defined(CPU_M68020_OR_M68030) && defined(CPU_M68040_OR_M68060)
  49. tst.l m68k_is040or060
  50. jeq 1f
  51. #endif
  52. #if defined(CPU_M68040_OR_M68060)
  53. move.l (FPS_PC2,%sp),(FPS_PC,%sp)
  54. #endif
  55. 1:
  56. | emulate the instruction
  57. jsr fp_scan
  58. #if defined(CONFIG_M68060)
  59. #if !defined(CPU_M68060_ONLY)
  60. btst #3,m68k_cputype+3
  61. jeq 1f
  62. #endif
  63. btst #7,(FPS_SR,%sp)
  64. jne fp_sendtrace060
  65. #endif
  66. 1:
  67. | emulation successful?
  68. tst.l %d0
  69. jeq ret_from_exception
  70. | send some signal to program here
  71. jra ret_from_exception
  72. | we jump here after an access error while trying to access
  73. | user space, we correct stackpointer and send a SIGSEGV to
  74. | the user process
  75. fp_err_ua2:
  76. addq.l #4,%sp
  77. fp_err_ua1:
  78. addq.l #4,%sp
  79. move.l %a0,-(%sp)
  80. pea SEGV_MAPERR
  81. pea SIGSEGV
  82. jsr fpemu_signal
  83. add.w #12,%sp
  84. jra ret_from_exception
  85. #if defined(CONFIG_M68060)
  86. | send a trace signal if we are debugged
  87. | it does not really belong here, but...
  88. fp_sendtrace060:
  89. move.l (FPS_PC,%sp),-(%sp)
  90. pea TRAP_TRACE
  91. pea SIGTRAP
  92. jsr fpemu_signal
  93. add.w #12,%sp
  94. jra ret_from_exception
  95. #endif
  96. .globl fp_get_data_reg, fp_put_data_reg
  97. .globl fp_get_addr_reg, fp_put_addr_reg
  98. | Entry points to get/put a register. Some of them can be get/put
  99. | directly, others are on the stack, as we read/write the stack
  100. | directly here, these function may only be called from within
  101. | instruction decoding, otherwise the stack pointer is incorrect
  102. | and the stack gets corrupted.
  103. fp_get_data_reg:
  104. jmp ([0f:w,%pc,%d0.w*4])
  105. .align 4
  106. 0:
  107. .long fp_get_d0, fp_get_d1
  108. .long fp_get_d2, fp_get_d3
  109. .long fp_get_d4, fp_get_d5
  110. .long fp_get_d6, fp_get_d7
  111. fp_get_d0:
  112. move.l (PT_D0+8,%sp),%d0
  113. printf PREGISTER,"{d0->%08x}",1,%d0
  114. rts
  115. fp_get_d1:
  116. move.l (PT_D1+8,%sp),%d0
  117. printf PREGISTER,"{d1->%08x}",1,%d0
  118. rts
  119. fp_get_d2:
  120. move.l (PT_D2+8,%sp),%d0
  121. printf PREGISTER,"{d2->%08x}",1,%d0
  122. rts
  123. fp_get_d3:
  124. move.l %d3,%d0
  125. printf PREGISTER,"{d3->%08x}",1,%d0
  126. rts
  127. fp_get_d4:
  128. move.l %d4,%d0
  129. printf PREGISTER,"{d4->%08x}",1,%d0
  130. rts
  131. fp_get_d5:
  132. move.l %d5,%d0
  133. printf PREGISTER,"{d5->%08x}",1,%d0
  134. rts
  135. fp_get_d6:
  136. move.l %d6,%d0
  137. printf PREGISTER,"{d6->%08x}",1,%d0
  138. rts
  139. fp_get_d7:
  140. move.l %d7,%d0
  141. printf PREGISTER,"{d7->%08x}",1,%d0
  142. rts
  143. fp_put_data_reg:
  144. jmp ([0f:w,%pc,%d1.w*4])
  145. .align 4
  146. 0:
  147. .long fp_put_d0, fp_put_d1
  148. .long fp_put_d2, fp_put_d3
  149. .long fp_put_d4, fp_put_d5
  150. .long fp_put_d6, fp_put_d7
  151. fp_put_d0:
  152. printf PREGISTER,"{d0<-%08x}",1,%d0
  153. move.l %d0,(PT_D0+8,%sp)
  154. rts
  155. fp_put_d1:
  156. printf PREGISTER,"{d1<-%08x}",1,%d0
  157. move.l %d0,(PT_D1+8,%sp)
  158. rts
  159. fp_put_d2:
  160. printf PREGISTER,"{d2<-%08x}",1,%d0
  161. move.l %d0,(PT_D2+8,%sp)
  162. rts
  163. fp_put_d3:
  164. printf PREGISTER,"{d3<-%08x}",1,%d0
  165. | move.l %d0,%d3
  166. move.l %d0,(PT_D3+8,%sp)
  167. rts
  168. fp_put_d4:
  169. printf PREGISTER,"{d4<-%08x}",1,%d0
  170. | move.l %d0,%d4
  171. move.l %d0,(PT_D4+8,%sp)
  172. rts
  173. fp_put_d5:
  174. printf PREGISTER,"{d5<-%08x}",1,%d0
  175. | move.l %d0,%d5
  176. move.l %d0,(PT_D5+8,%sp)
  177. rts
  178. fp_put_d6:
  179. printf PREGISTER,"{d6<-%08x}",1,%d0
  180. move.l %d0,%d6
  181. rts
  182. fp_put_d7:
  183. printf PREGISTER,"{d7<-%08x}",1,%d0
  184. move.l %d0,%d7
  185. rts
  186. fp_get_addr_reg:
  187. jmp ([0f:w,%pc,%d0.w*4])
  188. .align 4
  189. 0:
  190. .long fp_get_a0, fp_get_a1
  191. .long fp_get_a2, fp_get_a3
  192. .long fp_get_a4, fp_get_a5
  193. .long fp_get_a6, fp_get_a7
  194. fp_get_a0:
  195. move.l (PT_A0+8,%sp),%a0
  196. printf PREGISTER,"{a0->%08x}",1,%a0
  197. rts
  198. fp_get_a1:
  199. move.l (PT_A1+8,%sp),%a0
  200. printf PREGISTER,"{a1->%08x}",1,%a0
  201. rts
  202. fp_get_a2:
  203. move.l (PT_A2+8,%sp),%a0
  204. printf PREGISTER,"{a2->%08x}",1,%a0
  205. rts
  206. fp_get_a3:
  207. move.l %a3,%a0
  208. printf PREGISTER,"{a3->%08x}",1,%a0
  209. rts
  210. fp_get_a4:
  211. move.l %a4,%a0
  212. printf PREGISTER,"{a4->%08x}",1,%a0
  213. rts
  214. fp_get_a5:
  215. move.l %a5,%a0
  216. printf PREGISTER,"{a5->%08x}",1,%a0
  217. rts
  218. fp_get_a6:
  219. move.l %a6,%a0
  220. printf PREGISTER,"{a6->%08x}",1,%a0
  221. rts
  222. fp_get_a7:
  223. move.l %usp,%a0
  224. printf PREGISTER,"{a7->%08x}",1,%a0
  225. rts
  226. fp_put_addr_reg:
  227. jmp ([0f:w,%pc,%d0.w*4])
  228. .align 4
  229. 0:
  230. .long fp_put_a0, fp_put_a1
  231. .long fp_put_a2, fp_put_a3
  232. .long fp_put_a4, fp_put_a5
  233. .long fp_put_a6, fp_put_a7
  234. fp_put_a0:
  235. printf PREGISTER,"{a0<-%08x}",1,%a0
  236. move.l %a0,(PT_A0+8,%sp)
  237. rts
  238. fp_put_a1:
  239. printf PREGISTER,"{a1<-%08x}",1,%a0
  240. move.l %a0,(PT_A1+8,%sp)
  241. rts
  242. fp_put_a2:
  243. printf PREGISTER,"{a2<-%08x}",1,%a0
  244. move.l %a0,(PT_A2+8,%sp)
  245. rts
  246. fp_put_a3:
  247. printf PREGISTER,"{a3<-%08x}",1,%a0
  248. move.l %a0,%a3
  249. rts
  250. fp_put_a4:
  251. printf PREGISTER,"{a4<-%08x}",1,%a0
  252. move.l %a0,%a4
  253. rts
  254. fp_put_a5:
  255. printf PREGISTER,"{a5<-%08x}",1,%a0
  256. move.l %a0,%a5
  257. rts
  258. fp_put_a6:
  259. printf PREGISTER,"{a6<-%08x}",1,%a0
  260. move.l %a0,%a6
  261. rts
  262. fp_put_a7:
  263. printf PREGISTER,"{a7<-%08x}",1,%a0
  264. move.l %a0,%usp
  265. rts
  266. .data
  267. .align 4
  268. fp_debugprint:
  269. | .long PMDECODE
  270. .long PMINSTR+PMDECODE+PMCONV+PMNORM
  271. | .long PMCONV+PMNORM+PMINSTR
  272. | .long 0