misc.S 7.3 KB

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