misc.S 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /*
  2. * arch/xtensa/mm/misc.S
  3. *
  4. * Miscellaneous assembly functions.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. *
  10. * Copyright (C) 2001 - 2007 Tensilica Inc.
  11. *
  12. * Chris Zankel <chris@zankel.net>
  13. */
  14. #include <linux/linkage.h>
  15. #include <linux/pgtable.h>
  16. #include <asm/page.h>
  17. #include <asm/asmmacro.h>
  18. #include <asm/cacheasm.h>
  19. #include <asm/tlbflush.h>
  20. /*
  21. * clear_page and clear_user_page are the same for non-cache-aliased configs.
  22. *
  23. * clear_page (unsigned long page)
  24. * a2
  25. */
  26. ENTRY(clear_page)
  27. abi_entry_default
  28. movi a3, 0
  29. __loopi a2, a7, PAGE_SIZE, 32
  30. s32i a3, a2, 0
  31. s32i a3, a2, 4
  32. s32i a3, a2, 8
  33. s32i a3, a2, 12
  34. s32i a3, a2, 16
  35. s32i a3, a2, 20
  36. s32i a3, a2, 24
  37. s32i a3, a2, 28
  38. __endla a2, a7, 32
  39. abi_ret_default
  40. ENDPROC(clear_page)
  41. EXPORT_SYMBOL(clear_page)
  42. /*
  43. * copy_page and copy_user_page are the same for non-cache-aliased configs.
  44. *
  45. * copy_page (void *to, void *from)
  46. * a2 a3
  47. */
  48. ENTRY(copy_page)
  49. abi_entry_default
  50. __loopi a2, a4, PAGE_SIZE, 32
  51. l32i a8, a3, 0
  52. l32i a9, a3, 4
  53. s32i a8, a2, 0
  54. s32i a9, a2, 4
  55. l32i a8, a3, 8
  56. l32i a9, a3, 12
  57. s32i a8, a2, 8
  58. s32i a9, a2, 12
  59. l32i a8, a3, 16
  60. l32i a9, a3, 20
  61. s32i a8, a2, 16
  62. s32i a9, a2, 20
  63. l32i a8, a3, 24
  64. l32i a9, a3, 28
  65. s32i a8, a2, 24
  66. s32i a9, a2, 28
  67. addi a2, a2, 32
  68. addi a3, a3, 32
  69. __endl a2, a4
  70. abi_ret_default
  71. ENDPROC(copy_page)
  72. EXPORT_SYMBOL(copy_page)
  73. #ifdef CONFIG_MMU
  74. /*
  75. * If we have to deal with cache aliasing, we use temporary memory mappings
  76. * to ensure that the source and destination pages have the same color as
  77. * the virtual address. We use way 0 and 1 for temporary mappings in such cases.
  78. *
  79. * The temporary DTLB entries shouldn't be flushed by interrupts, but are
  80. * flushed by preemptive task switches. Special code in the
  81. * fast_second_level_miss handler re-established the temporary mapping.
  82. * It requires that the PPNs for the destination and source addresses are
  83. * in a6, and a7, respectively.
  84. */
  85. /* TLB miss exceptions are treated special in the following region */
  86. ENTRY(__tlbtemp_mapping_start)
  87. #if (DCACHE_WAY_SIZE > PAGE_SIZE)
  88. /*
  89. * clear_page_alias(void *addr, unsigned long paddr)
  90. * a2 a3
  91. */
  92. ENTRY(clear_page_alias)
  93. abi_entry_default
  94. movi a5, PAGE_OFFSET
  95. addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
  96. mov a4, a2
  97. wdtlb a6, a2
  98. dsync
  99. movi a3, 0
  100. __loopi a2, a7, PAGE_SIZE, 32
  101. s32i a3, a2, 0
  102. s32i a3, a2, 4
  103. s32i a3, a2, 8
  104. s32i a3, a2, 12
  105. s32i a3, a2, 16
  106. s32i a3, a2, 20
  107. s32i a3, a2, 24
  108. s32i a3, a2, 28
  109. __endla a2, a7, 32
  110. /* We need to invalidate the temporary dtlb entry. */
  111. idtlb a4
  112. dsync
  113. abi_ret_default
  114. ENDPROC(clear_page_alias)
  115. /*
  116. * copy_page_alias(void *to, void *from,
  117. * a2 a3
  118. * unsigned long to_paddr, unsigned long from_paddr)
  119. * a4 a5
  120. */
  121. ENTRY(copy_page_alias)
  122. abi_entry_default
  123. /* Setup a temporary DTLB for destination. */
  124. addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE)
  125. wdtlb a6, a2
  126. dsync
  127. /* Setup a temporary DTLB for source. */
  128. addi a7, a5, PAGE_KERNEL
  129. addi a8, a3, 1 # way1
  130. wdtlb a7, a8
  131. dsync
  132. 1: __loopi a2, a4, PAGE_SIZE, 32
  133. l32i a8, a3, 0
  134. l32i a9, a3, 4
  135. s32i a8, a2, 0
  136. s32i a9, a2, 4
  137. l32i a8, a3, 8
  138. l32i a9, a3, 12
  139. s32i a8, a2, 8
  140. s32i a9, a2, 12
  141. l32i a8, a3, 16
  142. l32i a9, a3, 20
  143. s32i a8, a2, 16
  144. s32i a9, a2, 20
  145. l32i a8, a3, 24
  146. l32i a9, a3, 28
  147. s32i a8, a2, 24
  148. s32i a9, a2, 28
  149. addi a2, a2, 32
  150. addi a3, a3, 32
  151. __endl a2, a4
  152. /* We need to invalidate any temporary mapping! */
  153. addi a2, a2, -PAGE_SIZE
  154. idtlb a2
  155. dsync
  156. addi a3, a3, -PAGE_SIZE+1
  157. idtlb a3
  158. dsync
  159. abi_ret_default
  160. ENDPROC(copy_page_alias)
  161. #endif
  162. #if (DCACHE_WAY_SIZE > PAGE_SIZE)
  163. /*
  164. * void __flush_invalidate_dcache_page_alias (addr, phys)
  165. * a2 a3
  166. */
  167. ENTRY(__flush_invalidate_dcache_page_alias)
  168. abi_entry_default
  169. movi a7, 0 # required for exception handler
  170. addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
  171. mov a4, a2
  172. wdtlb a6, a2
  173. dsync
  174. ___flush_invalidate_dcache_page a2 a3
  175. idtlb a4
  176. dsync
  177. abi_ret_default
  178. ENDPROC(__flush_invalidate_dcache_page_alias)
  179. /*
  180. * void __invalidate_dcache_page_alias (addr, phys)
  181. * a2 a3
  182. */
  183. ENTRY(__invalidate_dcache_page_alias)
  184. abi_entry_default
  185. movi a7, 0 # required for exception handler
  186. addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
  187. mov a4, a2
  188. wdtlb a6, a2
  189. dsync
  190. ___invalidate_dcache_page a2 a3
  191. idtlb a4
  192. dsync
  193. abi_ret_default
  194. ENDPROC(__invalidate_dcache_page_alias)
  195. #endif
  196. ENTRY(__tlbtemp_mapping_itlb)
  197. #if (ICACHE_WAY_SIZE > PAGE_SIZE)
  198. ENTRY(__invalidate_icache_page_alias)
  199. abi_entry_default
  200. addi a6, a3, (PAGE_KERNEL_EXEC | _PAGE_HW_WRITE)
  201. mov a4, a2
  202. witlb a6, a2
  203. isync
  204. ___invalidate_icache_page a2 a3
  205. iitlb a4
  206. isync
  207. abi_ret_default
  208. ENDPROC(__invalidate_icache_page_alias)
  209. #endif
  210. /* End of special treatment in tlb miss exception */
  211. ENTRY(__tlbtemp_mapping_end)
  212. #endif /* CONFIG_MMU
  213. /*
  214. * void __invalidate_icache_page(ulong start)
  215. */
  216. ENTRY(__invalidate_icache_page)
  217. abi_entry_default
  218. ___invalidate_icache_page a2 a3
  219. isync
  220. abi_ret_default
  221. ENDPROC(__invalidate_icache_page)
  222. /*
  223. * void __invalidate_dcache_page(ulong start)
  224. */
  225. ENTRY(__invalidate_dcache_page)
  226. abi_entry_default
  227. ___invalidate_dcache_page a2 a3
  228. dsync
  229. abi_ret_default
  230. ENDPROC(__invalidate_dcache_page)
  231. /*
  232. * void __flush_invalidate_dcache_page(ulong start)
  233. */
  234. ENTRY(__flush_invalidate_dcache_page)
  235. abi_entry_default
  236. ___flush_invalidate_dcache_page a2 a3
  237. dsync
  238. abi_ret_default
  239. ENDPROC(__flush_invalidate_dcache_page)
  240. /*
  241. * void __flush_dcache_page(ulong start)
  242. */
  243. ENTRY(__flush_dcache_page)
  244. abi_entry_default
  245. ___flush_dcache_page a2 a3
  246. dsync
  247. abi_ret_default
  248. ENDPROC(__flush_dcache_page)
  249. /*
  250. * void __invalidate_icache_range(ulong start, ulong size)
  251. */
  252. ENTRY(__invalidate_icache_range)
  253. abi_entry_default
  254. ___invalidate_icache_range a2 a3 a4
  255. isync
  256. abi_ret_default
  257. ENDPROC(__invalidate_icache_range)
  258. EXPORT_SYMBOL(__invalidate_icache_range)
  259. /*
  260. * void __flush_invalidate_dcache_range(ulong start, ulong size)
  261. */
  262. ENTRY(__flush_invalidate_dcache_range)
  263. abi_entry_default
  264. ___flush_invalidate_dcache_range a2 a3 a4
  265. dsync
  266. abi_ret_default
  267. ENDPROC(__flush_invalidate_dcache_range)
  268. /*
  269. * void _flush_dcache_range(ulong start, ulong size)
  270. */
  271. ENTRY(__flush_dcache_range)
  272. abi_entry_default
  273. ___flush_dcache_range a2 a3 a4
  274. dsync
  275. abi_ret_default
  276. ENDPROC(__flush_dcache_range)
  277. EXPORT_SYMBOL(__flush_dcache_range)
  278. /*
  279. * void _invalidate_dcache_range(ulong start, ulong size)
  280. */
  281. ENTRY(__invalidate_dcache_range)
  282. abi_entry_default
  283. ___invalidate_dcache_range a2 a3 a4
  284. abi_ret_default
  285. ENDPROC(__invalidate_dcache_range)
  286. EXPORT_SYMBOL(__invalidate_dcache_range)
  287. /*
  288. * void _invalidate_icache_all(void)
  289. */
  290. ENTRY(__invalidate_icache_all)
  291. abi_entry_default
  292. ___invalidate_icache_all a2 a3
  293. isync
  294. abi_ret_default
  295. ENDPROC(__invalidate_icache_all)
  296. /*
  297. * void _flush_invalidate_dcache_all(void)
  298. */
  299. ENTRY(__flush_invalidate_dcache_all)
  300. abi_entry_default
  301. ___flush_invalidate_dcache_all a2 a3
  302. dsync
  303. abi_ret_default
  304. ENDPROC(__flush_invalidate_dcache_all)
  305. /*
  306. * void _invalidate_dcache_all(void)
  307. */
  308. ENTRY(__invalidate_dcache_all)
  309. abi_entry_default
  310. ___invalidate_dcache_all a2 a3
  311. dsync
  312. abi_ret_default
  313. ENDPROC(__invalidate_dcache_all)