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