asm.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*
  2. * Copyright (C) 2002 Wolfgang Denk <wd@denx.de>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <config.h>
  23. #ifdef CONFIG_POST
  24. #include <post.h>
  25. #include <ppc_asm.tmpl>
  26. #include <ppc_defs.h>
  27. #include <asm/cache.h>
  28. #if CONFIG_POST & CFG_POST_CPU
  29. /* void cpu_post_exec_02 (ulong *code, ulong op1, ulong op2); */
  30. .global cpu_post_exec_02
  31. cpu_post_exec_02:
  32. mflr r0
  33. stwu r0, -4(r1)
  34. subi r1, r1, 104
  35. stmw r6, 0(r1)
  36. mtlr r3
  37. mr r3, r4
  38. mr r4, r5
  39. blrl
  40. lmw r6, 0(r1)
  41. addi r1, r1, 104
  42. lwz r0, 0(r1)
  43. addi r1, r1, 4
  44. mtlr r0
  45. blr
  46. /* void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, ulong op4); */
  47. .global cpu_post_exec_04
  48. cpu_post_exec_04:
  49. mflr r0
  50. stwu r0, -4(r1)
  51. subi r1, r1, 96
  52. stmw r8, 0(r1)
  53. mtlr r3
  54. mr r3, r4
  55. mr r4, r5
  56. mr r5, r6
  57. mtxer r7
  58. blrl
  59. lmw r8, 0(r1)
  60. addi r1, r1, 96
  61. lwz r0, 0(r1)
  62. addi r1, r1, 4
  63. mtlr r0
  64. blr
  65. /* void cpu_post_exec_12 (ulong *code, ulong *res, ulong op1, ulong op2); */
  66. .global cpu_post_exec_12
  67. cpu_post_exec_12:
  68. mflr r0
  69. stwu r0, -4(r1)
  70. stwu r4, -4(r1)
  71. mtlr r3
  72. mr r3, r5
  73. mr r4, r6
  74. blrl
  75. lwz r4, 0(r1)
  76. stw r3, 0(r4)
  77. lwz r0, 4(r1)
  78. addi r1, r1, 8
  79. mtlr r0
  80. blr
  81. /* void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); */
  82. .global cpu_post_exec_11
  83. cpu_post_exec_11:
  84. mflr r0
  85. stwu r0, -4(r1)
  86. stwu r4, -4(r1)
  87. mtlr r3
  88. mr r3, r5
  89. blrl
  90. lwz r4, 0(r1)
  91. stw r3, 0(r4)
  92. lwz r0, 4(r1)
  93. addi r1, r1, 8
  94. mtlr r0
  95. blr
  96. /* void cpu_post_exec_21 (ulong *code, ulong *cr, ulong *res, ulong op1); */
  97. .global cpu_post_exec_21
  98. cpu_post_exec_21:
  99. mflr r0
  100. stwu r0, -4(r1)
  101. stwu r4, -4(r1)
  102. stwu r5, -4(r1)
  103. li r0, 0
  104. mtxer r0
  105. lwz r0, 0(r4)
  106. mtcr r0
  107. mtlr r3
  108. mr r3, r6
  109. blrl
  110. mfcr r0
  111. lwz r4, 4(r1)
  112. stw r0, 0(r4)
  113. lwz r4, 0(r1)
  114. stw r3, 0(r4)
  115. lwz r0, 8(r1)
  116. addi r1, r1, 12
  117. mtlr r0
  118. blr
  119. /* void cpu_post_exec_22 (ulong *code, ulong *cr, ulong *res, ulong op1,
  120. ulong op2); */
  121. .global cpu_post_exec_22
  122. cpu_post_exec_22:
  123. mflr r0
  124. stwu r0, -4(r1)
  125. stwu r4, -4(r1)
  126. stwu r5, -4(r1)
  127. li r0, 0
  128. mtxer r0
  129. lwz r0, 0(r4)
  130. mtcr r0
  131. mtlr r3
  132. mr r3, r6
  133. mr r4, r7
  134. blrl
  135. mfcr r0
  136. lwz r4, 4(r1)
  137. stw r0, 0(r4)
  138. lwz r4, 0(r1)
  139. stw r3, 0(r4)
  140. lwz r0, 8(r1)
  141. addi r1, r1, 12
  142. mtlr r0
  143. blr
  144. /* void cpu_post_exec_12w (ulong *code, ulong *op1, ulong op2, ulong op3); */
  145. .global cpu_post_exec_12w
  146. cpu_post_exec_12w:
  147. mflr r0
  148. stwu r0, -4(r1)
  149. stwu r4, -4(r1)
  150. mtlr r3
  151. lwz r3, 0(r4)
  152. mr r4, r5
  153. mr r5, r6
  154. blrl
  155. lwz r4, 0(r1)
  156. stw r3, 0(r4)
  157. lwz r0, 4(r1)
  158. addi r1, r1, 8
  159. mtlr r0
  160. blr
  161. /* void cpu_post_exec_11w (ulong *code, ulong *op1, ulong op2); */
  162. .global cpu_post_exec_11w
  163. cpu_post_exec_11w:
  164. mflr r0
  165. stwu r0, -4(r1)
  166. stwu r4, -4(r1)
  167. mtlr r3
  168. lwz r3, 0(r4)
  169. mr r4, r5
  170. blrl
  171. lwz r4, 0(r1)
  172. stw r3, 0(r4)
  173. lwz r0, 4(r1)
  174. addi r1, r1, 8
  175. mtlr r0
  176. blr
  177. /* void cpu_post_exec_22w (ulong *code, ulong *op1, ulong op2, ulong *op3); */
  178. .global cpu_post_exec_22w
  179. cpu_post_exec_22w:
  180. mflr r0
  181. stwu r0, -4(r1)
  182. stwu r4, -4(r1)
  183. stwu r6, -4(r1)
  184. mtlr r3
  185. lwz r3, 0(r4)
  186. mr r4, r5
  187. blrl
  188. lwz r4, 4(r1)
  189. stw r3, 0(r4)
  190. lwz r4, 0(r1)
  191. stw r5, 0(r4)
  192. lwz r0, 8(r1)
  193. addi r1, r1, 12
  194. mtlr r0
  195. blr
  196. /* void cpu_post_exec_21w (ulong *code, ulong *op1, ulong *op2); */
  197. .global cpu_post_exec_21w
  198. cpu_post_exec_21w:
  199. mflr r0
  200. stwu r0, -4(r1)
  201. stwu r4, -4(r1)
  202. stwu r5, -4(r1)
  203. mtlr r3
  204. lwz r3, 0(r4)
  205. blrl
  206. lwz r5, 4(r1)
  207. stw r3, 0(r5)
  208. lwz r5, 0(r1)
  209. stw r4, 0(r5)
  210. lwz r0, 8(r1)
  211. addi r1, r1, 12
  212. mtlr r0
  213. blr
  214. /* void cpu_post_exec_21x (ulong *code, ulong *op1, ulong *op2, ulong op3); */
  215. .global cpu_post_exec_21x
  216. cpu_post_exec_21x:
  217. mflr r0
  218. stwu r0, -4(r1)
  219. stwu r4, -4(r1)
  220. stwu r5, -4(r1)
  221. mtlr r3
  222. mr r3, r6
  223. blrl
  224. lwz r5, 4(r1)
  225. stw r3, 0(r5)
  226. lwz r5, 0(r1)
  227. stw r4, 0(r5)
  228. lwz r0, 8(r1)
  229. addi r1, r1, 12
  230. mtlr r0
  231. blr
  232. /* void cpu_post_exec_31 (ulong *code, ulong *ctr, ulong *lr, ulong *jump,
  233. ulong cr); */
  234. .global cpu_post_exec_31
  235. cpu_post_exec_31:
  236. mflr r0
  237. stwu r0, -4(r1)
  238. stwu r4, -4(r1)
  239. stwu r5, -4(r1)
  240. stwu r6, -4(r1)
  241. mtlr r3
  242. lwz r3, 0(r4)
  243. lwz r4, 0(r5)
  244. mr r6, r7
  245. blrl
  246. lwz r7, 8(r1)
  247. stw r3, 0(r7)
  248. lwz r7, 4(r1)
  249. stw r4, 0(r7)
  250. lwz r7, 0(r1)
  251. stw r5, 0(r7)
  252. lwz r0, 12(r1)
  253. addi r1, r1, 16
  254. mtlr r0
  255. blr
  256. /* int cpu_post_complex_1_asm (int a1, int a2, int a3, int a4, int n); */
  257. .global cpu_post_complex_1_asm
  258. cpu_post_complex_1_asm:
  259. li r9,0
  260. cmpw r9,r7
  261. bge cpu_post_complex_1_done
  262. mtctr r7
  263. cpu_post_complex_1_loop:
  264. mullw r0,r3,r4
  265. subf r0,r5,r0
  266. divw r0,r0,r6
  267. add r9,r9,r0
  268. bdnz cpu_post_complex_1_loop
  269. cpu_post_complex_1_done:
  270. mr r3,r9
  271. blr
  272. /* int cpu_post_complex_2_asm (int x, int n); */
  273. .global cpu_post_complex_2_asm
  274. cpu_post_complex_2_asm:
  275. mr. r0,r4
  276. mtctr r0
  277. mr r0,r3
  278. li r3,1
  279. li r4,1
  280. blelr
  281. cpu_post_complex_2_loop:
  282. mullw r3,r3,r0
  283. add r3,r3,r4
  284. bdnz cpu_post_complex_2_loop
  285. blr
  286. #endif
  287. #endif