2 * arch/xtensa/mm/misc.S
4 * Miscellaneous assembly functions.
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
10 * Copyright (C) 2001 - 2007 Tensilica Inc.
12 * Chris Zankel <chris@zankel.net>
16 #include <linux/linkage.h>
18 #include <asm/pgtable.h>
19 #include <asm/asmmacro.h>
20 #include <asm/cacheasm.h>
21 #include <asm/tlbflush.h>
25 * clear_page and clear_user_page are the same for non-cache-aliased configs.
27 * clear_page (unsigned long page)
36 __loopi a2, a7, PAGE_SIZE, 32
52 * copy_page and copy_user_page are the same for non-cache-aliased configs.
54 * copy_page (void *to, void *from)
62 __loopi a2, a4, PAGE_SIZE, 32
95 * If we have to deal with cache aliasing, we use temporary memory mappings
96 * to ensure that the source and destination pages have the same color as
97 * the virtual address. We use way 0 and 1 for temporary mappings in such cases.
99 * The temporary DTLB entries shouldn't be flushed by interrupts, but are
100 * flushed by preemptive task switches. Special code in the
101 * fast_second_level_miss handler re-established the temporary mapping.
102 * It requires that the PPNs for the destination and source addresses are
103 * in a6, and a7, respectively.
106 /* TLB miss exceptions are treated special in the following region */
108 ENTRY(__tlbtemp_mapping_start)
110 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
113 * clear_page_alias(void *addr, unsigned long paddr)
117 ENTRY(clear_page_alias)
121 /* Skip setting up a temporary DTLB if not aliased low page. */
127 /* Setup a temporary DTLB for the addr. */
129 addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
135 __loopi a2, a7, PAGE_SIZE, 32
149 /* We need to invalidate the temporary idtlb entry, if any. */
156 ENDPROC(clear_page_alias)
159 * copy_page_alias(void *to, void *from,
161 * unsigned long to_paddr, unsigned long from_paddr)
165 ENTRY(copy_page_alias)
169 /* Skip setting up a temporary DTLB for destination if not aliased. */
175 /* Setup a temporary DTLB for destination. */
177 addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE)
181 /* Skip setting up a temporary DTLB for source if not aliased. */
185 /* Setup a temporary DTLB for source. */
187 addi a7, a5, PAGE_KERNEL
188 addi a8, a3, 1 # way1
193 1: __loopi a2, a4, PAGE_SIZE, 32
220 /* We need to invalidate any temporary mapping! */
226 1: addi a2, a2, -PAGE_SIZE
232 2: addi a3, a3, -PAGE_SIZE+1
238 ENDPROC(copy_page_alias)
242 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
245 * void __flush_invalidate_dcache_page_alias (addr, phys)
249 ENTRY(__flush_invalidate_dcache_page_alias)
253 movi a7, 0 # required for exception handler
254 addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
259 ___flush_invalidate_dcache_page a2 a3
266 ENDPROC(__flush_invalidate_dcache_page_alias)
269 * void __invalidate_dcache_page_alias (addr, phys)
273 ENTRY(__invalidate_dcache_page_alias)
277 movi a7, 0 # required for exception handler
278 addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
283 ___invalidate_dcache_page a2 a3
290 ENDPROC(__invalidate_dcache_page_alias)
293 ENTRY(__tlbtemp_mapping_itlb)
295 #if (ICACHE_WAY_SIZE > PAGE_SIZE)
297 ENTRY(__invalidate_icache_page_alias)
301 addi a6, a3, (PAGE_KERNEL_EXEC | _PAGE_HW_WRITE)
306 ___invalidate_icache_page a2 a3
312 ENDPROC(__invalidate_icache_page_alias)
316 /* End of special treatment in tlb miss exception */
318 ENTRY(__tlbtemp_mapping_end)
323 * void __invalidate_icache_page(ulong start)
326 ENTRY(__invalidate_icache_page)
330 ___invalidate_icache_page a2 a3
335 ENDPROC(__invalidate_icache_page)
338 * void __invalidate_dcache_page(ulong start)
341 ENTRY(__invalidate_dcache_page)
345 ___invalidate_dcache_page a2 a3
350 ENDPROC(__invalidate_dcache_page)
353 * void __flush_invalidate_dcache_page(ulong start)
356 ENTRY(__flush_invalidate_dcache_page)
360 ___flush_invalidate_dcache_page a2 a3
365 ENDPROC(__flush_invalidate_dcache_page)
368 * void __flush_dcache_page(ulong start)
371 ENTRY(__flush_dcache_page)
375 ___flush_dcache_page a2 a3
380 ENDPROC(__flush_dcache_page)
383 * void __invalidate_icache_range(ulong start, ulong size)
386 ENTRY(__invalidate_icache_range)
390 ___invalidate_icache_range a2 a3 a4
395 ENDPROC(__invalidate_icache_range)
398 * void __flush_invalidate_dcache_range(ulong start, ulong size)
401 ENTRY(__flush_invalidate_dcache_range)
405 ___flush_invalidate_dcache_range a2 a3 a4
410 ENDPROC(__flush_invalidate_dcache_range)
413 * void _flush_dcache_range(ulong start, ulong size)
416 ENTRY(__flush_dcache_range)
420 ___flush_dcache_range a2 a3 a4
425 ENDPROC(__flush_dcache_range)
428 * void _invalidate_dcache_range(ulong start, ulong size)
431 ENTRY(__invalidate_dcache_range)
435 ___invalidate_dcache_range a2 a3 a4
439 ENDPROC(__invalidate_dcache_range)
442 * void _invalidate_icache_all(void)
445 ENTRY(__invalidate_icache_all)
449 ___invalidate_icache_all a2 a3
454 ENDPROC(__invalidate_icache_all)
457 * void _flush_invalidate_dcache_all(void)
460 ENTRY(__flush_invalidate_dcache_all)
464 ___flush_invalidate_dcache_all a2 a3
469 ENDPROC(__flush_invalidate_dcache_all)
472 * void _invalidate_dcache_all(void)
475 ENTRY(__invalidate_dcache_all)
479 ___invalidate_dcache_all a2 a3
484 ENDPROC(__invalidate_dcache_all)