asm.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. isync
  33. mflr r0
  34. stwu r0, -4(r1)
  35. subi r1, r1, 104
  36. stmw r6, 0(r1)
  37. mtlr r3
  38. mr r3, r4
  39. mr r4, r5
  40. blrl
  41. lmw r6, 0(r1)
  42. addi r1, r1, 104
  43. lwz r0, 0(r1)
  44. addi r1, r1, 4
  45. mtlr r0
  46. blr
  47. /* void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, ulong op4); */
  48. .global cpu_post_exec_04
  49. cpu_post_exec_04:
  50. isync
  51. mflr r0
  52. stwu r0, -4(r1)
  53. subi r1, r1, 96
  54. stmw r8, 0(r1)
  55. mtlr r3
  56. mr r3, r4
  57. mr r4, r5
  58. mr r5, r6
  59. mtxer r7
  60. blrl
  61. lmw r8, 0(r1)
  62. addi r1, r1, 96
  63. lwz r0, 0(r1)
  64. addi r1, r1, 4
  65. mtlr r0
  66. blr
  67. /* void cpu_post_exec_12 (ulong *code, ulong *res, ulong op1, ulong op2); */
  68. .global cpu_post_exec_12
  69. cpu_post_exec_12:
  70. isync
  71. mflr r0
  72. stwu r0, -4(r1)
  73. stwu r4, -4(r1)
  74. mtlr r3
  75. mr r3, r5
  76. mr r4, r6
  77. blrl
  78. lwz r4, 0(r1)
  79. stw r3, 0(r4)
  80. lwz r0, 4(r1)
  81. addi r1, r1, 8
  82. mtlr r0
  83. blr
  84. /* void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); */
  85. .global cpu_post_exec_11
  86. cpu_post_exec_11:
  87. isync
  88. mflr r0
  89. stwu r0, -4(r1)
  90. stwu r4, -4(r1)
  91. mtlr r3
  92. mr r3, r5
  93. blrl
  94. lwz r4, 0(r1)
  95. stw r3, 0(r4)
  96. lwz r0, 4(r1)
  97. addi r1, r1, 8
  98. mtlr r0
  99. blr
  100. /* void cpu_post_exec_21 (ulong *code, ulong *cr, ulong *res, ulong op1); */
  101. .global cpu_post_exec_21
  102. cpu_post_exec_21:
  103. isync
  104. mflr r0
  105. stwu r0, -4(r1)
  106. stwu r4, -4(r1)
  107. stwu r5, -4(r1)
  108. li r0, 0
  109. mtxer r0
  110. lwz r0, 0(r4)
  111. mtcr r0
  112. mtlr r3
  113. mr r3, r6
  114. blrl
  115. mfcr r0
  116. lwz r4, 4(r1)
  117. stw r0, 0(r4)
  118. lwz r4, 0(r1)
  119. stw r3, 0(r4)
  120. lwz r0, 8(r1)
  121. addi r1, r1, 12
  122. mtlr r0
  123. blr
  124. /* void cpu_post_exec_22 (ulong *code, ulong *cr, ulong *res, ulong op1,
  125. ulong op2); */
  126. .global cpu_post_exec_22
  127. cpu_post_exec_22:
  128. isync
  129. mflr r0
  130. stwu r0, -4(r1)
  131. stwu r4, -4(r1)
  132. stwu r5, -4(r1)
  133. li r0, 0
  134. mtxer r0
  135. lwz r0, 0(r4)
  136. mtcr r0
  137. mtlr r3
  138. mr r3, r6
  139. mr r4, r7
  140. blrl
  141. mfcr r0
  142. lwz r4, 4(r1)
  143. stw r0, 0(r4)
  144. lwz r4, 0(r1)
  145. stw r3, 0(r4)
  146. lwz r0, 8(r1)
  147. addi r1, r1, 12
  148. mtlr r0
  149. blr
  150. /* void cpu_post_exec_12w (ulong *code, ulong *op1, ulong op2, ulong op3); */
  151. .global cpu_post_exec_12w
  152. cpu_post_exec_12w:
  153. isync
  154. mflr r0
  155. stwu r0, -4(r1)
  156. stwu r4, -4(r1)
  157. mtlr r3
  158. lwz r3, 0(r4)
  159. mr r4, r5
  160. mr r5, r6
  161. blrl
  162. lwz r4, 0(r1)
  163. stw r3, 0(r4)
  164. lwz r0, 4(r1)
  165. addi r1, r1, 8
  166. mtlr r0
  167. blr
  168. /* void cpu_post_exec_11w (ulong *code, ulong *op1, ulong op2); */
  169. .global cpu_post_exec_11w
  170. cpu_post_exec_11w:
  171. isync
  172. mflr r0
  173. stwu r0, -4(r1)
  174. stwu r4, -4(r1)
  175. mtlr r3
  176. lwz r3, 0(r4)
  177. mr r4, r5
  178. blrl
  179. lwz r4, 0(r1)
  180. stw r3, 0(r4)
  181. lwz r0, 4(r1)
  182. addi r1, r1, 8
  183. mtlr r0
  184. blr
  185. /* void cpu_post_exec_22w (ulong *code, ulong *op1, ulong op2, ulong *op3); */
  186. .global cpu_post_exec_22w
  187. cpu_post_exec_22w:
  188. isync
  189. mflr r0
  190. stwu r0, -4(r1)
  191. stwu r4, -4(r1)
  192. stwu r6, -4(r1)
  193. mtlr r3
  194. lwz r3, 0(r4)
  195. mr r4, r5
  196. blrl
  197. lwz r4, 4(r1)
  198. stw r3, 0(r4)
  199. lwz r4, 0(r1)
  200. stw r5, 0(r4)
  201. lwz r0, 8(r1)
  202. addi r1, r1, 12
  203. mtlr r0
  204. blr
  205. /* void cpu_post_exec_21w (ulong *code, ulong *op1, ulong *op2); */
  206. .global cpu_post_exec_21w
  207. cpu_post_exec_21w:
  208. isync
  209. mflr r0
  210. stwu r0, -4(r1)
  211. stwu r4, -4(r1)
  212. stwu r5, -4(r1)
  213. mtlr r3
  214. lwz r3, 0(r4)
  215. blrl
  216. lwz r5, 4(r1)
  217. stw r3, 0(r5)
  218. lwz r5, 0(r1)
  219. stw r4, 0(r5)
  220. lwz r0, 8(r1)
  221. addi r1, r1, 12
  222. mtlr r0
  223. blr
  224. /* void cpu_post_exec_21x (ulong *code, ulong *op1, ulong *op2, ulong op3); */
  225. .global cpu_post_exec_21x
  226. cpu_post_exec_21x:
  227. isync
  228. mflr r0
  229. stwu r0, -4(r1)
  230. stwu r4, -4(r1)
  231. stwu r5, -4(r1)
  232. mtlr r3
  233. mr r3, r6
  234. blrl
  235. lwz r5, 4(r1)
  236. stw r3, 0(r5)
  237. lwz r5, 0(r1)
  238. stw r4, 0(r5)
  239. lwz r0, 8(r1)
  240. addi r1, r1, 12
  241. mtlr r0
  242. blr
  243. /* void cpu_post_exec_31 (ulong *code, ulong *ctr, ulong *lr, ulong *jump,
  244. ulong cr); */
  245. .global cpu_post_exec_31
  246. cpu_post_exec_31:
  247. isync
  248. mflr r0
  249. stwu r0, -4(r1)
  250. stwu r4, -4(r1)
  251. stwu r5, -4(r1)
  252. stwu r6, -4(r1)
  253. mtlr r3
  254. lwz r3, 0(r4)
  255. lwz r4, 0(r5)
  256. mr r6, r7
  257. blrl
  258. lwz r7, 8(r1)
  259. stw r3, 0(r7)
  260. lwz r7, 4(r1)
  261. stw r4, 0(r7)
  262. lwz r7, 0(r1)
  263. stw r5, 0(r7)
  264. lwz r0, 12(r1)
  265. addi r1, r1, 16
  266. mtlr r0
  267. blr
  268. /* int cpu_post_complex_1_asm (int a1, int a2, int a3, int a4, int n); */
  269. .global cpu_post_complex_1_asm
  270. cpu_post_complex_1_asm:
  271. li r9,0
  272. cmpw r9,r7
  273. bge cpu_post_complex_1_done
  274. mtctr r7
  275. cpu_post_complex_1_loop:
  276. mullw r0,r3,r4
  277. subf r0,r5,r0
  278. divw r0,r0,r6
  279. add r9,r9,r0
  280. bdnz cpu_post_complex_1_loop
  281. cpu_post_complex_1_done:
  282. mr r3,r9
  283. blr
  284. /* int cpu_post_complex_2_asm (int x, int n); */
  285. .global cpu_post_complex_2_asm
  286. cpu_post_complex_2_asm:
  287. mr. r0,r4
  288. mtctr r0
  289. mr r0,r3
  290. li r3,1
  291. li r4,1
  292. blelr
  293. cpu_post_complex_2_loop:
  294. mullw r3,r3,r0
  295. add r3,r3,r4
  296. bdnz cpu_post_complex_2_loop
  297. blr
  298. #endif
  299. #endif