entry.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:7k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2. At entry the registers contain the following information:
  3. r14 return address for undefined exception return
  4. r9 return address for return from exception
  5. r13 user registers on stack, offset 0 up to offset 4*15 contains
  6. registers r0..15, then the psr
  7. r10 FP workspace 35 words (init, reg[8][4], fpsr, fpcr)
  8.  
  9. */
  10. /*---------------------------------------------------------------------------*/
  11. .data
  12. fp_const:
  13. .word 0, 0x00000000, 0, 0x80000000 @ 0
  14. .word 0, 0x80000000, 0,          0 @ 1
  15. .word 0, 0x80000000, 0,          1 @ 2
  16. .word 0, 0xc0000000, 0,          1 @ 3
  17. .word 0, 0x80000000, 0,          2 @ 4
  18. .word 0, 0xa0000000, 0,          2 @ 5
  19. .word 0, 0x80000000, 0,   -1 @ 0.5
  20. .word 0, 0xa0000000, 0,          3 @ 10
  21. fp_undef:
  22. .word 0
  23. fp_cond:
  24. .word 0xf0f0 @ eq
  25. .word 0x0f0f @ ne
  26. .word 0xcccc @ cs
  27. .word 0x3333 @ cc
  28. .word 0xff00 @ mi
  29. .word 0x00ff @ pl
  30. .word 0xaaaa @ vs
  31. .word 0x5555 @ vc
  32. .word 0x0c0c @ hi
  33. .word 0xf3f3 @ ls
  34. .word 0xaa55 @ ge
  35. .word 0x55aa @ lt
  36. .word 0x0a05 @ gt
  37. .word 0xf5fa @ le
  38. .word 0xffff @ al
  39. .word 0x0000 @ nv
  40. /*---------------------------------------------------------------------------*/
  41. .text
  42. .globl fastfpe_enter
  43. fastfpe_enter:
  44. ldr r4,=fp_undef
  45. str r14,[r4] @ to free one register
  46. add r10,r10,#4 @ to make the code simpler
  47. ldr r4,[r13,#60] @ r4=saved PC
  48. ldr r4,[r4,#-4] @ r4=trapped instruction
  49. and r1,r4,#0x00000f00 @ r1=coprocessor << 8
  50. next_enter:
  51. cmp r1,#1<<8 @ copro 1 ?
  52. beq copro_1
  53. cmp r1,#2<<8
  54. movne pc,r14
  55. copro_2:
  56. and r1,r4,#0x0f000000
  57. cmp r1,#0x0c000000          @ CPDT with post indexing
  58.         cmpne   r1,#0x0d000000          @ CPDT with pre indexing
  59.         beq     CPDT_M_enter
  60. mov pc,r14
  61. copro_1:
  62. and r1,r4,#0x0f000000
  63. cmp r1,#0x0e000000 @ CPDO
  64. beq CPDO_CPRT_enter
  65. cmp r1,#0x0c000000 @ CPDT with post indexing
  66. cmpne r1,#0x0d000000 @ CPDT with pre indexing
  67. beq CPDT_1_enter
  68. mov pc,r14
  69. /*---------------------------------------------------------------------------*/
  70. .globl fastfpe_next
  71. fastfpe_next:
  72. ldr r5,[r13,#60]
  73. next_after_cond:
  74. __x1:
  75. ldrt r4,[r5],#4
  76. ldr r0,=fp_cond @ check condition of next instruction
  77. ldr r1,[r13,#64] @ psr containing flags
  78. mov r2,r4,lsr#28
  79. mov r1,r1,lsr#28
  80. ldr r0,[r0,r2,lsl#2]
  81. mov r0,r0,lsr r1
  82. tst r0,#1
  83. beq next_after_cond @ must not necessarily have been an
  84. @ FP instruction !
  85. and r1,r4,#0x0f000000 @ Test for copro instruction
  86. cmp r1,#0x0c000000
  87. rsbgts r0,r1,#0x0e000000 @ cmpgt #0x0e000000,r1
  88. movlt pc,r9 @ next is no copro instruction, return
  89. ands r1,r4,#0x00000f00 @ r1 = coprocessor << 8
  90. cmpne r1,#3<<8
  91. movge pc,r9 @ copro = 0 or >=3, return
  92. str r5,[r13,#60] @ save updated pc
  93. b next_enter
  94. /*---------------------------------------------------------------------------*/
  95. undefined:
  96. ldr r4,=fp_undef
  97. ldr pc,[r4]
  98. /*---------------------------------------------------------------------------*/
  99. CPDT_1_enter:
  100. and r5,r4,#0x000f0000 @ r5=base register number << 16
  101. ldr r6,[r13,r5,lsr#14] @ r6=base address
  102. cmp r5,#0x000f0000 @ base register = pc ?
  103. addeq r6,r6,#4
  104. and r7,r4,#0x000000ff @ r7=offset value
  105. tst r4,#0x00800000 @ up or down?
  106. addne r7,r6,r7,lsl#2
  107. subeq r7,r6,r7,lsl#2 @ r6=base address +/- offset
  108. tst r4,#0x01000000 @ preindexing ?
  109. movne r6,r7
  110. tst r4,#0x00200000 @ write back ?
  111. cmpne r5,#0x000f0000 @ base register = pc ?
  112. strne r7,[r13,r5,lsr#14]
  113. and r0,r4,#0x00007000 @ r0=fp register number << 12
  114. add r0,r10,r0,lsr#8 @ r0=address of fp register
  115. mov r1,#0
  116. tst r4,#0x00008000
  117. orrne r1,r1,#1 @ T0
  118. tst r4,#0x00400000
  119. orrne r1,r1,#2 @ T1
  120. tst r4,#0x00100000
  121. orrne r1,r1,#4 @ L/S
  122. add pc,pc,r1,lsl#2
  123. mov r0,r0
  124. b CPDT_store_single @ these functions get 
  125. b CPDT_store_double @ r0=address of fp register
  126. b CPDT_store_extended @ r6=address of data
  127. b undefined @ CPDT_store_decimal
  128.         b       CPDT_load_single
  129.         b       CPDT_load_double
  130.         b       CPDT_load_extended
  131.         b       undefined @ CPDT_load_decimal
  132. /*---------------------------------------------------------------------------*/
  133. CPDT_M_enter:
  134. and r5,r4,#0x000f0000 @ r5=base register number << 16
  135. ldr r6,[r13,r5,lsr#14] @ r6=base address
  136. cmp r5,#0x000f0000 @ base register = pc ?
  137. addeq r6,r6,#4
  138. and r7,r4,#0x000000ff @ r7=offset value
  139. tst r4,#0x00800000 @ up or down?
  140. addne r7,r6,r7,lsl#2
  141. subeq r7,r6,r7,lsl#2 @ r7=base address +/- offset
  142. tst r4,#0x01000000 @ preindexing ?
  143. movne r6,r7
  144. tst r4,#0x00200000 @ write back ?
  145. cmpne r5,#0x000f0000 @ base register = pc ?
  146. strne r7,[r13,r5,lsr#14]
  147. and r0,r4,#0x00007000 @ r0=fp register number << 12
  148. and r1,r4,#0x00008000
  149. mov r1,r1,lsr#15 @ N0
  150. and r2,r4,#0x00400000
  151. orrs r1,r1,r2,lsr#21 @ N1
  152. addeq r1,r1,#4 @ r1=register count
  153. tst r4,#0x00100000 @ load/store
  154. beq CPDT_sfm
  155. b CPDT_lfm
  156. /*---------------------------------------------------------------------------*/
  157. CPDO_CPRT_enter:
  158. tst r4,#0x00000010
  159. bne CPRT_enter
  160. and r0,r4,#0x00007000
  161. add r0,r10,r0,lsr#8 @ r0=address of Fd
  162. and r1,r4,#0x00070000
  163. add r1,r10,r1,lsr#12 @ r1=address of Fn
  164. tst r4,#0x00000008
  165. bne CPDO_const
  166. and r2,r4,#0x00000007
  167. add r2,r10,r2,lsl#4 @ r2=address of Fm
  168. CPDO_constback:
  169. and r3,r4,#0x00f00000
  170. tst r4,#0x00008000
  171. orrne r3,r3,#0x01000000
  172. add pc,pc,r3,lsr#18
  173. mov r0,r0
  174. b CPDO_adf
  175. b CPDO_muf
  176. b CPDO_suf
  177. b CPDO_rsf
  178. b CPDO_dvf
  179. b CPDO_rdf
  180. b undefined
  181. b undefined
  182. b undefined @ CPDO_rmf
  183. b CPDO_muf
  184. b CPDO_dvf
  185. b CPDO_rdf
  186. b undefined
  187. b undefined
  188. b undefined
  189. b undefined
  190. b CPDO_mvf
  191. b CPDO_mnf
  192. b CPDO_abs
  193. b CPDO_rnd
  194. b CPDO_sqt
  195. b undefined
  196. b undefined
  197. b undefined
  198. b undefined
  199. b undefined
  200. b undefined
  201. b undefined
  202. b undefined
  203. b undefined
  204. b CPDO_rnd
  205. b fastfpe_next
  206. CPDO_const:
  207. ldr r2,=fp_const
  208. and r3,r4,#0x00000007
  209. add r2,r2,r3,lsl#4
  210. b CPDO_constback
  211. /*---------------------------------------------------------------------------*/
  212. CPRT_enter:
  213. and r0,r4,#0x0000f000 @ r0=Rd<<12
  214. and r1,r4,#0x00070000
  215. add r1,r10,r1,lsr#12 @ r1=address of Fn
  216. tst r4,#0x00000008
  217. bne CPRT_const
  218. and r2,r4,#0x00000007
  219. add r2,r10,r2,lsl#4 @ r2=address of Fm
  220. CPRT_constback:
  221. and r3,r4,#0x00f00000
  222. add pc,pc,r3,lsr#18
  223. mov r0,r0
  224. b CPRT_flt
  225. b CPRT_fix
  226. b CPRT_wfs
  227. b CPRT_rfs
  228. b undefined
  229. b undefined
  230. b undefined
  231. b undefined
  232. b undefined
  233. b CPRT_cmf
  234. b undefined
  235. b CPRT_cnf
  236. b undefined
  237. b CPRT_cmf
  238. b undefined
  239. b CPRT_cnf
  240. CPRT_const:
  241. ldr r2,=fp_const
  242. and r3,r4,#0x00000007
  243. add r2,r2,r3,lsl#4
  244. b CPRT_constback
  245. /*---------------------------------------------------------------------------*/
  246. @ The fetch of the next instruction to emulate could fault
  247. .section .fixup,"ax"
  248. .align
  249. __f1:
  250. mov pc,r9
  251. .previous
  252. .section __ex_table,"a"
  253. .align 3
  254. .long __x1,__f1
  255. .previous
  256. /*---------------------------------------------------------------------------*/